mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-10 16:20:42 +00:00
fix leaks in testcases
This commit is contained in:
parent
6f7a4d74c2
commit
b46439ba15
7 changed files with 15 additions and 10 deletions
|
@ -1462,7 +1462,7 @@ ObserveAllProperties()
|
||||||
START_SET("ObserveAllProperties");
|
START_SET("ObserveAllProperties");
|
||||||
FLAKY_ON_GCC_START
|
FLAKY_ON_GCC_START
|
||||||
|
|
||||||
TestKVOObject *observed = [[TestKVOObject alloc] init];
|
TestKVOObject *observed = AUTORELEASE([[TestKVOObject alloc] init]);
|
||||||
TestKVOObserver *observer = [[[TestKVOObserver alloc] init] autorelease];
|
TestKVOObserver *observer = [[[TestKVOObserver alloc] init] autorelease];
|
||||||
|
|
||||||
[observed addObserver:observer
|
[observed addObserver:observer
|
||||||
|
@ -2102,8 +2102,8 @@ SetValueForKeyPropertyNotification()
|
||||||
// not get two notifications for the same change.
|
// not get two notifications for the same change.
|
||||||
START_SET("SetValueForKeyPropertyNotification");
|
START_SET("SetValueForKeyPropertyNotification");
|
||||||
|
|
||||||
TestKVOObject *observed = [TestKVOObject new];
|
TestKVOObject *observed = AUTORELEASE([TestKVOObject new]);
|
||||||
TestKVOObserver *observer = [TestKVOObserver new];
|
TestKVOObserver *observer = AUTORELEASE([TestKVOObserver new]);
|
||||||
|
|
||||||
[observed addObserver:observer
|
[observed addObserver:observer
|
||||||
forKeyPath:@"basicObjectProperty"
|
forKeyPath:@"basicObjectProperty"
|
||||||
|
|
|
@ -11,14 +11,14 @@ int main()
|
||||||
val2 = @"A Goodbye";
|
val2 = @"A Goodbye";
|
||||||
val3 = @"Testing all strings";
|
val3 = @"Testing all strings";
|
||||||
|
|
||||||
vals1 = [[NSMutableArray arrayWithObject: val1] retain];
|
vals1 = [NSMutableArray arrayWithObject: val1];
|
||||||
[vals1 addObject: val2];
|
[vals1 addObject: val2];
|
||||||
vals2 = AUTORELEASE([vals1 mutableCopy]);
|
vals2 = AUTORELEASE([vals1 mutableCopy]);
|
||||||
[vals2 addObject: val2];
|
[vals2 addObject: val2];
|
||||||
vals3 = AUTORELEASE([vals2 mutableCopy]);
|
vals3 = AUTORELEASE([vals2 mutableCopy]);
|
||||||
[vals3 addObject: val3];
|
[vals3 addObject: val3];
|
||||||
|
|
||||||
obj = [NSMutableArray new];
|
obj = [NSMutableArray array];
|
||||||
arr = obj;
|
arr = obj;
|
||||||
PASS(obj != nil && [obj isKindOfClass:[NSMutableArray class]] && [obj count] == 0,
|
PASS(obj != nil && [obj isKindOfClass:[NSMutableArray class]] && [obj count] == 0,
|
||||||
"-count returns zero for an empty array");
|
"-count returns zero for an empty array");
|
||||||
|
|
|
@ -97,7 +97,7 @@ int main()
|
||||||
[obj count] == 0,
|
[obj count] == 0,
|
||||||
"-description gives us a text property-list");
|
"-description gives us a text property-list");
|
||||||
|
|
||||||
dict = [[NSMutableDictionary dictionaryWithObjects:vals1 forKeys:keys1] retain];
|
dict = [NSMutableDictionary dictionaryWithObjects:vals1 forKeys:keys1];
|
||||||
PASS(dict != nil &&
|
PASS(dict != nil &&
|
||||||
[dict isKindOfClass:[NSMutableDictionary class]] &&
|
[dict isKindOfClass:[NSMutableDictionary class]] &&
|
||||||
[dict count] == 2,
|
[dict count] == 2,
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||||
NSMutableSet *testObj = [NSMutableSet new];
|
NSMutableSet *testObj = [NSMutableSet set];
|
||||||
test_NSObject(@"NSMutableSet", [NSArray arrayWithObject:testObj]);
|
test_NSObject(@"NSMutableSet", [NSArray arrayWithObject:testObj]);
|
||||||
test_NSCoding([NSArray arrayWithObject:testObj]);
|
test_NSCoding([NSArray arrayWithObject:testObj]);
|
||||||
test_NSCopying(@"NSSet",@"NSMutableSet",
|
test_NSCopying(@"NSSet",@"NSMutableSet",
|
||||||
|
|
|
@ -141,6 +141,7 @@ int main()
|
||||||
{
|
{
|
||||||
obj = [[MyOperation alloc] initWithValue: i];
|
obj = [[MyOperation alloc] initWithValue: i];
|
||||||
[a addObject: obj];
|
[a addObject: obj];
|
||||||
|
RELEASE(obj);
|
||||||
[q addOperation: obj];
|
[q addOperation: obj];
|
||||||
}
|
}
|
||||||
[q waitUntilAllOperationsAreFinished];
|
[q waitUntilAllOperationsAreFinished];
|
||||||
|
@ -157,7 +158,7 @@ int main()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PASS((ran == want), "many operations, all were performed")
|
PASS((ran == want), "many operations, all were performed")
|
||||||
PASS((f - s) < 0.1, "many operations, duration was reasonably small")
|
PASS((f - s) < 0.5, "concurrent test duration")
|
||||||
|
|
||||||
// multiple concurrent operations
|
// multiple concurrent operations
|
||||||
[q setMaxConcurrentOperationCount: 5];
|
[q setMaxConcurrentOperationCount: 5];
|
||||||
|
@ -178,6 +179,7 @@ int main()
|
||||||
PASS(([obj getCalculation] == (2*i)), "operation was performed");
|
PASS(([obj getCalculation] == (2*i)), "operation was performed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RELEASE(q);
|
||||||
END_SET("concurrent operations")
|
END_SET("concurrent operations")
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ int main()
|
||||||
[q waitUntilAllOperationsAreFinished];
|
[q waitUntilAllOperationsAreFinished];
|
||||||
f = [NSDate timeIntervalSinceReferenceDate];
|
f = [NSDate timeIntervalSinceReferenceDate];
|
||||||
PASS([o counter] == want, "expected number of operations")
|
PASS([o counter] == want, "expected number of operations")
|
||||||
PASS((f - s) < 0.1, "duration was reasonable")
|
PASS((f - s) < 0.5, "sequential test duration")
|
||||||
|
|
||||||
[o reset];
|
[o reset];
|
||||||
[q addOperationWithTarget: o
|
[q addOperationWithTarget: o
|
||||||
|
|
|
@ -224,14 +224,17 @@ int main()
|
||||||
|
|
||||||
PASS(([NSOperationQueue currentQueue] == [NSOperationQueue mainQueue]), "current queue outside -main is main queue");
|
PASS(([NSOperationQueue currentQueue] == [NSOperationQueue mainQueue]), "current queue outside -main is main queue");
|
||||||
PASS(([NSOperationQueue mainQueue] != nil), "main queue is not nil");
|
PASS(([NSOperationQueue mainQueue] != nil), "main queue is not nil");
|
||||||
|
|
||||||
obj = [OpFlag new];
|
obj = [OpFlag new];
|
||||||
[q addOperation: obj];
|
[q addOperation: obj];
|
||||||
[q waitUntilAllOperationsAreFinished];
|
[q waitUntilAllOperationsAreFinished];
|
||||||
PASS(([obj isFinished] == YES), "main queue runs an operation");
|
PASS(([obj isFinished] == YES), "main queue runs an operation");
|
||||||
PASS(([obj thread] != [NSThread currentThread]),
|
PASS(([obj thread] != [NSThread currentThread]),
|
||||||
"operation ran in other thread");
|
"operation ran in other thread");
|
||||||
|
RELEASE(obj);
|
||||||
|
|
||||||
[q setSuspended: YES];
|
[q setSuspended: YES];
|
||||||
|
|
||||||
obj = [OpFlag new];
|
obj = [OpFlag new];
|
||||||
[q addOperation: obj];
|
[q addOperation: obj];
|
||||||
[NSThread sleepForTimeInterval: 0.1];
|
[NSThread sleepForTimeInterval: 0.1];
|
||||||
|
@ -239,7 +242,7 @@ int main()
|
||||||
[q setSuspended: NO];
|
[q setSuspended: NO];
|
||||||
[q waitUntilAllOperationsAreFinished];
|
[q waitUntilAllOperationsAreFinished];
|
||||||
PASS(([obj isFinished] == YES), "unsuspend works");
|
PASS(([obj isFinished] == YES), "unsuspend works");
|
||||||
[obj release];
|
RELEASE(obj);
|
||||||
|
|
||||||
[q setMaxConcurrentOperationCount: 0];
|
[q setMaxConcurrentOperationCount: 0];
|
||||||
obj = [OpFlag new];
|
obj = [OpFlag new];
|
||||||
|
|
Loading…
Reference in a new issue