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");
|
||||
FLAKY_ON_GCC_START
|
||||
|
||||
TestKVOObject *observed = [[TestKVOObject alloc] init];
|
||||
TestKVOObject *observed = AUTORELEASE([[TestKVOObject alloc] init]);
|
||||
TestKVOObserver *observer = [[[TestKVOObserver alloc] init] autorelease];
|
||||
|
||||
[observed addObserver:observer
|
||||
|
@ -2102,8 +2102,8 @@ SetValueForKeyPropertyNotification()
|
|||
// not get two notifications for the same change.
|
||||
START_SET("SetValueForKeyPropertyNotification");
|
||||
|
||||
TestKVOObject *observed = [TestKVOObject new];
|
||||
TestKVOObserver *observer = [TestKVOObserver new];
|
||||
TestKVOObject *observed = AUTORELEASE([TestKVOObject new]);
|
||||
TestKVOObserver *observer = AUTORELEASE([TestKVOObserver new]);
|
||||
|
||||
[observed addObserver:observer
|
||||
forKeyPath:@"basicObjectProperty"
|
||||
|
|
|
@ -11,14 +11,14 @@ int main()
|
|||
val2 = @"A Goodbye";
|
||||
val3 = @"Testing all strings";
|
||||
|
||||
vals1 = [[NSMutableArray arrayWithObject: val1] retain];
|
||||
vals1 = [NSMutableArray arrayWithObject: val1];
|
||||
[vals1 addObject: val2];
|
||||
vals2 = AUTORELEASE([vals1 mutableCopy]);
|
||||
[vals2 addObject: val2];
|
||||
vals3 = AUTORELEASE([vals2 mutableCopy]);
|
||||
[vals3 addObject: val3];
|
||||
|
||||
obj = [NSMutableArray new];
|
||||
obj = [NSMutableArray array];
|
||||
arr = obj;
|
||||
PASS(obj != nil && [obj isKindOfClass:[NSMutableArray class]] && [obj count] == 0,
|
||||
"-count returns zero for an empty array");
|
||||
|
|
|
@ -97,7 +97,7 @@ int main()
|
|||
[obj count] == 0,
|
||||
"-description gives us a text property-list");
|
||||
|
||||
dict = [[NSMutableDictionary dictionaryWithObjects:vals1 forKeys:keys1] retain];
|
||||
dict = [NSMutableDictionary dictionaryWithObjects:vals1 forKeys:keys1];
|
||||
PASS(dict != nil &&
|
||||
[dict isKindOfClass:[NSMutableDictionary class]] &&
|
||||
[dict count] == 2,
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
int main()
|
||||
{
|
||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
NSMutableSet *testObj = [NSMutableSet new];
|
||||
NSMutableSet *testObj = [NSMutableSet set];
|
||||
test_NSObject(@"NSMutableSet", [NSArray arrayWithObject:testObj]);
|
||||
test_NSCoding([NSArray arrayWithObject:testObj]);
|
||||
test_NSCopying(@"NSSet",@"NSMutableSet",
|
||||
|
|
|
@ -141,6 +141,7 @@ int main()
|
|||
{
|
||||
obj = [[MyOperation alloc] initWithValue: i];
|
||||
[a addObject: obj];
|
||||
RELEASE(obj);
|
||||
[q addOperation: obj];
|
||||
}
|
||||
[q waitUntilAllOperationsAreFinished];
|
||||
|
@ -157,7 +158,7 @@ int main()
|
|||
}
|
||||
}
|
||||
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
|
||||
[q setMaxConcurrentOperationCount: 5];
|
||||
|
@ -178,6 +179,7 @@ int main()
|
|||
PASS(([obj getCalculation] == (2*i)), "operation was performed");
|
||||
}
|
||||
|
||||
RELEASE(q);
|
||||
END_SET("concurrent operations")
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ int main()
|
|||
[q waitUntilAllOperationsAreFinished];
|
||||
f = [NSDate timeIntervalSinceReferenceDate];
|
||||
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];
|
||||
[q addOperationWithTarget: o
|
||||
|
|
|
@ -224,14 +224,17 @@ int main()
|
|||
|
||||
PASS(([NSOperationQueue currentQueue] == [NSOperationQueue mainQueue]), "current queue outside -main is main queue");
|
||||
PASS(([NSOperationQueue mainQueue] != nil), "main queue is not nil");
|
||||
|
||||
obj = [OpFlag new];
|
||||
[q addOperation: obj];
|
||||
[q waitUntilAllOperationsAreFinished];
|
||||
PASS(([obj isFinished] == YES), "main queue runs an operation");
|
||||
PASS(([obj thread] != [NSThread currentThread]),
|
||||
"operation ran in other thread");
|
||||
RELEASE(obj);
|
||||
|
||||
[q setSuspended: YES];
|
||||
|
||||
obj = [OpFlag new];
|
||||
[q addOperation: obj];
|
||||
[NSThread sleepForTimeInterval: 0.1];
|
||||
|
@ -239,7 +242,7 @@ int main()
|
|||
[q setSuspended: NO];
|
||||
[q waitUntilAllOperationsAreFinished];
|
||||
PASS(([obj isFinished] == YES), "unsuspend works");
|
||||
[obj release];
|
||||
RELEASE(obj);
|
||||
|
||||
[q setMaxConcurrentOperationCount: 0];
|
||||
obj = [OpFlag new];
|
||||
|
|
Loading…
Reference in a new issue