mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 00:41:02 +00:00
More leaks fixed
This commit is contained in:
parent
aedd13dc94
commit
c7f0c27dd7
8 changed files with 47 additions and 40 deletions
|
@ -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")
|
||||
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -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)");
|
||||
|
|
|
@ -36,20 +36,22 @@
|
|||
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -12,13 +12,13 @@ static BOOL blockDidRun = NO;
|
|||
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue