Important change to the START_SET and END_SET macros to stop their use

being confusing.  They now both take a simple C-string argument which
names the set, and the macros check that each end matches a start of
the same name.  Since tis means that a START_SET no longer takes an
argument sayng whether or notthe set is to be skipped, we now have a
SKIP macro to be used inside a set to skip to the end of it.  This
is actually more versatile as we can have multiple SKIP macros in the
same set, each providing a different reason for the set being skipped.
Also removed a few obsolete/unused functions and macros.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@32355 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2011-02-24 16:26:01 +00:00
parent 7027375a67
commit e6dc5a58b6
37 changed files with 214 additions and 195 deletions

View file

@ -30,7 +30,7 @@
void testRootClass(const char *clsName)
{
testHopeful = YES;
START_SET(YES)
START_SET("testRootClass")
Class cls = objc_getClass(clsName);
Class super = class_getSuperclass(cls);
Class meta = object_getClass(cls);
@ -51,7 +51,7 @@ void testRootClass(const char *clsName)
void testNonRootClass(const char *clsName)
{
testHopeful = YES;
START_SET(YES)
START_SET("testNonRootClass")
Class cls = objc_getClass(clsName);
Class super = class_getSuperclass(cls);
Class meta = object_getClass(cls);

View file

@ -1,9 +1,12 @@
#import "Testing.h"
#ifndef OBJC_NEW_PROPERTIES
int main(void)
{
unsupported("Your compiler does not support declared properties");
return 0;
START_SET("Properties")
SKIP("Your compiler does not support declared properties");
END_SET("Properties")
return 0;
}
#else
#import <Foundation/Foundation.h>
@ -11,8 +14,8 @@ int main(void)
@interface A : NSObject
{
@private
NSObject *n;
NSObject *a;
NSObject *n;
NSObject *a;
}
@property (nonatomic,readwrite,retain) NSObject *n;
@property (readwrite,retain) NSObject *a;
@ -21,43 +24,43 @@ int main(void)
@implementation A
- (NSObject *)n
{
return [[n retain] autorelease];
return [[n retain] autorelease];
}
- (void)setN:(NSObject *)newN
{
if (n != newN)
{
[n release];
n = [newN retain];
}
if (n != newN)
{
[n release];
n = [newN retain];
}
}
- (NSObject *)a
{
return [[a retain] autorelease];
return [[a retain] autorelease];
}
- (void)setA:(NSObject *)newA
{
@synchronized(self)
{
if (a != newA)
{
[a release];
a = [newA retain];
}
}
@synchronized(self)
{
if (a != newA)
{
[a release];
a = [newA retain];
}
}
}
- (void)dealloc
{
[a release];
[n release];
[super dealloc];
[a release];
[n release];
[super dealloc];
}
@end
@interface B : NSObject
// If we've got non-fragile ABI support, try not declaring the ivars
#if !__has_feature(objc_nonfragile_abi)
{
id a, b, c, d;
id a, b, c, d;
}
#endif
@property (nonatomic,readwrite,retain) id a;
@ -69,42 +72,42 @@ int main(void)
@synthesize a,b,c,d;
- (void)dealloc
{
[a release];
[b release];
[c release];
[d release];
[super dealloc];
[a release];
[b release];
[c release];
[d release];
[super dealloc];
}
@end
int main(int argc, char **argv)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
id testObject = [@"str" mutableCopy];
id testObject = [@"str" mutableCopy];
A *a = [[A alloc] init];
// Note: use of dot syntax here is only for testing purposes. This case -
// in the test suite and outside of the main code - does not invoke
// requirement to buy all of the other GNUstep developers a beer.
a.a = testObject;
PASS(a.a == testObject, "Setting manually created atomic property");
a.n = testObject;
PASS(a.n == testObject, "Setting manually created nonatomic property");
DESTROY(a);
B *b = [B new];
b.a = testObject;
PASS(b.a == testObject, "Setting synthesized atomic property");
b.b = testObject;
PASS(b.b == testObject, "Setting synthesized nonatomic property");
b.c = testObject;
PASS(b.c != testObject, "Synthesized nonatomic copy method did not do simple assign");
PASS([testObject isEqualToString: b.c], "Synthesized nonatomic copy method did copy");
b.d = testObject;
PASS(b.d != testObject, "Synthesized atomic copy method did not do simple assign");
PASS([testObject isEqualToString: b.d], "Synthesized atomic copy method did copy");
[b release];
return 0;
A *a = [[A alloc] init];
// Note: use of dot syntax here is only for testing purposes. This case -
// in the test suite and outside of the main code - does not invoke
// requirement to buy all of the other GNUstep developers a beer.
a.a = testObject;
PASS(a.a == testObject, "Setting manually created atomic property");
a.n = testObject;
PASS(a.n == testObject, "Setting manually created nonatomic property");
DESTROY(a);
B *b = [B new];
b.a = testObject;
PASS(b.a == testObject, "Setting synthesized atomic property");
b.b = testObject;
PASS(b.b == testObject, "Setting synthesized nonatomic property");
b.c = testObject;
PASS(b.c != testObject, "Synthesized nonatomic copy method did not do simple assign");
PASS([testObject isEqualToString: b.c], "Synthesized nonatomic copy method did copy");
b.d = testObject;
PASS(b.d != testObject, "Synthesized atomic copy method did not do simple assign");
PASS([testObject isEqualToString: b.d], "Synthesized atomic copy method did copy");
[b release];
return 0;
}
#endif

View file

@ -24,8 +24,8 @@ int main()
obj = [NSArray array];
PASS((obj != nil && [obj isKindOfClass:[NSArray class]] && [obj count] == 0),
"+array creates an empty array");
TEST_EXCEPTION([NSArray arrayWithObject:nil];, @"NSInvalidArgumentException",
YES, "+arrayWithObject with nil argument throws exception");
PASS_EXCEPTION([NSArray arrayWithObject:nil];, @"NSInvalidArgumentException",
"+arrayWithObject with nil argument throws exception");
obj = [NSArray arrayWithObject:val1];
PASS(obj != nil && [obj isKindOfClass:[NSArray class]] && [obj count] == 1,

View file

@ -69,7 +69,7 @@ int main()
[a objectAtIndex:0] == val1 && [a objectAtIndex:1] == val2,
"-subarrayWithRange: seems ok");
r = NSMakeRange(1,2);
TEST_EXCEPTION([arr subarrayWithRange:r];,@"NSRangeException",YES,"-subarrayWithRange with invalid range");
PASS_EXCEPTION([arr subarrayWithRange:r];,@"NSRangeException","-subarrayWithRange with invalid range");
}
{

View file

@ -10,7 +10,9 @@
int main()
{
START_SET(NSCALENDAR_SUPPORTED)
START_SET("NSCalendar basic")
if (!NSCALENDAR_SUPPORTED)
SKIP("NSCalendar not supported\nThe ICU library was not available when GNUstep-base was built")
id testObj = [NSCalendar currentCalendar];
test_NSObject(@"NSCalendar", [NSArray arrayWithObject: testObj]);

View file

@ -11,8 +11,11 @@
int main(void)
{
START_SET(NSCALENDAR_SUPPORTED)
START_SET("NSCalendar create")
NSCalendar *cal;
if (!NSCALENDAR_SUPPORTED)
SKIP("NSCalendar not supported\nThe ICU library was not available when GNUstep-base was built")
cal = [NSCalendar currentCalendar];
PASS (cal != nil, "+currentCalendar returns non-nil");

View file

@ -42,22 +42,22 @@ int main()
[data2 getBytes:hold range:NSMakeRange(2,6)];
PASS(strcmp(hold,"st str") == 0, "-getBytes:range works");
TEST_EXCEPTION([data2 getBytes:hold
PASS_EXCEPTION([data2 getBytes:hold
range:NSMakeRange(strlen(str2)*sizeof(void*),1)];,
NSRangeException, YES,
NSRangeException,
"getBytes:range: with bad location");
TEST_EXCEPTION([data2 getBytes:hold
PASS_EXCEPTION([data2 getBytes:hold
range:NSMakeRange(1,(strlen(str2)*sizeof(void*)))];,
NSRangeException, YES,
NSRangeException,
"getBytes:range: with bad length");
TEST_EXCEPTION([data2 subdataWithRange:NSMakeRange((strlen(str2)*sizeof(void*)),1)];,
NSRangeException, YES,
PASS_EXCEPTION([data2 subdataWithRange:NSMakeRange((strlen(str2)*sizeof(void*)),1)];,
NSRangeException,
"-subdataWithRange: with bad location");
TEST_EXCEPTION([data2 subdataWithRange:NSMakeRange(1,(strlen(str2)*sizeof(void*)))];,
NSRangeException, YES,
PASS_EXCEPTION([data2 subdataWithRange:NSMakeRange(1,(strlen(str2)*sizeof(void*)))];,
NSRangeException,
"-subdataWithRange: with bad length");
data2 = [NSData dataWithBytesNoCopy:str1

View file

@ -22,7 +22,9 @@ int main(void)
unsigned int components;
NSInteger year;
START_SET(NSLOCALE_SUPPORTED)
START_SET("NSDateFormatter")
if (!NSLOCALE_SUPPORTED)
SKIP("NSLocale not supported\nThe ICU library was not available when GNUstep-base was built")
[NSTimeZone setDefaultTimeZone: [NSTimeZone timeZoneWithName: @"GMT"]];
@ -73,7 +75,7 @@ int main(void)
PASS_EQUAL(str, @"dd MMM", "Convert date format as Cocoa.");
RELEASE(locale);
END_SET("NSDateFormatter not supported\nThe ICU library was not provided when GNUstep-base was configured/built.")
END_SET("NSDateFormatter")
return 0;
}

View file

@ -35,12 +35,12 @@ int main()
[obj count] == 0,
"+dictionary creates an empty dictionary");
TEST_EXCEPTION([NSDictionary dictionaryWithObject:val1 forKey:nil];,
NSInvalidArgumentException,YES,
PASS_EXCEPTION([NSDictionary dictionaryWithObject:val1 forKey:nil];,
NSInvalidArgumentException,
"+dictionaryWithObject:forKey: with nil key");
TEST_EXCEPTION([NSDictionary dictionaryWithObject:nil forKey:key1];,
NSInvalidArgumentException,YES,
PASS_EXCEPTION([NSDictionary dictionaryWithObject:nil forKey:key1];,
NSInvalidArgumentException,
"+dictionaryWithObject:forKey: with nil value");
obj = [NSDictionary dictionaryWithObject:val1 forKey:key1];
@ -55,8 +55,8 @@ int main()
[obj count] == 2,
"+dictionaryWithObjects:forKeys: builds a dictionary");
TEST_EXCEPTION([NSDictionary dictionaryWithObjects:vals1 forKeys:keys2];,
NSInvalidArgumentException, YES,
PASS_EXCEPTION([NSDictionary dictionaryWithObjects:vals1 forKeys:keys2];,
NSInvalidArgumentException,
"+dictionaryWithObjects:forKeys: with arrays of different sizes");
obj = [NSDictionary dictionaryWithObjects:vals2 forKeys:keys2];
PASS(obj != nil &&

View file

@ -3,24 +3,22 @@
int main(void)
{
START_SET("String throwing")
#if BASE_NATIVE_OBJC_EXCEPTIONS == 1
id caught = nil;
id thrown = @"thrown";
@try
{
@throw thrown;
}
@catch (id str)
{
caught = str;
}
[NSAutoreleasePool new];
START_SET(YES)
PASS((caught == thrown), "Throwing an NSConstantString instance before the class is initialised");
END_SET("String throwing")
id caught = nil;
id thrown = @"thrown";
@try
{
@throw thrown;
}
@catch (id str)
{
caught = str;
}
PASS((caught == thrown), "Throwing an NSConstantString instance before the class is initialised");
#else
[NSAutoreleasePool new];
unsupported("Native exceptions");
SKIP("Native exceptions not supported")
#endif
return 0;
END_SET("String throwing")
return 0;
}

View file

@ -126,8 +126,8 @@ NSLog(@"'%@', '%@'", NSUserName(), [attr fileOwnerAccountName]);
PASS(![mgr isExecutableFileAtPath: @"NSFMCopy"],
"NSFileManager isExecutableFileAtPath: works");
TEST_EXCEPTION([mgr removeFileAtPath: @"." handler: nil];,
NSInvalidArgumentException, YES,
PASS_EXCEPTION([mgr removeFileAtPath: @"." handler: nil];,
NSInvalidArgumentException,
"NSFileManager -removeFileAtPath: @\".\" throws exception");
PASS([mgr createDirectoryAtPath: @"subdir" attributes: nil],
@ -136,12 +136,12 @@ NSLog(@"'%@', '%@'", NSUserName(), [attr fileOwnerAccountName]);
PASS([mgr changeCurrentDirectoryPath: @"subdir"],
"NSFileManager can move into subdir");
TEST_EXCEPTION([mgr removeFileAtPath: @"." handler: nil];,
NSInvalidArgumentException, YES,
PASS_EXCEPTION([mgr removeFileAtPath: @"." handler: nil];,
NSInvalidArgumentException,
"NSFileManager -removeFileAtPath: @\".\" throws exception");
TEST_EXCEPTION([mgr removeFileAtPath: @".." handler: nil];,
NSInvalidArgumentException, YES,
PASS_EXCEPTION([mgr removeFileAtPath: @".." handler: nil];,
NSInvalidArgumentException,
"NSFileManager -removeFileAtPath: @\"..\" throws exception");
/* clean up */
{

View file

@ -25,8 +25,8 @@ int main()
[obj addObject: (void*)@"hello"];
PASS([obj count] == 1, "-addObject: increments count");
TEST_EXCEPTION([obj addObject: nil];,
NSInvalidArgumentException, YES, "-addObject: raises with nil");
PASS_EXCEPTION([obj addObject: nil];,
NSInvalidArgumentException, "-addObject: raises with nil");
[arp release]; arp = nil;
return 0;

View file

@ -77,8 +77,8 @@ int main()
sig = [tar methodSignatureForSelector:@selector(returnIdButThrowException)];
inv = [NSInvocation invocationWithMethodSignature: sig];
[inv setSelector:@selector(returnIdButThrowException)];
TEST_EXCEPTION([inv invokeWithTarget:tar];,@"AnException",YES,"Exception in invocation #1");
TEST_EXCEPTION([inv getReturnValue:&ret];,NSGenericException,YES,"Exception getting return value #1");
PASS_EXCEPTION([inv invokeWithTarget:tar];,@"AnException","Exception in invocation #1");
PASS_EXCEPTION([inv getReturnValue:&ret];,NSGenericException,"Exception getting return value #1");
/* same as above but with a successful call first */
sig = [tar methodSignatureForSelector:@selector(returnIdButThrowException)];
@ -89,8 +89,8 @@ int main()
[inv getReturnValue:&ret];
[inv setSelector:@selector(returnIdButThrowException)];
TEST_EXCEPTION([inv invokeWithTarget:tar];,@"AnException",YES,"Exception in invocation #2");
TEST_EXCEPTION([inv getReturnValue:&ret];,NSGenericException,YES,"Exception getting return value #2");
PASS_EXCEPTION([inv invokeWithTarget:tar];,@"AnException","Exception in invocation #2");
PASS_EXCEPTION([inv getReturnValue:&ret];,NSGenericException,"Exception getting return value #2");
[arp release]; arp = nil;

View file

@ -16,8 +16,8 @@ int main()
obj = [obj initForWritingWithMutableData: data1];
PASS((obj != nil && [obj isKindOfClass:[NSKeyedArchiver class]]), "-initForWritingWithMutableData seems ok");
TEST_EXCEPTION([[NSUnarchiver alloc] initForReadingWithData:nil];,
@"NSInvalidArgumentException", YES,
PASS_EXCEPTION([[NSUnarchiver alloc] initForReadingWithData:nil];,
@"NSInvalidArgumentException",
"Creating an NSUnarchiver with nil data throws an exception");
[arp release]; arp = nil;

View file

@ -41,14 +41,14 @@ int main()
[data2 release];
TEST_EXCEPTION(val1 = [NSString stringWithCString:"Archiver.dat"];
PASS_RUNS(val1 = [NSString stringWithCString:"Archiver.dat"];
val2 = [NSString stringWithCString:"A Goodbye"];
val3 = [NSString stringWithCString:"Testing all strings"];
val4 = [NSNumber numberWithUnsignedInt: 100];
vals1 = [[[NSArray arrayWithObject:val1]
arrayByAddingObject:val2]
arrayByAddingObject: val4];
vals2 = [vals1 arrayByAddingObject: val2];, nil, NO,
vals2 = [vals1 arrayByAddingObject: val2];,
"We can build basic strings and arrays for tests");
PASS([NSKeyedArchiver archiveRootObject:vals2 toFile:val1],

View file

@ -10,14 +10,18 @@
int main()
{
START_SET(NSLOCALE_SUPPORTED)
id testObj = [NSLocale currentLocale];
START_SET("NSLocale")
id testObj;
if (!NSLOCALE_SUPPORTED)
SKIP("NSLocale not supported\nThe ICU library was not available when GNUstep-base was built")
testObj = [NSLocale currentLocale];
test_NSObject(@"NSLocale", [NSArray arrayWithObject: testObj]);
test_keyed_NSCoding([NSArray arrayWithObject: testObj]);
test_NSCopying(@"NSLocale", @"NSLocale",
[NSArray arrayWithObject: testObj], NO, NO);
END_SET("NSLocale not supported.\nThe ICU library was not provided when GNUstep-base was configured/built.")
END_SET("NSLocale")
return 0;
}

View file

@ -10,10 +10,11 @@
int main(void)
{
START_SET(NSLOCALE_SUPPORTED)
START_SET("NSLocale")
NSLocale *locale;
if (!NSLOCALE_SUPPORTED)
SKIP("NSLocale not supported\nThe ICU library was not available when GNUstep-base was built")
locale = [NSLocale systemLocale];
PASS (locale != nil, "+systemLocale returns non-nil");
TEST_FOR_CLASS(@"NSLocale", locale, "+systemLocale return a NSLocale");
@ -22,7 +23,7 @@ int main(void)
PASS (locale != nil, "+currentLocale return non-nil");
TEST_FOR_CLASS(@"NSLocale", locale, "+currentLocale return a NSLocale");
END_SET("NSLocale not supported.\nThe ICU library was not provided when GNUstep-base was configured/built.")
END_SET("NSLocale")
return 0;
}

View file

@ -11,12 +11,15 @@
int main(void)
{
START_SET(NSLOCALE_SUPPORTED)
START_SET("NSLocale")
NSLocale *locale;
id o;
unichar u;
if (!NSLOCALE_SUPPORTED)
SKIP("NSLocale not supported\nThe ICU library was not available when GNUstep-base was built")
// These tests don't really work all that well. I need to come up with
// something better. Most of the ones that fail are because nil is returned.
locale = [[NSLocale alloc] initWithLocaleIdentifier: @"es_ES_PREEURO"];
@ -124,7 +127,7 @@ int main(void)
@"americanenglish",
"Canonical language identifier for 'AmericanEnglish is americanenglish");
END_SET("NSLocale not supported.\nThe ICU library was not provided when GNUstep-base was configured/built.")
END_SET("NSLocale")
return 0;
}

View file

@ -27,8 +27,8 @@ int main()
PASS([obj count] == 1, "-setObject:forKey increments count");
[obj setObject: nil forKey: @"Key2"];
PASS([obj count] == 2, "-setObject:forKey: works with nil value");
TEST_EXCEPTION([obj setObject: val1 forKey: nil];,
NSInvalidArgumentException, YES, "-setObject:forKey: raises with nil key");
PASS_EXCEPTION([obj setObject: val1 forKey: nil];,
NSInvalidArgumentException, "-setObject:forKey: raises with nil key");
[arp release]; arp = nil;
return 0;

View file

@ -29,8 +29,8 @@ int main()
[obj count] == 0,
"+array creates an empty mutable array");
TEST_EXCEPTION([NSMutableArray arrayWithObject:nil];,
NSInvalidArgumentException,YES,
PASS_EXCEPTION([NSMutableArray arrayWithObject:nil];,
NSInvalidArgumentException,
"+arrayWithObject: with nil object raises an exception");
obj = [NSMutableArray arrayWithObject:val1];

View file

@ -79,7 +79,7 @@ int main()
"-subarrayWithRange: seems ok");
r = NSMakeRange(1,2);
TEST_EXCEPTION([arr subarrayWithRange:r];,@"NSRangeException",YES,"-subarrayWithRange with invalid range");
PASS_EXCEPTION([arr subarrayWithRange:r];,@"NSRangeException","-subarrayWithRange with invalid range");
}
{

View file

@ -47,9 +47,9 @@ int main()
strcmp(tmp,str2) == 0,
"-replaceBytesInRange:withBytes suceeds");
free(tmp);
TEST_EXCEPTION([mutable replaceBytesInRange:NSMakeRange([mutable length]+1,6)
PASS_EXCEPTION([mutable replaceBytesInRange:NSMakeRange([mutable length]+1,6)
withBytes:str2];,
NSRangeException,YES,"-replaceBytesInRange:withBytes out of range raises exception");
NSRangeException,"-replaceBytesInRange:withBytes out of range raises exception");
[arp release]; arp = nil;

View file

@ -95,10 +95,8 @@ int main()
isKindOfClass: [NSMutableString class]],
"initWithCharacters:length: creates mutable string for unicode");
TEST_EXCEPTION([[NSMutableString stringWithString: @"foo"]
PASS_RUNS([[NSMutableString stringWithString: @"foo"]
appendString: @"bar"];,
nil,
NO,
"can append to string from NSMutableString +stringWithString:");
testObj = [@"hello" mutableCopy];

View file

@ -19,7 +19,7 @@
int main()
{
START_SET(YES)
START_SET("not-a-number checks")
NSNumber *n;
NSNumber *nan;

View file

@ -14,7 +14,7 @@ int main()
NSNumber *num;
NSString *str;
START_SET(YES)
START_SET("NSNumberFormatter")
PASS(NSNumberFormatterBehavior10_4
== [NSNumberFormatter defaultFormatterBehavior],
@ -63,7 +63,9 @@ int main()
PASS_EQUAL(num, [NSNumber numberWithFloat: 0.0],
"getObjectValue inited with 0.00")
START_SET(NSLOCALE_SUPPORTED)
START_SET("NSLocale")
if (!NSLOCALE_SUPPORTED)
SKIP("NSLocale not supported\nThe ICU library was not available when GNUstep-base was built")
num = [[[NSNumber alloc] initWithFloat: 1234.567] autorelease];
@ -111,9 +113,9 @@ int main()
PASS_EQUAL(str, @"0-1235", "format string of length 1")
END_SET("10.4 behaviors not supported\nThe ICU library was not provided when GNUstep-base was configured/built.")
END_SET("NSLocale")
END_SET("NSNumberFormatter 10.4")
END_SET("NSNumberFormatter")
return 0;
}

View file

@ -73,8 +73,8 @@ int main()
PASS(([obj2 isFinished] == YES),
"a cancelled object can finish");
TEST_EXCEPTION([obj2 start];,
NSInvalidArgumentException, YES,
PASS_EXCEPTION([obj2 start];,
NSInvalidArgumentException,
"NSOperation cannot be started twice");
PASS(([obj2 waitUntilFinished], YES), "wait returns at once");
@ -108,8 +108,8 @@ int main()
PASS(([obj1 maxConcurrentOperationCount] == 1000000), "max concurrent set to a million");
[obj1 setMaxConcurrentOperationCount: NSOperationQueueDefaultMaxConcurrentOperationCount];
PASS(([obj1 maxConcurrentOperationCount] == NSOperationQueueDefaultMaxConcurrentOperationCount), "max concurrent set to default");
TEST_EXCEPTION([obj1 setMaxConcurrentOperationCount: -1000000];,
NSInvalidArgumentException, YES,
PASS_EXCEPTION([obj1 setMaxConcurrentOperationCount: -1000000];,
NSInvalidArgumentException,
"NSOperationQueue cannot be given neagative count");
obj2 = [NSOperation new];

View file

@ -159,8 +159,8 @@ int main()
// Check that raising exception in -main causes operation tracking to fail.
obj = [OpRaise new];
TEST_EXCEPTION([obj start];,
NSGenericException, YES,
PASS_EXCEPTION([obj start];,
NSGenericException,
"NSOperation exceptions propogate from main");
PASS(([obj isFinished] == NO), "operation failed to finish");
PASS(([obj ran] == YES), "operation ran");

View file

@ -15,11 +15,11 @@ int main()
PASS(theClass != Nil, "%s exists",prefix);
obj0 = [NSProxy alloc];
PASS(obj0 != nil, "%s has working alloc",prefix);
TEST_EXCEPTION([obj0 isKindOfClass:theClass];, NSInvalidArgumentException,
YES, "NSProxy -isKindOfClass raises exception");
PASS_EXCEPTION([obj0 isKindOfClass:theClass];, NSInvalidArgumentException,
"NSProxy -isKindOfClass raises exception");
TEST_EXCEPTION([obj0 isMemberOfClass:theClass];,
NSInvalidArgumentException, YES,
PASS_EXCEPTION([obj0 isMemberOfClass:theClass];,
NSInvalidArgumentException,
"NSProxy -isKindOfClass raises exception");
obj1 = [NSProxy allocWithZone:testZone];

View file

@ -20,14 +20,14 @@ int main()
PASS(run != nil, "NSRunLoop understands [+currentRunLoop]");
PASS([run currentMode] == nil, "-currentMode returns nil");
TEST_EXCEPTION(date = [NSDate dateWithTimeIntervalSinceNow:3];
PASS_RUNS(date = [NSDate dateWithTimeIntervalSinceNow:3];
[run runUntilDate:date];,
nil,NO,"-runUntilDate: works");
TEST_EXCEPTION(date = [NSDate dateWithTimeIntervalSinceNow:5];
"-runUntilDate: works");
PASS_RUNS(date = [NSDate dateWithTimeIntervalSinceNow:5];
tim = [NSTimer scheduledTimerWithTimeInterval: 2.0
invocation:inv
repeats:YES];,
nil,NO,"-runUntilDate: works with a timer");
"-runUntilDate: works with a timer");

View file

@ -140,36 +140,38 @@ int main()
[defaultOutput setDelegate: nil];
#endif
START_SET(SSL_SUPPORTED)
done = NO;
byteCount = 0;
defaultInput = nil;
defaultOutput = nil;
li = [[Listener new] autorelease];
[NSStream getStreamsToHost: host port: 443
inputStream: &defaultInput outputStream: &defaultOutput];
START_SET("NSStream SSL")
if (!SSL_SUPPORTED)
SKIP("NSStream SSL functions not supported\nThe GNU TLS library was not provided when GNUstep-base was configured/built.")
done = NO;
byteCount = 0;
defaultInput = nil;
defaultOutput = nil;
li = [[Listener new] autorelease];
[NSStream getStreamsToHost: host port: 443
inputStream: &defaultInput outputStream: &defaultOutput];
[defaultInput setDelegate: li];
[defaultOutput setDelegate: li];
[defaultInput scheduleInRunLoop: rl forMode: NSDefaultRunLoopMode];
[defaultOutput scheduleInRunLoop: rl forMode: NSDefaultRunLoopMode];
[defaultInput setProperty: NSStreamSocketSecurityLevelNegotiatedSSL
forKey: NSStreamSocketSecurityLevelKey];
[defaultOutput setProperty: NSStreamSocketSecurityLevelNegotiatedSSL
forKey: NSStreamSocketSecurityLevelKey];
[defaultInput open];
[defaultOutput open];
[defaultInput setDelegate: li];
[defaultOutput setDelegate: li];
[defaultInput scheduleInRunLoop: rl forMode: NSDefaultRunLoopMode];
[defaultOutput scheduleInRunLoop: rl forMode: NSDefaultRunLoopMode];
[defaultInput setProperty: NSStreamSocketSecurityLevelNegotiatedSSL
forKey: NSStreamSocketSecurityLevelKey];
[defaultOutput setProperty: NSStreamSocketSecurityLevelNegotiatedSSL
forKey: NSStreamSocketSecurityLevelKey];
[defaultInput open];
[defaultOutput open];
d = [NSDate dateWithTimeIntervalSinceNow: 30];
while (done == NO && [d timeIntervalSinceNow] > 0.0)
{
[rl runMode: NSDefaultRunLoopMode beforeDate: d];
}
d = [NSDate dateWithTimeIntervalSinceNow: 30];
while (done == NO && [d timeIntervalSinceNow] > 0.0)
{
[rl runMode: NSDefaultRunLoopMode beforeDate: d];
}
PASS(byteCount>0, "read www.google.com https");
[defaultInput setDelegate: nil];
[defaultOutput setDelegate: nil];
END_SET("NSStream SSL functions not supported\nThe GNU TLS library was not provided when GNUstep-base was configured/built.")
PASS(byteCount>0, "read www.google.com https");
[defaultInput setDelegate: nil];
[defaultOutput setDelegate: nil];
END_SET("NSStream SSL")
[arp release];
return 0;

View file

@ -34,8 +34,8 @@ int main()
&& ![s isKindOfClass: [NSMutableString class]],
"initWithCharacters:length: creates mutable string for unicode");
TEST_EXCEPTION([[NSString alloc] initWithString: nil];,
NSInvalidArgumentException, YES,
PASS_EXCEPTION([[NSString alloc] initWithString: nil];,
NSInvalidArgumentException,
"NSString -initWithString: does not allow nil argument");
PASS([@"he" getCString: buf maxLength: 2 encoding: NSASCIIStringEncoding]==NO,

View file

@ -31,7 +31,7 @@ static void strCompare (char *s0, char *s1, NSComparisonResult ci,
us0 = nil;
us1 = nil;
TEST_EXCEPTION(cs0 = [NSString stringWithCString:s0];
PASS_RUNS(cs0 = [NSString stringWithCString:s0];
l = [cs0 length];
d = [NSMutableData dataWithLength:(l * 2)];
b = [d mutableBytes];
@ -44,7 +44,6 @@ static void strCompare (char *s0, char *s1, NSComparisonResult ci,
b = [d mutableBytes];
[cs1 getCharacters:b];
us1 = [NSString stringWithCharacters:b length:l];,
nil,NO,
"create strings for compare is ok");
opts = NSCaseInsensitiveSearch;
type = "case insensitive comparison for";
@ -173,7 +172,7 @@ static void strRange(char *s0, char *s1, unsigned int opts,
us0 = nil;
us1 = nil;
TEST_EXCEPTION(cs0 = [NSString stringWithCString:s0];
PASS_RUNS(cs0 = [NSString stringWithCString:s0];
l = [cs0 length];
d = [NSMutableData dataWithLength:(l * 2)];
b = [d mutableBytes];
@ -186,7 +185,7 @@ static void strRange(char *s0, char *s1, unsigned int opts,
b = [d mutableBytes];
[cs1 getCharacters:b];
us1 = [NSString stringWithCharacters:b length:l];,
nil,NO, "create strings for range is ok");
"create strings for range is ok");
res = [cs0 rangeOfString:cs1 options:opts range:range];
PASS(rangesEqual(res,want), "CCString range for '%s' and '%s' is ok",s0,s1);
@ -213,7 +212,7 @@ static void strRangeFromSet(char *s, NSCharacterSet *c, unsigned int o, NSRange
cs1 = nil;
us0 = nil;
us1 = nil;
TEST_EXCEPTION(cs0 = [NSString stringWithCString:s];
PASS_RUNS(cs0 = [NSString stringWithCString:s];
l = [cs0 length];
d = [NSMutableData dataWithLength:(l * 2)];
b = [d mutableBytes];
@ -226,7 +225,7 @@ static void strRangeFromSet(char *s, NSCharacterSet *c, unsigned int o, NSRange
b = [d mutableBytes];
[cs1 getCharacters:b];
us1 = [NSMutableString stringWithCharacters:b length:l];,
nil,NO, "create strings for range");
"create strings for range");
res = [cs0 rangeOfCharacterFromSet:c options:o range:range];
PASS(rangesEqual(res,want), "CString range for '%s' is ok",s);
@ -256,23 +255,23 @@ int main()
{
NSAutoreleasePool *arp = [NSAutoreleasePool new];
TEST_EXCEPTION([NSString stringWithUTF8String: 0],
NSInvalidArgumentException, YES,
PASS_EXCEPTION([NSString stringWithUTF8String: 0],
NSInvalidArgumentException,
"stringWithUTF8String raises for NULL");
TEST_EXCEPTION([NSString stringWithCString: 0
PASS_EXCEPTION([NSString stringWithCString: 0
encoding: NSASCIIStringEncoding],
NSInvalidArgumentException, YES,
NSInvalidArgumentException,
"initWithCString raises for NULL");
TEST_EXCEPTION([@"Hello" substringWithRange:NSMakeRange(6,4)];,
NSRangeException, YES,
PASS_EXCEPTION([@"Hello" substringWithRange:NSMakeRange(6,4)];,
NSRangeException,
"NSString extracting substring with range beyond end of string");
TEST_EXCEPTION([@"Hello" compare: @"Hello"
PASS_EXCEPTION([@"Hello" compare: @"Hello"
options:NSLiteralSearch
range:NSMakeRange(4,3)];,
NSRangeException, YES,
NSRangeException,
"NSString comparison with range beyond end of string");
strCompare("hello", "hello", NSOrderedSame, NSOrderedSame, NSOrderedSame,

View file

@ -51,7 +51,7 @@ int main()
[task terminate];
TEST_EXCEPTION([task launch];, @"NSInvalidArgumentException", YES,
PASS_EXCEPTION([task launch];, @"NSInvalidArgumentException",
"raised exception on failed launch")
[outPipe release];
[task release];

View file

@ -50,7 +50,9 @@ int main()
&& [current isDaylightSavingTime] == NO,
"can set default time zone");
START_SET(NSLOCALE_SUPPORTED)
START_SET("NSLocale")
if (!NSLOCALE_SUPPORTED)
SKIP("NSlocale not supported\nThe ICU library was not available when GNUstep-base was built")
current = [NSTimeZone timeZoneWithName: @"America/Sao_Paulo"];
locale = [[NSLocale alloc] initWithLocaleIdentifier: @"en_GB"];
@ -84,7 +86,7 @@ int main()
== [current daylightSavingTimeOffsetForDate: date],
"Returns correct Daylight Saving offset.")
END_SET("NSLocale features not supported\nThe ICU library was not provided when GNUstep-base was configured/built.")
END_SET("NSLocale")
[arp release]; arp = nil;
return 0;

View file

@ -21,8 +21,8 @@ int main()
TEST_FOR_CLASS(@"NSURLHandle", [NSURLHandle alloc],
"NSURLHandle +alloc returns an NSURLHandle");
TEST_EXCEPTION([DummyHandle cachedHandleForURL: httpURL];,
NSInvalidArgumentException, YES,
PASS_EXCEPTION([DummyHandle cachedHandleForURL: httpURL];,
NSInvalidArgumentException,
"NSURLHandle subclass must implement +cachedHandleForURL:");
cls = [NSURLHandle URLHandleClassForURL: httpURL];

View file

@ -15,7 +15,7 @@ int main()
"NSURLProtocol +alloc returns an NSURLProtocol");
mutable = [[NSMutableURLRequest requestWithURL: httpURL] retain];
TEST_EXCEPTION([NSURLProtocol canInitWithRequest: mutable], nil, YES,
PASS_EXCEPTION([NSURLProtocol canInitWithRequest: mutable], nil,
"NSURLProtocol +canInitWithRequest throws an exeception (subclasses should be used)");
canon = [NSURLProtocol canonicalRequestForRequest: mutable];

View file

@ -302,7 +302,7 @@ int main()
bar = [[NSObject alloc] init];
rc = [bar retainCount];
TEST_EXCEPTION([um registerUndoWithTarget:obj selector:@selector(setFooReg:) object:nil], nil, YES, "can't register undo outside any group");
PASS_EXCEPTION([um registerUndoWithTarget:obj selector:@selector(setFooReg:) object:nil], nil, "can't register undo outside any group");
[um beginUndoGrouping];
[um registerUndoWithTarget:obj selector:@selector(setFooReg:) object:bar];