mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
tests by Graham
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@36863 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
bff29b02a6
commit
da5934191c
4 changed files with 102 additions and 5 deletions
|
@ -27,11 +27,11 @@
|
|||
|
||||
#import "common.h"
|
||||
|
||||
#import <Foundation/NSInvocationOperation.h>
|
||||
#import <Foundation/NSException.h>
|
||||
#import <Foundation/NSInvocation.h>
|
||||
#import <Foundation/NSMethodSignature.h>
|
||||
#import <Foundation/NSValue.h>
|
||||
#import "Foundation/NSInvocationOperation.h"
|
||||
#import "Foundation/NSException.h"
|
||||
#import "Foundation/NSInvocation.h"
|
||||
#import "Foundation/NSMethodSignature.h"
|
||||
#import "Foundation/NSValue.h"
|
||||
|
||||
@implementation NSInvocationOperation
|
||||
|
||||
|
|
27
Tests/base/NSInvocationOperation/GNUmakefile
Normal file
27
Tests/base/NSInvocationOperation/GNUmakefile
Normal file
|
@ -0,0 +1,27 @@
|
|||
# __GENERATED__ makefile marker
|
||||
#
|
||||
|
||||
include $(GNUSTEP_MAKEFILES)/common.make
|
||||
-include ../GNUmakefile.super
|
||||
|
||||
GNUSTEP_OBJ_DIR=./obj
|
||||
|
||||
TEST_TOOL_NAME = basic
|
||||
|
||||
ifeq ($(gcov),yes)
|
||||
ADDITIONAL_OBJCFLAGS += -ftest-coverage -fprofile-arcs
|
||||
ADDITIONAL_OBJCCFLAGS += -ftest-coverage -fprofile-arcs
|
||||
ADDITIONAL_LDFLAGS += -ftest-coverage -fprofile-arcs
|
||||
ADDITIONAL_TOOL_LIBS+=-lgcov
|
||||
endif
|
||||
|
||||
|
||||
basic_OBJC_FILES=basic.m
|
||||
|
||||
-include GNUmakefile.preamble
|
||||
include $(GNUSTEP_MAKEFILES)/test-tool.make
|
||||
-include GNUmakefile.postamble
|
||||
|
||||
after-clean::
|
||||
rm -f core tests.log tests.sum oldtests.log oldtests.sum
|
||||
|
0
Tests/base/NSInvocationOperation/TestInfo
Normal file
0
Tests/base/NSInvocationOperation/TestInfo
Normal file
70
Tests/base/NSInvocationOperation/basic.m
Normal file
70
Tests/base/NSInvocationOperation/basic.m
Normal file
|
@ -0,0 +1,70 @@
|
|||
#import <Foundation/NSInvocationOperation.h>
|
||||
#import <Foundation/NSInvocation.h>
|
||||
#import <Foundation/NSOperation.h>
|
||||
#import <Foundation/NSValue.h>
|
||||
#import <Foundation/NSAutoreleasePool.h>
|
||||
#import "ObjectTesting.h"
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
NSInvocationOperation *op;
|
||||
NSInvocation *inv1, *inv2;
|
||||
NSValue *val;
|
||||
int length;
|
||||
NSString *hello = @"hello", *uppercaseHello;
|
||||
NSOperationQueue *queue = [NSOperationQueue new];
|
||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
|
||||
op = [[NSInvocationOperation alloc] initWithTarget: hello
|
||||
selector: @selector(length)
|
||||
object: nil];
|
||||
[queue addOperations: [NSArray arrayWithObject: op]
|
||||
waitUntilFinished: YES];
|
||||
val = [op result];
|
||||
[val getValue: &length];
|
||||
PASS((length == 5), "Can invoke a selector on a target");
|
||||
[op release];
|
||||
|
||||
inv1 = [NSInvocation invocationWithMethodSignature:
|
||||
[hello methodSignatureForSelector: @selector(uppercaseString)]];
|
||||
[inv1 setTarget: hello];
|
||||
[inv1 setSelector: @selector(uppercaseString)];
|
||||
op = [[NSInvocationOperation alloc] initWithInvocation: inv1];
|
||||
inv2 = [op invocation];
|
||||
PASS(([inv2 isEqual: inv1]), "Can recover an operation's invocation");
|
||||
[queue addOperations: [NSArray arrayWithObject: op]
|
||||
waitUntilFinished: YES];
|
||||
uppercaseHello = [op result];
|
||||
PASS(([uppercaseHello isEqualToString: @"HELLO"]), "Can schedule an NSInvocation");
|
||||
[op release];
|
||||
|
||||
op = [[NSInvocationOperation alloc] initWithTarget: hello
|
||||
selector: @selector(release)
|
||||
object: nil];
|
||||
[queue addOperations: [NSArray arrayWithObject: op]
|
||||
waitUntilFinished: YES];
|
||||
PASS_EXCEPTION(([op result]), NSInvocationOperationVoidResultException,
|
||||
"Can't get result of a void invocation");
|
||||
[op release];
|
||||
|
||||
op = [[NSInvocationOperation alloc] initWithTarget: hello
|
||||
selector: @selector(length)
|
||||
object: nil];
|
||||
[op cancel];
|
||||
[queue addOperations: [NSArray arrayWithObject: op]
|
||||
waitUntilFinished: YES];
|
||||
PASS_EXCEPTION(([op result]), NSInvocationOperationCancelledException,
|
||||
"Can't get the result of a cancelled invocation");
|
||||
[op release];
|
||||
|
||||
op = [[NSInvocationOperation alloc] initWithTarget: hello
|
||||
selector: @selector(length)
|
||||
object: nil];
|
||||
PASS(([op result] == nil), "Result is nil before the invocation has completed");
|
||||
[op release];
|
||||
|
||||
[queue release];
|
||||
[arp release]; arp = nil;
|
||||
return 0;
|
||||
}
|
Loading…
Reference in a new issue