I have to get stuck on stoopid today because I spent more than an hour trying to figure out how to get the args variables to work in this iPhone project I'm working on. Can someone help me get the green bar below unit test? Where am I mistaken?
#import <SenTestingKit/SenTestingKit.h> @interface VAArgsTest : SenTestCase { } @end NSString* vaArgsAppend(NSString *first, ...) { NSMutableString *list = [[NSMutableString alloc] initWithString:first]; id eachArg; va_list argumentList; va_start(argumentList, first); while(eachArg = va_arg(argumentList, id)) { if(eachArg)[list appendString:(NSString*)eachArg]; } va_end(argumentList); return [list autorelease]; } @implementation VAArgsTest -(void) testCallVaArgsAppend { NSString *result = vaArgsAppend(@"one ", "two ", @"three"); STAssertEqualObjects(result, @"one two three", @"Expected appended string."); } @end
Cliff source share