From 135be32fd14474885986da0709a4e9e2b77841d5 Mon Sep 17 00:00:00 2001 From: "gtm.daemon" Date: Mon, 22 Jul 2013 20:30:08 +0000 Subject: Fix up some assertions so that they don't run into issues with format strings not being constants. DELTA=32 (18 added, 0 deleted, 14 changed) --- UnitTesting/GTMSenTestCase.h | 44 +++++++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 13 deletions(-) (limited to 'UnitTesting') diff --git a/UnitTesting/GTMSenTestCase.h b/UnitTesting/GTMSenTestCase.h index 744550f..023a64a 100644 --- a/UnitTesting/GTMSenTestCase.h +++ b/UnitTesting/GTMSenTestCase.h @@ -873,20 +873,26 @@ do { \ continue; \ } \ @catch (id anException) { \ - NSString *_descrip = STComposeString(@"(Expected exception: %@) %@", NSStringFromClass([specificException class]), description); \ + NSString *_descrip = STComposeString( \ + @"(Expected exception: %@) ", \ + NSStringFromClass([specificException class])); \ + _descrip = [_descrip stringByAppendingFormat:description, ##__VA_ARGS__]; \ [self failWithException:[NSException failureInRaise:[NSString stringWithUTF8String:#expr] \ exception:anException \ inFile:[NSString stringWithUTF8String:__FILE__] \ atLine:__LINE__ \ - withDescription:@"%@", STComposeString(_descrip, ##__VA_ARGS__)]]; \ - continue; \ + withDescription:@"%@", _descrip]]; \ + continue; \ } \ - NSString *_descrip = STComposeString(@"(Expected exception: %@) %@", NSStringFromClass([specificException class]), description); \ + NSString *_descrip = STComposeString( \ + @"(Expected exception: %@) ", \ + NSStringFromClass([specificException class])); \ + _descrip = [_descrip stringByAppendingFormat:description, ##__VA_ARGS__]; \ [self failWithException:[NSException failureInRaise:[NSString stringWithUTF8String:#expr] \ exception:nil \ inFile:[NSString stringWithUTF8String:__FILE__] \ atLine:__LINE__ \ - withDescription:@"%@", STComposeString(_descrip, ##__VA_ARGS__)]]; \ + withDescription:@"%@", _descrip]]; \ } while (0) @@ -909,32 +915,41 @@ do { \ } \ @catch (specificException *anException) { \ if ([aName isEqualToString:[anException name]]) continue; \ - NSString *_descrip = STComposeString(@"(Expected exception: %@ (name: %@)) %@", NSStringFromClass([specificException class]), aName, description); \ + NSString *_descrip = STComposeString( \ + @"(Expected exception: %@ (name: %@)) ", \ + NSStringFromClass([specificException class]), aName); \ + _descrip = [_descrip stringByAppendingFormat:description, ##__VA_ARGS__]; \ [self failWithException: \ [NSException failureInRaise:[NSString stringWithUTF8String:#expr] \ exception:anException \ inFile:[NSString stringWithUTF8String:__FILE__] \ atLine:__LINE__ \ - withDescription:@"%@", STComposeString(_descrip, ##__VA_ARGS__)]]; \ + withDescription:@"%@", _descrip]]; \ continue; \ } \ @catch (id anException) { \ - NSString *_descrip = STComposeString(@"(Expected exception: %@) %@", NSStringFromClass([specificException class]), description); \ + NSString *_descrip = STComposeString( \ + @"(Expected exception: %@ (name: %@)) ", \ + NSStringFromClass([specificException class]), aName); \ + _descrip = [_descrip stringByAppendingFormat:description, ##__VA_ARGS__]; \ [self failWithException: \ [NSException failureInRaise:[NSString stringWithUTF8String:#expr] \ exception:anException \ inFile:[NSString stringWithUTF8String:__FILE__] \ atLine:__LINE__ \ - withDescription:@"%@", STComposeString(_descrip, ##__VA_ARGS__)]]; \ + withDescription:@"%@", _descrip]]; \ continue; \ } \ - NSString *_descrip = STComposeString(@"(Expected exception: %@) %@", NSStringFromClass([specificException class]), description); \ + NSString *_descrip = STComposeString( \ + @"(Expected exception: %@ (name: %@)) ", \ + NSStringFromClass([specificException class]), aName); \ + _descrip = [_descrip stringByAppendingFormat:description, ##__VA_ARGS__]; \ [self failWithException: \ [NSException failureInRaise:[NSString stringWithUTF8String:#expr] \ exception:nil \ inFile:[NSString stringWithUTF8String:__FILE__] \ atLine:__LINE__ \ - withDescription:@"%@", STComposeString(_descrip, ##__VA_ARGS__)]]; \ + withDescription:@"%@", _descrip]]; \ } while (0) @@ -1004,13 +1019,16 @@ do { \ } \ @catch (specificException *anException) { \ if ([aName isEqualToString:[anException name]]) { \ - NSString *_descrip = STComposeString(@"(Expected exception: %@ (name: %@)) %@", NSStringFromClass([specificException class]), aName, description); \ + NSString *_descrip = STComposeString( \ + @"(Expected exception: %@ (name: %@)) ", \ + NSStringFromClass([specificException class]), aName); \ + _descrip = [_descrip stringByAppendingFormat:description, ##__VA_ARGS__]; \ [self failWithException: \ [NSException failureInRaise:[NSString stringWithUTF8String:#expr] \ exception:anException \ inFile:[NSString stringWithUTF8String:__FILE__] \ atLine:__LINE__ \ - withDescription:@"%@", STComposeString(_descrip, ##__VA_ARGS__)]]; \ + withDescription:@"%@", _descrip]]; \ } \ continue; \ } \ -- cgit v1.2.3