diff --git a/Tests/base/NSNumber/test00.m b/Tests/base/NSNumber/test00.m index 097e22b64c..9794ef2c1e 100644 --- a/Tests/base/NSNumber/test00.m +++ b/Tests/base/NSNumber/test00.m @@ -132,9 +132,9 @@ int main() PASS(200 == [val1 unsignedShortValue], "NSDecimalNumber unsignedShortValue works") - val1 = [[NSNumber alloc] initWithLongLong: LLONG_MIN]; - val2 = [[NSNumber alloc] initWithUnsignedLongLong: - (unsigned long long)LLONG_MAX + 1]; + val1 = AUTORELEASE([[NSNumber alloc] initWithLongLong: LLONG_MIN]); + val2 = AUTORELEASE([[NSNumber alloc] initWithUnsignedLongLong: + (unsigned long long)LLONG_MAX + 1]); PASS([val1 compare: val2] == NSOrderedAscending, "comparison of min signed with max unsigned works") diff --git a/Tests/base/NSNumberFormatter/basic.m b/Tests/base/NSNumberFormatter/basic.m index 7858b7557b..8b2082eebd 100644 --- a/Tests/base/NSNumberFormatter/basic.m +++ b/Tests/base/NSNumberFormatter/basic.m @@ -13,7 +13,7 @@ int main() [NSNumberFormatter setDefaultFormatterBehavior: NSNumberFormatterBehavior10_0]; - TEST_FOR_CLASS(@"NSNumberFormatter",[NSNumberFormatter alloc], + TEST_FOR_CLASS(@"NSNumberFormatter", AUTORELEASE([NSNumberFormatter alloc]), "+[NSNumberFormatter alloc] returns a NSNumberFormatter"); fmt = [[[NSNumberFormatter alloc] init] autorelease]; diff --git a/Tests/base/NSObject/test01.m b/Tests/base/NSObject/test01.m index bb89461329..0e89de0b27 100644 --- a/Tests/base/NSObject/test01.m +++ b/Tests/base/NSObject/test01.m @@ -48,7 +48,7 @@ int main() ![[[NSArray new] autorelease] isClass]), "-isClass returns NO on an instance"); - evilObject = [MyEvilClass new]; + evilObject = AUTORELEASE([MyEvilClass new]); [evilObject setInfo:1]; PASS(![evilObject isClass], "-isClass returns NO on an instance (special test for broken libobjc)"); diff --git a/Tests/base/NSObject/test02.m b/Tests/base/NSObject/test02.m index 943cf4319a..ff99fa097b 100644 --- a/Tests/base/NSObject/test02.m +++ b/Tests/base/NSObject/test02.m @@ -36,20 +36,22 @@ - (void) doNothingCategory int main() { - NSAutoreleasePool *arp = [NSAutoreleasePool new]; + ENTER_POOL + id instance = AUTORELEASE([NicolaTest new]); + PASS([NicolaTest conformsToProtocol:@protocol(DoingNothing)], "+conformsToProtocol returns YES on an implemented protocol"); PASS([NicolaTest conformsToProtocol:@protocol(DoingNothingCategory)], "+conformsToProtocol returns YES on a protocol implemented in a category"); PASS(![NicolaTest conformsToProtocol:@protocol(NSCoding)], "+conformsToProtocol returns NO on an unimplemented protocol"); - PASS([[NicolaTest new] conformsToProtocol:@protocol(DoingNothing)], + PASS([instance conformsToProtocol:@protocol(DoingNothing)], "-conformsToProtocol returns YES on an implemented protocol"); - PASS([[NicolaTest new] conformsToProtocol:@protocol(DoingNothingCategory)], + PASS([instance conformsToProtocol:@protocol(DoingNothingCategory)], "-conformsToProtocol returns YES on a protocol implemented in a category"); - PASS(![[NicolaTest new] conformsToProtocol:@protocol(NSCoding)], + PASS(![instance conformsToProtocol:@protocol(NSCoding)], "-conformsToProtocol returns NO on an unimplemented protocol"); - [arp release]; arp = nil; + LEAVE_POOL return 0; } diff --git a/Tests/base/NSOperation/basic.m b/Tests/base/NSOperation/basic.m index 869d845d71..e8c84ba2cf 100644 --- a/Tests/base/NSOperation/basic.m +++ b/Tests/base/NSOperation/basic.m @@ -12,13 +12,13 @@ int main() { + ENTER_POOL id obj1; id obj2; - NSMutableArray *testObjs = [[NSMutableArray alloc] init]; - NSAutoreleasePool *arp = [NSAutoreleasePool new]; + NSMutableArray *testObjs = [NSMutableArray array]; test_alloc(@"NSOperation"); - obj1 = [NSOperation new]; + obj1 = AUTORELEASE([NSOperation new]); PASS((obj1 != nil), "can create an operation"); [testObjs addObject: obj1]; test_NSObject(@"NSOperation", testObjs); @@ -36,7 +36,7 @@ int main() PASS(([obj1 queuePriority] == NSOperationQueuePriorityVeryHigh), "operation has very high priority"); - obj2 = [NSOperation new]; + obj2 = AUTORELEASE([NSOperation new]); [obj2 addDependency: obj1]; PASS(([[obj2 dependencies] isEqual: testObjs]), "operation has added dependency"); @@ -53,8 +53,7 @@ int main() "dependency removal works"); PASS(([obj2 isReady] == YES), "operation without dependency is ready"); - [obj1 release]; - obj1 = [NSOperation new]; + obj1 = AUTORELEASE([NSOperation new]); [testObjs replaceObjectAtIndex: 0 withObject: obj1]; [obj2 addDependency: obj1]; # if __has_feature(blocks) @@ -72,8 +71,7 @@ int main() PASS(([obj2 isReady] == YES), "operation with finished dependency is ready"); [obj2 removeDependency: obj1]; - [obj1 release]; - obj1 = [NSOperation new]; + obj1 = AUTORELEASE([NSOperation new]); [testObjs replaceObjectAtIndex: 0 withObject: obj1]; [obj2 addDependency: obj1]; [obj2 cancel]; @@ -92,7 +90,7 @@ int main() test_alloc(@"NSOperationQueue"); - obj1 = [NSOperationQueue new]; + obj1 = AUTORELEASE([NSOperationQueue new]); PASS((obj1 != nil), "can create an operation queue"); [testObjs removeAllObjects]; [testObjs addObject: obj1]; @@ -121,11 +119,11 @@ int main() NSInvalidArgumentException, "NSOperationQueue cannot be given negative count"); - obj2 = [NSOperation new]; + obj2 = AUTORELEASE([NSOperation new]); [obj1 addOperation: obj2]; [NSThread sleepForTimeInterval: 1.0]; PASS(([obj2 isFinished] == YES), "queue ran operation"); - [arp release]; arp = nil; + LEAVE_POOL return 0; } diff --git a/Tests/base/NSOrderedSet/basic.m b/Tests/base/NSOrderedSet/basic.m index 5351641f8b..3fa4e979a0 100644 --- a/Tests/base/NSOrderedSet/basic.m +++ b/Tests/base/NSOrderedSet/basic.m @@ -120,7 +120,7 @@ int main() NSOrderedSet *testObj, *testObj2; NSMutableOrderedSet *mutableTest1, *mutableTest2; - NSMutableArray *testObjs = [NSMutableArray new]; + NSMutableArray *testObjs = [NSMutableArray array]; NSData *data = [stringData dataUsingEncoding: NSUTF8StringEncoding]; NSMutableSet *testSet; diff --git a/Tests/base/NSPersonNameComponentsFormatter/basic.m b/Tests/base/NSPersonNameComponentsFormatter/basic.m index d48703b1cc..102cd1a12d 100644 --- a/Tests/base/NSPersonNameComponentsFormatter/basic.m +++ b/Tests/base/NSPersonNameComponentsFormatter/basic.m @@ -6,16 +6,21 @@ int main() { START_SET("NSPersonNameComponentsFormatter base"); - NSPersonNameComponents *pnc = [[NSPersonNameComponents alloc] init]; + NSPersonNameComponents *pnc; + NSPersonNameComponents *pnc2; + NSPersonNameComponentsFormatter *fmt; + + pnc = AUTORELEASE([[NSPersonNameComponents alloc] init]); [pnc setGivenName: @"Gregory"]; [pnc setMiddleName: @"John"]; [pnc setFamilyName: @"Casamento"]; [pnc setNameSuffix: @"PhD"]; [pnc setNamePrefix: @"Dr."]; - NSPersonNameComponentsFormatter *fmt = [[NSPersonNameComponentsFormatter alloc] init]; - NSPersonNameComponents *pnc2 = [fmt personNameComponentsFromString: - @"Dr. Gregory John Casamento PhD"]; + fmt = AUTORELEASE([[NSPersonNameComponentsFormatter alloc] init]); + pnc2 = [fmt personNameComponentsFromString: + @"Dr. Gregory John Casamento PhD"]; + PASS([[pnc givenName] isEqualToString: [pnc2 givenName]], "First name matches"); PASS([[pnc middleName] isEqualToString: @@ -27,7 +32,7 @@ int main() PASS([[pnc namePrefix] isEqualToString: [pnc2 namePrefix]], "Prefix name matches"); - fmt = [[NSPersonNameComponentsFormatter alloc] init]; + fmt = AUTORELEASE([[NSPersonNameComponentsFormatter alloc] init]); pnc2 = [fmt personNameComponentsFromString: @"Gregory John Casamento PhD"]; PASS([[pnc givenName] isEqualToString: @@ -39,7 +44,7 @@ int main() PASS([[pnc nameSuffix] isEqualToString: [pnc2 nameSuffix]], "Suffix name matches"); - fmt = [[NSPersonNameComponentsFormatter alloc] init]; + fmt = AUTORELEASE([[NSPersonNameComponentsFormatter alloc] init]); pnc2 = [fmt personNameComponentsFromString: @"Gregory John Casamento"]; PASS([[pnc givenName] isEqualToString: diff --git a/Tests/base/NSPointerArray/create.m b/Tests/base/NSPointerArray/create.m index 14e8acd4db..5af2c0b7b8 100644 --- a/Tests/base/NSPointerArray/create.m +++ b/Tests/base/NSPointerArray/create.m @@ -4,11 +4,9 @@ int main() { - NSAutoreleasePool *arp = [NSAutoreleasePool new]; - NSMutableString *ms; + ENTER_POOL NSString *val1, *val2, *val3; - NSPointerArray *obj, *old; - NSUInteger rc; + NSPointerArray *obj; id vals[3]; val1 = @"Hello"; @@ -19,9 +17,9 @@ int main() vals[1] = val2; vals[2] = val3; - obj = [[NSPointerArray new] autorelease]; + obj = AUTORELEASE([NSPointerArray new]); PASS(obj != nil - && [obj isKindOfClass:[NSPointerArray class]] + && [obj isKindOfClass: [NSPointerArray class]] && [obj count] == 0, "+new creates an empty pointer array"); @@ -36,13 +34,17 @@ int main() PASS([obj count] == 5 && [obj pointerAtIndex: 2] == (void*)vals[0], "+insertPointer:atIndex: works"); - obj = [NSPointerArray pointerArrayWithWeakObjects]; - ms = [@"hello" mutableCopy]; - rc = [ms retainCount]; - [obj addPointer: ms]; - PASS(rc == [ms retainCount], "array with weak references doesn't retain"); + LEAVE_POOL + + ENTER_POOL + NSPointerArray *pa = [NSPointerArray weakObjectsPointerArray]; + NSMutableString *ms = AUTORELEASE([@"hello" mutableCopy]); + NSUInteger rc = [ms retainCount]; + + [pa addPointer: ms]; + PASS(rc == [ms retainCount], "array with weak references doesn't retain") + LEAVE_POOL - [arp release]; arp = nil; return 0; }