mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Fix leaks in testcases
This commit is contained in:
parent
6f0765cbb3
commit
d3603a8e24
6 changed files with 30 additions and 17 deletions
|
@ -180,7 +180,7 @@ main(int argc, char *argv[])
|
|||
{
|
||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
id obj = nil;
|
||||
id rem = [TypeTester new];
|
||||
id rem = AUTORELEASE([TypeTester new]);
|
||||
GSFinePoint f0;
|
||||
GSFinePoint f1;
|
||||
NSPoint p0;
|
||||
|
|
|
@ -21,7 +21,7 @@ int main()
|
|||
{
|
||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
NSString *customMode = @"CustomRunLoopMode";
|
||||
MyClass *dummy = [MyClass new];
|
||||
MyClass *dummy = AUTORELEASE([MyClass new]);
|
||||
NSMethodSignature *sig;
|
||||
NSInvocation *inv;
|
||||
NSTimer *dly;
|
||||
|
|
|
@ -33,7 +33,8 @@ int main()
|
|||
date = [NSDate dateWithTimeIntervalSinceNow: delay];
|
||||
[run runUntilDate: date];
|
||||
PASS([str isEqual: @"foo"],
|
||||
"-performSelector:target:argument:order:modes: works for one performer");
|
||||
"-performSelector:target:argument:order:modes: works for one performer")
|
||||
DESTROY(str);
|
||||
|
||||
str = [[NSMutableString alloc] init];
|
||||
[run performSelector: @selector(appendString:)
|
||||
|
@ -47,7 +48,8 @@ int main()
|
|||
if ([str isEqual: @""])
|
||||
SKIP("it looks like stdin is redirected")
|
||||
PASS([str isEqual: @"foo"],
|
||||
"-performSelector:target:argument:order:modes: only sends the message once");
|
||||
"-performSelector:target:argument:order:modes: only sends the message once")
|
||||
DESTROY(str);
|
||||
|
||||
str = [[NSMutableString alloc] init];
|
||||
[run performSelector: @selector(appendString:)
|
||||
|
@ -63,7 +65,8 @@ int main()
|
|||
date = [NSDate dateWithTimeIntervalSinceNow: delay];
|
||||
[run runUntilDate: date];
|
||||
PASS([str isEqual: @"foobar"],
|
||||
"-performSelector:target:argument:order:modes: orders performers correctly");
|
||||
"-performSelector:target:argument:order:modes: orders performers correctly")
|
||||
DESTROY(str);
|
||||
|
||||
str = [[NSMutableString alloc] init];
|
||||
[run performSelector: @selector(appendString:)
|
||||
|
@ -87,7 +90,8 @@ int main()
|
|||
date = [NSDate dateWithTimeIntervalSinceNow: delay];
|
||||
[run runUntilDate: date];
|
||||
PASS([str isEqual: @"foozot"],
|
||||
"-cancelPerformSelector:target:argument: works");
|
||||
"-cancelPerformSelector:target:argument: works")
|
||||
DESTROY(str);
|
||||
|
||||
str = [[NSMutableString alloc] init];
|
||||
[run performSelector: @selector(appendString:)
|
||||
|
@ -103,7 +107,9 @@ int main()
|
|||
[run cancelPerformSelectorsWithTarget: str];
|
||||
date = [NSDate dateWithTimeIntervalSinceNow: delay];
|
||||
[run runUntilDate: date];
|
||||
PASS([str isEqualToString: @""], "-cancelPerformSelectorsWithTarget: works %s",[str UTF8String]);
|
||||
PASS([str isEqualToString: @""],
|
||||
"-cancelPerformSelectorsWithTarget: works %s",[str UTF8String])
|
||||
DESTROY(str);
|
||||
|
||||
[fh closeFile];
|
||||
[fh release];
|
||||
|
|
|
@ -31,11 +31,11 @@ int main()
|
|||
#endif
|
||||
|
||||
info = [NSProcessInfo processInfo];
|
||||
env = [[info environment] mutableCopy];
|
||||
env = [info environment];
|
||||
yes = YES;
|
||||
|
||||
PASS(info != nil && [info isKindOfClass: [NSProcessInfo class]]
|
||||
&& env != nil && [env isKindOfClass: [NSMutableDictionary class]]
|
||||
&& env != nil && [env isKindOfClass: [NSDictionary class]]
|
||||
&& yes == YES,
|
||||
"We can build some objects for task tests");
|
||||
|
||||
|
@ -52,7 +52,7 @@ int main()
|
|||
task = [NSTask launchedTaskWithLaunchPath: pth1
|
||||
arguments: [NSArray array]];
|
||||
[task waitUntilExit];
|
||||
PASS(YES, "launchedTaskWithLaunchPath:arguments: works");
|
||||
PASS(YES, "launchedTaskWithLaunchPath:arguments: works")
|
||||
|
||||
task = [NSTask new];
|
||||
args = [NSArray arrayWithObjects: @"xxx", @"yyy", nil];
|
||||
|
@ -62,7 +62,8 @@ int main()
|
|||
[task launch];
|
||||
[task waitUntilExit];
|
||||
PASS([task terminationReason] == NSTaskTerminationReasonExit,
|
||||
"termination reason for normal exit works");
|
||||
"termination reason for normal exit works")
|
||||
DESTROY(task);
|
||||
|
||||
[arp release]; arp = nil;
|
||||
return 0;
|
||||
|
|
|
@ -42,7 +42,7 @@ int main()
|
|||
helpers = [helpers stringByAppendingPathComponent: @"obj"];
|
||||
|
||||
task = [[NSTask alloc] init];
|
||||
outPipe = [[NSPipe pipe] retain];
|
||||
outPipe = [NSPipe pipe];
|
||||
[task setLaunchPath: [helpers stringByAppendingPathComponent: testcat]];
|
||||
[task setArguments: [NSArray arrayWithObjects: nil]];
|
||||
[task setStandardOutput: outPipe];
|
||||
|
@ -55,9 +55,10 @@ int main()
|
|||
NSLog(@"Data was %*.*s",
|
||||
(int)[data length], (int)[data length], (const char*)[data bytes]);
|
||||
[task terminate];
|
||||
DESTROY(task);
|
||||
|
||||
task = [[NSTask alloc] init];
|
||||
outPipe = [[NSPipe pipe] retain];
|
||||
outPipe = [NSPipe pipe];
|
||||
[task setLaunchPath: [helpers stringByAppendingPathComponent: testecho]];
|
||||
[task setArguments: [NSArray arrayWithObjects: @"Hello", @"there", nil]];
|
||||
[task setStandardOutput: outPipe];
|
||||
|
@ -73,8 +74,7 @@ int main()
|
|||
|
||||
PASS_EXCEPTION([task launch];, @"NSInvalidArgumentException",
|
||||
"raised exception on failed launch")
|
||||
[outPipe release];
|
||||
[task release];
|
||||
DESTROY(task);
|
||||
|
||||
task = [[NSTask alloc] init];
|
||||
[task setLaunchPath: [helpers stringByAppendingPathComponent: testcat]];
|
||||
|
@ -84,7 +84,7 @@ int main()
|
|||
PASS(error != nil, "error is returned")
|
||||
PASS([error domain] == NSCocoaErrorDomain, "error has expected domain")
|
||||
PASS([error code] == NSFileNoSuchFileError, "error has expected code")
|
||||
[task release];
|
||||
DESTROY(task);
|
||||
|
||||
#if !defined(_WIN32)
|
||||
task = [[NSTask alloc] init];
|
||||
|
@ -96,7 +96,7 @@ int main()
|
|||
[task launch];
|
||||
[task waitUntilExit];
|
||||
PASS([task terminationStatus] == 0, "subtask changes process group");
|
||||
[task release];
|
||||
DESTROY(task);
|
||||
#endif
|
||||
|
||||
[arp release];
|
||||
|
|
|
@ -18,6 +18,12 @@
|
|||
|
||||
static BOOL taskTerminationNotificationReceived;
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
DESTROY(path);
|
||||
DEALLOC
|
||||
}
|
||||
|
||||
- (void) setLaunchPath: (NSString*)s
|
||||
{
|
||||
ASSIGNCOPY(path, s);
|
||||
|
|
Loading…
Reference in a new issue