Ben Copsey

Update GHUnit

Showing 40 changed files with 684 additions and 156 deletions
@@ -28,19 +28,40 @@ @@ -28,19 +28,40 @@
28 // 28 //
29 29
30 #import <Foundation/Foundation.h> 30 #import <Foundation/Foundation.h>
31 -#import <Foundation/NSDebug.h>  
32 31
33 #import <GHUnit/GHUnit.h> 32 #import <GHUnit/GHUnit.h>
34 #import <GHUnit/GHTestApp.h> 33 #import <GHUnit/GHTestApp.h>
35 #import <GHUnit/GHTesting.h> 34 #import <GHUnit/GHTesting.h>
36 35
  36 +// Default exception handler
  37 +void exceptionHandler(NSException *exception) {
  38 + NSLog(@"%@\n%@", [exception reason], GHUStackTraceFromException(exception));
  39 +}
  40 +
37 int main(int argc, char *argv[]) { 41 int main(int argc, char *argv[]) {
38 - // Setup any NSDebug settings 42 +
39 - NSDebugEnabled = YES; 43 + /*!
40 - NSZombieEnabled = YES; 44 + For debugging:
41 - NSDeallocateZombies = NO; 45 + Go into the "Get Info" contextual menu of your (test) executable (inside the "Executables" group in the left panel of XCode).
42 - NSHangOnUncaughtException = YES; 46 + Then go in the "Arguments" tab. You can add the following environment variables:
43 - setenv("NSAutoreleaseFreedObjectCheckEnabled", "1", 1); 47 +
  48 + Default: Set to:
  49 + NSDebugEnabled NO "YES"
  50 + NSZombieEnabled NO "YES"
  51 + NSDeallocateZombies NO "YES"
  52 + NSHangOnUncaughtException NO "YES"
  53 +
  54 + NSEnableAutoreleasePool YES "NO"
  55 + NSAutoreleaseFreedObjectCheckEnabled NO "YES"
  56 + NSAutoreleaseHighWaterMark 0 non-negative integer
  57 + NSAutoreleaseHighWaterResolution 0 non-negative integer
  58 +
  59 + For info on these varaiables see NSDebug.h; http://theshadow.uw.hu/iPhoneSDKdoc/Foundation.framework/NSDebug.h.html
  60 +
  61 + For malloc debugging see: http://developer.apple.com/mac/library/documentation/Performance/Conceptual/ManagingMemory/Articles/MallocDebug.html
  62 + */
  63 +
  64 + NSSetUncaughtExceptionHandler(&exceptionHandler);
44 65
45 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 66 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
46 67
@@ -58,9 +79,11 @@ int main(int argc, char *argv[]) { @@ -58,9 +79,11 @@ int main(int argc, char *argv[]) {
58 // To run a different test suite: 79 // To run a different test suite:
59 //GHTestSuite *suite = [GHTestSuite suiteWithTestFilter:@"GHSlowTest,GHAsyncTestCaseTest"]; 80 //GHTestSuite *suite = [GHTestSuite suiteWithTestFilter:@"GHSlowTest,GHAsyncTestCaseTest"];
60 //GHTestApp *app = [[GHTestApp alloc] initWithSuite:suite]; 81 //GHTestApp *app = [[GHTestApp alloc] initWithSuite:suite];
  82 + // Or set global:
  83 + //GHUnitTest = @"GHSlowTest";
61 [NSApp run]; 84 [NSApp run];
62 [app release]; 85 [app release];
63 } 86 }
64 [pool release]; 87 [pool release];
65 return retVal; 88 return retVal;
66 -} 89 +}
@@ -8,8 +8,7 @@ @@ -8,8 +8,7 @@
8 8
9 #import <Cocoa/Cocoa.h> 9 #import <Cocoa/Cocoa.h>
10 10
11 -@interface BWSplitView : NSSplitView 11 +@interface BWSplitView : NSSplitView {
12 -{  
13 NSColor *color; 12 NSColor *color;
14 BOOL colorIsEnabled, checkboxIsEnabled, dividerCanCollapse, collapsibleSubviewCollapsed; 13 BOOL colorIsEnabled, checkboxIsEnabled, dividerCanCollapse, collapsibleSubviewCollapsed;
15 id secondaryDelegate; 14 id secondaryDelegate;
@@ -63,7 +63,7 @@ typedef struct { @@ -63,7 +63,7 @@ typedef struct {
63 */ 63 */
64 extern GHTestStats GHTestStatsMake(NSInteger succeedCount, NSInteger failureCount, NSInteger cancelCount, NSInteger testCount); 64 extern GHTestStats GHTestStatsMake(NSInteger succeedCount, NSInteger failureCount, NSInteger cancelCount, NSInteger testCount);
65 65
66 -const GHTestStats GHTestStatsEmpty; 66 +extern const GHTestStats GHTestStatsEmpty;
67 67
68 extern NSString *NSStringFromGHTestStats(GHTestStats stats); 68 extern NSString *NSStringFromGHTestStats(GHTestStats stats);
69 69
@@ -83,7 +83,7 @@ @@ -83,7 +83,7 @@
83 - (void)testB { } 83 - (void)testB { }
84 84
85 // Override any exceptions; By default exceptions are raised, causing a test failure 85 // Override any exceptions; By default exceptions are raised, causing a test failure
86 - - (void)failWithException:(NSException*)exception { } 86 + - (void)failWithException:(NSException *)exception { }
87 87
88 @end 88 @end
89 @endcode 89 @endcode
@@ -77,6 +77,9 @@ @@ -77,6 +77,9 @@
77 // the License. 77 // the License.
78 // 78 //
79 79
  80 +#import "NSException+GHTestFailureExceptions.h"
  81 +#import "NSValue+GHValueFormatter.h"
  82 +
80 // GTM_BEGIN 83 // GTM_BEGIN
81 84
82 extern NSString *const GHTestFilenameKey; 85 extern NSString *const GHTestFilenameKey;
@@ -100,13 +103,13 @@ NSString *_expression = [NSString stringWithFormat:@"Expected noErr, got %ld for @@ -100,13 +103,13 @@ NSString *_expression = [NSString stringWithFormat:@"Expected noErr, got %ld for
100 if (description) { \ 103 if (description) { \
101 _expression = [NSString stringWithFormat:@"%@: %@", _expression, GHComposeString(description, ##__VA_ARGS__)]; \ 104 _expression = [NSString stringWithFormat:@"%@: %@", _expression, GHComposeString(description, ##__VA_ARGS__)]; \
102 } \ 105 } \
103 -[self failWithException:[NSException failureInFile:[NSString stringWithUTF8String:__FILE__] \ 106 +[self failWithException:[NSException ghu_failureInFile:[NSString stringWithUTF8String:__FILE__] \
104 atLine:__LINE__ \ 107 atLine:__LINE__ \
105 withDescription:_expression]]; \ 108 withDescription:_expression]]; \
106 } \ 109 } \
107 }\ 110 }\
108 @catch (id anException) {\ 111 @catch (id anException) {\
109 -[self failWithException:[NSException failureInRaise:[NSString stringWithFormat:@"(%s) == noErr fails", #a1] \ 112 +[self failWithException:[NSException ghu_failureInRaise:[NSString stringWithFormat:@"(%s) == noErr fails", #a1] \
110 exception:anException \ 113 exception:anException \
111 inFile:[NSString stringWithUTF8String:__FILE__] \ 114 inFile:[NSString stringWithUTF8String:__FILE__] \
112 atLine:__LINE__ \ 115 atLine:__LINE__ \
@@ -131,13 +134,13 @@ NSString *_expression = [NSString stringWithFormat:@"Expected %s(%ld) but got %l @@ -131,13 +134,13 @@ NSString *_expression = [NSString stringWithFormat:@"Expected %s(%ld) but got %l
131 if (description) { \ 134 if (description) { \
132 _expression = [NSString stringWithFormat:@"%@: %@", _expression, GHComposeString(description, ##__VA_ARGS__)]; \ 135 _expression = [NSString stringWithFormat:@"%@: %@", _expression, GHComposeString(description, ##__VA_ARGS__)]; \
133 } \ 136 } \
134 -[self failWithException:[NSException failureInFile:[NSString stringWithUTF8String:__FILE__] \ 137 +[self failWithException:[NSException ghu_failureInFile:[NSString stringWithUTF8String:__FILE__] \
135 atLine:__LINE__ \ 138 atLine:__LINE__ \
136 withDescription:_expression]]; \ 139 withDescription:_expression]]; \
137 } \ 140 } \
138 }\ 141 }\
139 @catch (id anException) {\ 142 @catch (id anException) {\
140 -[self failWithException:[NSException failureInRaise:[NSString stringWithFormat:@"(%s) == (%s) fails", #a1, #a2] \ 143 +[self failWithException:[NSException ghu_failureInRaise:[NSString stringWithFormat:@"(%s) == (%s) fails", #a1, #a2] \
141 exception:anException \ 144 exception:anException \
142 inFile:[NSString stringWithUTF8String:__FILE__] \ 145 inFile:[NSString stringWithUTF8String:__FILE__] \
143 atLine:__LINE__ \ 146 atLine:__LINE__ \
@@ -161,13 +164,13 @@ NSString *_expression = [NSString stringWithFormat:@"(%s) != NULL", #a1]; \ @@ -161,13 +164,13 @@ NSString *_expression = [NSString stringWithFormat:@"(%s) != NULL", #a1]; \
161 if (description) { \ 164 if (description) { \
162 _expression = [NSString stringWithFormat:@"%@: %@", _expression, GHComposeString(description, ##__VA_ARGS__)]; \ 165 _expression = [NSString stringWithFormat:@"%@: %@", _expression, GHComposeString(description, ##__VA_ARGS__)]; \
163 } \ 166 } \
164 -[self failWithException:[NSException failureInFile:[NSString stringWithUTF8String:__FILE__] \ 167 +[self failWithException:[NSException ghu_failureInFile:[NSString stringWithUTF8String:__FILE__] \
165 atLine:__LINE__ \ 168 atLine:__LINE__ \
166 withDescription:_expression]]; \ 169 withDescription:_expression]]; \
167 } \ 170 } \
168 }\ 171 }\
169 @catch (id anException) {\ 172 @catch (id anException) {\
170 -[self failWithException:[NSException failureInRaise:[NSString stringWithFormat:@"(%s) != NULL fails", #a1] \ 173 +[self failWithException:[NSException ghu_failureInRaise:[NSString stringWithFormat:@"(%s) != NULL fails", #a1] \
171 exception:anException \ 174 exception:anException \
172 inFile:[NSString stringWithUTF8String:__FILE__] \ 175 inFile:[NSString stringWithUTF8String:__FILE__] \
173 atLine:__LINE__ \ 176 atLine:__LINE__ \
@@ -190,13 +193,13 @@ NSString *_expression = [NSString stringWithFormat:@"(%s) == NULL", #a1]; \ @@ -190,13 +193,13 @@ NSString *_expression = [NSString stringWithFormat:@"(%s) == NULL", #a1]; \
190 if (description) { \ 193 if (description) { \
191 _expression = [NSString stringWithFormat:@"%@: %@", _expression, GHComposeString(description, ##__VA_ARGS__)]; \ 194 _expression = [NSString stringWithFormat:@"%@: %@", _expression, GHComposeString(description, ##__VA_ARGS__)]; \
192 } \ 195 } \
193 -[self failWithException:[NSException failureInFile:[NSString stringWithUTF8String:__FILE__] \ 196 +[self failWithException:[NSException ghu_failureInFile:[NSString stringWithUTF8String:__FILE__] \
194 atLine:__LINE__ \ 197 atLine:__LINE__ \
195 withDescription:_expression]]; \ 198 withDescription:_expression]]; \
196 } \ 199 } \
197 }\ 200 }\
198 @catch (id anException) {\ 201 @catch (id anException) {\
199 -[self failWithException:[NSException failureInRaise:[NSString stringWithFormat:@"(%s) == NULL fails", #a1] \ 202 +[self failWithException:[NSException ghu_failureInRaise:[NSString stringWithFormat:@"(%s) == NULL fails", #a1] \
200 exception:anException \ 203 exception:anException \
201 inFile:[NSString stringWithUTF8String:__FILE__] \ 204 inFile:[NSString stringWithUTF8String:__FILE__] \
202 atLine:__LINE__ \ 205 atLine:__LINE__ \
@@ -216,7 +219,7 @@ withDescription:GHComposeString(description, ##__VA_ARGS__)]]; \ @@ -216,7 +219,7 @@ withDescription:GHComposeString(description, ##__VA_ARGS__)]]; \
216 do { \ 219 do { \
217 @try {\ 220 @try {\
218 if (@encode(__typeof__(a1)) != @encode(__typeof__(a2))) { \ 221 if (@encode(__typeof__(a1)) != @encode(__typeof__(a2))) { \
219 -[self failWithException:[NSException failureInFile:[NSString stringWithUTF8String:__FILE__] \ 222 +[self failWithException:[NSException ghu_failureInFile:[NSString stringWithUTF8String:__FILE__] \
220 atLine:__LINE__ \ 223 atLine:__LINE__ \
221 withDescription:[@"Type mismatch -- " stringByAppendingString:GHComposeString(description, ##__VA_ARGS__)]]]; \ 224 withDescription:[@"Type mismatch -- " stringByAppendingString:GHComposeString(description, ##__VA_ARGS__)]]]; \
222 } else { \ 225 } else { \
@@ -229,14 +232,14 @@ NSString *_expression = [NSString stringWithFormat:@"(%s) != (%s)", #a1, #a2]; \ @@ -229,14 +232,14 @@ NSString *_expression = [NSString stringWithFormat:@"(%s) != (%s)", #a1, #a2]; \
229 if (description) { \ 232 if (description) { \
230 _expression = [NSString stringWithFormat:@"%@: %@", _expression, GHComposeString(description, ##__VA_ARGS__)]; \ 233 _expression = [NSString stringWithFormat:@"%@: %@", _expression, GHComposeString(description, ##__VA_ARGS__)]; \
231 } \ 234 } \
232 -[self failWithException:[NSException failureInFile:[NSString stringWithUTF8String:__FILE__] \ 235 +[self failWithException:[NSException ghu_failureInFile:[NSString stringWithUTF8String:__FILE__] \
233 atLine:__LINE__ \ 236 atLine:__LINE__ \
234 withDescription:_expression]]; \ 237 withDescription:_expression]]; \
235 } \ 238 } \
236 } \ 239 } \
237 } \ 240 } \
238 @catch (id anException) {\ 241 @catch (id anException) {\
239 -[self failWithException:[NSException failureInRaise:[NSString stringWithFormat:@"(%s) != (%s)", #a1, #a2] \ 242 +[self failWithException:[NSException ghu_failureInRaise:[NSString stringWithFormat:@"(%s) != (%s)", #a1, #a2] \
240 exception:anException \ 243 exception:anException \
241 inFile:[NSString stringWithUTF8String:__FILE__] \ 244 inFile:[NSString stringWithUTF8String:__FILE__] \
242 atLine:__LINE__ \ 245 atLine:__LINE__ \
@@ -263,12 +266,12 @@ NSString *_expression = [NSString stringWithFormat:@"%s('%@') != %s('%@')", #a1, @@ -263,12 +266,12 @@ NSString *_expression = [NSString stringWithFormat:@"%s('%@') != %s('%@')", #a1,
263 if (desc) { \ 266 if (desc) { \
264 _expression = [NSString stringWithFormat:@"%@: %@", _expression, GHComposeString(desc, ##__VA_ARGS__)]; \ 267 _expression = [NSString stringWithFormat:@"%@: %@", _expression, GHComposeString(desc, ##__VA_ARGS__)]; \
265 } \ 268 } \
266 -[self failWithException:[NSException failureInFile:[NSString stringWithUTF8String:__FILE__] \ 269 +[self failWithException:[NSException ghu_failureInFile:[NSString stringWithUTF8String:__FILE__] \
267 atLine:__LINE__ \ 270 atLine:__LINE__ \
268 withDescription:_expression]]; \ 271 withDescription:_expression]]; \
269 }\ 272 }\
270 @catch (id anException) {\ 273 @catch (id anException) {\
271 -[self failWithException:[NSException failureInRaise:[NSString stringWithFormat: @"(%s) != (%s)", #a1, #a2] \ 274 +[self failWithException:[NSException ghu_failureInRaise:[NSString stringWithFormat: @"(%s) != (%s)", #a1, #a2] \
272 exception:anException \ 275 exception:anException \
273 inFile:[NSString stringWithUTF8String:__FILE__] \ 276 inFile:[NSString stringWithUTF8String:__FILE__] \
274 atLine:__LINE__ \ 277 atLine:__LINE__ \
@@ -288,7 +291,7 @@ withDescription:GHComposeString(desc, ##__VA_ARGS__)]]; \ @@ -288,7 +291,7 @@ withDescription:GHComposeString(desc, ##__VA_ARGS__)]]; \
288 do { \ 291 do { \
289 @try {\ 292 @try {\
290 if (@encode(__typeof__(a1)) != @encode(__typeof__(a2))) { \ 293 if (@encode(__typeof__(a1)) != @encode(__typeof__(a2))) { \
291 -[self failWithException:[NSException failureInFile:[NSString stringWithUTF8String:__FILE__] \ 294 +[self failWithException:[NSException ghu_failureInFile:[NSString stringWithUTF8String:__FILE__] \
292 atLine:__LINE__ \ 295 atLine:__LINE__ \
293 withDescription:[@"Type mismatch -- " stringByAppendingString:GHComposeString(description, ##__VA_ARGS__)]]]; \ 296 withDescription:[@"Type mismatch -- " stringByAppendingString:GHComposeString(description, ##__VA_ARGS__)]]]; \
294 } else { \ 297 } else { \
@@ -301,7 +304,7 @@ NSString *_expression = [NSString stringWithFormat:@"%s (%lg) %s %s (%lg)", #a1, @@ -301,7 +304,7 @@ NSString *_expression = [NSString stringWithFormat:@"%s (%lg) %s %s (%lg)", #a1,
301 if (description) { \ 304 if (description) { \
302 _expression = [NSString stringWithFormat:@"%@: %@", _expression, GHComposeString(description, ##__VA_ARGS__)]; \ 305 _expression = [NSString stringWithFormat:@"%@: %@", _expression, GHComposeString(description, ##__VA_ARGS__)]; \
303 } \ 306 } \
304 -[self failWithException:[NSException failureInFile:[NSString stringWithUTF8String:__FILE__] \ 307 +[self failWithException:[NSException ghu_failureInFile:[NSString stringWithUTF8String:__FILE__] \
305 atLine:__LINE__ \ 308 atLine:__LINE__ \
306 withDescription:_expression]]; \ 309 withDescription:_expression]]; \
307 } \ 310 } \
@@ -309,7 +312,7 @@ withDescription:_expression]]; \ @@ -309,7 +312,7 @@ withDescription:_expression]]; \
309 } \ 312 } \
310 @catch (id anException) {\ 313 @catch (id anException) {\
311 [self failWithException:[NSException \ 314 [self failWithException:[NSException \
312 -failureInRaise:[NSString stringWithFormat:@"(%s) %s (%s)", #a1, #op, #a2] \ 315 +ghu_failureInRaise:[NSString stringWithFormat:@"(%s) %s (%s)", #a1, #op, #a2] \
313 exception:anException \ 316 exception:anException \
314 inFile:[NSString stringWithUTF8String:__FILE__] \ 317 inFile:[NSString stringWithUTF8String:__FILE__] \
315 atLine:__LINE__ \ 318 atLine:__LINE__ \
@@ -381,14 +384,14 @@ if (a1value == a2value) continue; \ @@ -381,14 +384,14 @@ if (a1value == a2value) continue; \
381 if ([a1value isKindOfClass:[NSString class]] && \ 384 if ([a1value isKindOfClass:[NSString class]] && \
382 [a2value isKindOfClass:[NSString class]] && \ 385 [a2value isKindOfClass:[NSString class]] && \
383 [a1value compare:a2value options:0] == NSOrderedSame) continue; \ 386 [a1value compare:a2value options:0] == NSOrderedSame) continue; \
384 -[self failWithException:[NSException failureInEqualityBetweenObject: a1value \ 387 +[self failWithException:[NSException ghu_failureInEqualityBetweenObject: a1value \
385 andObject: a2value \ 388 andObject: a2value \
386 inFile: [NSString stringWithUTF8String:__FILE__] \ 389 inFile: [NSString stringWithUTF8String:__FILE__] \
387 atLine: __LINE__ \ 390 atLine: __LINE__ \
388 withDescription: GHComposeString(description, ##__VA_ARGS__)]]; \ 391 withDescription: GHComposeString(description, ##__VA_ARGS__)]]; \
389 }\ 392 }\
390 @catch (id anException) {\ 393 @catch (id anException) {\
391 -[self failWithException:[NSException failureInRaise:[NSString stringWithFormat: @"(%s) == (%s)", #a1, #a2] \ 394 +[self failWithException:[NSException ghu_failureInRaise:[NSString stringWithFormat: @"(%s) == (%s)", #a1, #a2] \
392 exception:anException \ 395 exception:anException \
393 inFile:[NSString stringWithUTF8String:__FILE__] \ 396 inFile:[NSString stringWithUTF8String:__FILE__] \
394 atLine:__LINE__ \ 397 atLine:__LINE__ \
@@ -415,14 +418,14 @@ id a2value = (a2); \ @@ -415,14 +418,14 @@ id a2value = (a2); \
415 if ([a1value isKindOfClass:[NSString class]] && \ 418 if ([a1value isKindOfClass:[NSString class]] && \
416 [a2value isKindOfClass:[NSString class]] && \ 419 [a2value isKindOfClass:[NSString class]] && \
417 [a1value compare:a2value options:0] != NSOrderedSame) continue; \ 420 [a1value compare:a2value options:0] != NSOrderedSame) continue; \
418 -[self failWithException:[NSException failureInEqualityBetweenObject: a1value \ 421 +[self failWithException:[NSException ghu_failureInEqualityBetweenObject: a1value \
419 andObject: a2value \ 422 andObject: a2value \
420 inFile: [NSString stringWithUTF8String:__FILE__] \ 423 inFile: [NSString stringWithUTF8String:__FILE__] \
421 atLine: __LINE__ \ 424 atLine: __LINE__ \
422 withDescription: GHComposeString(description, ##__VA_ARGS__)]]; \ 425 withDescription: GHComposeString(description, ##__VA_ARGS__)]]; \
423 }\ 426 }\
424 @catch (id anException) {\ 427 @catch (id anException) {\
425 -[self failWithException:[NSException failureInRaise:[NSString stringWithFormat: @"(%s) != (%s)", #a1, #a2] \ 428 +[self failWithException:[NSException ghu_failureInRaise:[NSString stringWithFormat: @"(%s) != (%s)", #a1, #a2] \
426 exception:anException \ 429 exception:anException \
427 inFile:[NSString stringWithUTF8String:__FILE__] \ 430 inFile:[NSString stringWithUTF8String:__FILE__] \
428 atLine:__LINE__ \ 431 atLine:__LINE__ \
@@ -444,14 +447,14 @@ const char* a1value = (a1); \ @@ -444,14 +447,14 @@ const char* a1value = (a1); \
444 const char* a2value = (a2); \ 447 const char* a2value = (a2); \
445 if (a1value == a2value) continue; \ 448 if (a1value == a2value) continue; \
446 if (strcmp(a1value, a2value) == 0) continue; \ 449 if (strcmp(a1value, a2value) == 0) continue; \
447 -[self failWithException:[NSException failureInEqualityBetweenObject: [NSString stringWithUTF8String:a1value] \ 450 +[self failWithException:[NSException ghu_failureInEqualityBetweenObject: [NSString stringWithUTF8String:a1value] \
448 andObject: [NSString stringWithUTF8String:a2value] \ 451 andObject: [NSString stringWithUTF8String:a2value] \
449 inFile: [NSString stringWithUTF8String:__FILE__] \ 452 inFile: [NSString stringWithUTF8String:__FILE__] \
450 atLine: __LINE__ \ 453 atLine: __LINE__ \
451 withDescription: GHComposeString(description, ##__VA_ARGS__)]]; \ 454 withDescription: GHComposeString(description, ##__VA_ARGS__)]]; \
452 }\ 455 }\
453 @catch (id anException) {\ 456 @catch (id anException) {\
454 -[self failWithException:[NSException failureInRaise:[NSString stringWithFormat: @"(%s) == (%s)", #a1, #a2] \ 457 +[self failWithException:[NSException ghu_failureInRaise:[NSString stringWithFormat: @"(%s) == (%s)", #a1, #a2] \
455 exception:anException \ 458 exception:anException \
456 inFile:[NSString stringWithUTF8String:__FILE__] \ 459 inFile:[NSString stringWithUTF8String:__FILE__] \
457 atLine:__LINE__ \ 460 atLine:__LINE__ \
@@ -472,14 +475,14 @@ do { \ @@ -472,14 +475,14 @@ do { \
472 const char* a1value = (a1); \ 475 const char* a1value = (a1); \
473 const char* a2value = (a2); \ 476 const char* a2value = (a2); \
474 if (strcmp(a1value, a2value) != 0) continue; \ 477 if (strcmp(a1value, a2value) != 0) continue; \
475 -[self failWithException:[NSException failureInEqualityBetweenObject: [NSString stringWithUTF8String:a1value] \ 478 +[self failWithException:[NSException ghu_failureInEqualityBetweenObject: [NSString stringWithUTF8String:a1value] \
476 andObject: [NSString stringWithUTF8String:a2value] \ 479 andObject: [NSString stringWithUTF8String:a2value] \
477 inFile: [NSString stringWithUTF8String:__FILE__] \ 480 inFile: [NSString stringWithUTF8String:__FILE__] \
478 atLine: __LINE__ \ 481 atLine: __LINE__ \
479 withDescription: GHComposeString(description, ##__VA_ARGS__)]]; \ 482 withDescription: GHComposeString(description, ##__VA_ARGS__)]]; \
480 }\ 483 }\
481 @catch (id anException) {\ 484 @catch (id anException) {\
482 -[self failWithException:[NSException failureInRaise:[NSString stringWithFormat: @"(%s) != (%s)", #a1, #a2] \ 485 +[self failWithException:[NSException ghu_failureInRaise:[NSString stringWithFormat: @"(%s) != (%s)", #a1, #a2] \
483 exception:anException \ 486 exception:anException \
484 inFile:[NSString stringWithUTF8String:__FILE__] \ 487 inFile:[NSString stringWithUTF8String:__FILE__] \
485 atLine:__LINE__ \ 488 atLine:__LINE__ \
@@ -507,14 +510,14 @@ if (a1value == a2value) continue; \ @@ -507,14 +510,14 @@ if (a1value == a2value) continue; \
507 if ( (@encode(__typeof__(a1value)) == @encode(id)) && \ 510 if ( (@encode(__typeof__(a1value)) == @encode(id)) && \
508 (@encode(__typeof__(a2value)) == @encode(id)) && \ 511 (@encode(__typeof__(a2value)) == @encode(id)) && \
509 [(id)a1value isEqual: (id)a2value] ) continue; \ 512 [(id)a1value isEqual: (id)a2value] ) continue; \
510 -[self failWithException:[NSException failureInEqualityBetweenObject: a1value \ 513 +[self failWithException:[NSException ghu_failureInEqualityBetweenObject: a1value \
511 andObject: a2value \ 514 andObject: a2value \
512 inFile: [NSString stringWithUTF8String:__FILE__] \ 515 inFile: [NSString stringWithUTF8String:__FILE__] \
513 atLine: __LINE__ \ 516 atLine: __LINE__ \
514 withDescription: GHComposeString(description, ##__VA_ARGS__)]]; \ 517 withDescription: GHComposeString(description, ##__VA_ARGS__)]]; \
515 }\ 518 }\
516 @catch (id anException) {\ 519 @catch (id anException) {\
517 -[self failWithException:[NSException failureInRaise:[NSString stringWithFormat: @"(%s) == (%s)", #a1, #a2] \ 520 +[self failWithException:[NSException ghu_failureInRaise:[NSString stringWithFormat: @"(%s) == (%s)", #a1, #a2] \
518 exception:anException \ 521 exception:anException \
519 inFile:[NSString stringWithUTF8String:__FILE__] \ 522 inFile:[NSString stringWithUTF8String:__FILE__] \
520 atLine:__LINE__ \ 523 atLine:__LINE__ \
@@ -535,7 +538,7 @@ withDescription:GHComposeString(description, ##__VA_ARGS__)]]; \ @@ -535,7 +538,7 @@ withDescription:GHComposeString(description, ##__VA_ARGS__)]]; \
535 do { \ 538 do { \
536 @try {\ 539 @try {\
537 if (@encode(__typeof__(a1)) != @encode(__typeof__(a2))) { \ 540 if (@encode(__typeof__(a1)) != @encode(__typeof__(a2))) { \
538 -[self failWithException:[NSException failureInFile:[NSString stringWithUTF8String:__FILE__] \ 541 +[self failWithException:[NSException ghu_failureInFile:[NSString stringWithUTF8String:__FILE__] \
539 atLine:__LINE__ \ 542 atLine:__LINE__ \
540 withDescription:[@"Type mismatch -- " stringByAppendingString:GHComposeString(description, ##__VA_ARGS__)]]]; \ 543 withDescription:[@"Type mismatch -- " stringByAppendingString:GHComposeString(description, ##__VA_ARGS__)]]]; \
541 } else { \ 544 } else { \
@@ -544,7 +547,7 @@ __typeof__(a2) a2value = (a2); \ @@ -544,7 +547,7 @@ __typeof__(a2) a2value = (a2); \
544 NSValue *a1encoded = [NSValue value:&a1value withObjCType: @encode(__typeof__(a1))]; \ 547 NSValue *a1encoded = [NSValue value:&a1value withObjCType: @encode(__typeof__(a1))]; \
545 NSValue *a2encoded = [NSValue value:&a2value withObjCType: @encode(__typeof__(a2))]; \ 548 NSValue *a2encoded = [NSValue value:&a2value withObjCType: @encode(__typeof__(a2))]; \
546 if (![a1encoded isEqualToValue:a2encoded]) { \ 549 if (![a1encoded isEqualToValue:a2encoded]) { \
547 -[self failWithException:[NSException failureInEqualityBetweenValue: a1encoded \ 550 +[self failWithException:[NSException ghu_failureInEqualityBetweenValue: a1encoded \
548 andValue: a2encoded \ 551 andValue: a2encoded \
549 withAccuracy: nil \ 552 withAccuracy: nil \
550 inFile: [NSString stringWithUTF8String:__FILE__] \ 553 inFile: [NSString stringWithUTF8String:__FILE__] \
@@ -554,7 +557,7 @@ withDescription: GHComposeString(description, ##__VA_ARGS__)]]; \ @@ -554,7 +557,7 @@ withDescription: GHComposeString(description, ##__VA_ARGS__)]]; \
554 } \ 557 } \
555 } \ 558 } \
556 @catch (id anException) {\ 559 @catch (id anException) {\
557 -[self failWithException:[NSException failureInRaise:[NSString stringWithFormat: @"(%s) == (%s)", #a1, #a2] \ 560 +[self failWithException:[NSException ghu_failureInRaise:[NSString stringWithFormat: @"(%s) == (%s)", #a1, #a2] \
558 exception:anException \ 561 exception:anException \
559 inFile:[NSString stringWithUTF8String:__FILE__] \ 562 inFile:[NSString stringWithUTF8String:__FILE__] \
560 atLine:__LINE__ \ 563 atLine:__LINE__ \
@@ -581,7 +584,7 @@ withDescription:GHComposeString(description, ##__VA_ARGS__)]]; \ @@ -581,7 +584,7 @@ withDescription:GHComposeString(description, ##__VA_ARGS__)]]; \
581 do { \ 584 do { \
582 @try {\ 585 @try {\
583 if (@encode(__typeof__(a1)) != @encode(__typeof__(a2))) { \ 586 if (@encode(__typeof__(a1)) != @encode(__typeof__(a2))) { \
584 -[self failWithException:[NSException failureInFile:[NSString stringWithUTF8String:__FILE__] \ 587 +[self failWithException:[NSException ghu_failureInFile:[NSString stringWithUTF8String:__FILE__] \
585 atLine:__LINE__ \ 588 atLine:__LINE__ \
586 withDescription:[@"Type mismatch -- " stringByAppendingString:GHComposeString(description, ##__VA_ARGS__)]]]; \ 589 withDescription:[@"Type mismatch -- " stringByAppendingString:GHComposeString(description, ##__VA_ARGS__)]]]; \
587 } else { \ 590 } else { \
@@ -592,7 +595,7 @@ if (GHAbsoluteDifference(a1value, a2value) > accuracyvalue) { \ @@ -592,7 +595,7 @@ if (GHAbsoluteDifference(a1value, a2value) > accuracyvalue) { \
592 NSValue *a1encoded = [NSValue value:&a1value withObjCType:@encode(__typeof__(a1))]; \ 595 NSValue *a1encoded = [NSValue value:&a1value withObjCType:@encode(__typeof__(a1))]; \
593 NSValue *a2encoded = [NSValue value:&a2value withObjCType:@encode(__typeof__(a2))]; \ 596 NSValue *a2encoded = [NSValue value:&a2value withObjCType:@encode(__typeof__(a2))]; \
594 NSValue *accuracyencoded = [NSValue value:&accuracyvalue withObjCType:@encode(__typeof__(accuracy))]; \ 597 NSValue *accuracyencoded = [NSValue value:&accuracyvalue withObjCType:@encode(__typeof__(accuracy))]; \
595 -[self failWithException:[NSException failureInEqualityBetweenValue: a1encoded \ 598 +[self failWithException:[NSException ghu_failureInEqualityBetweenValue: a1encoded \
596 andValue: a2encoded \ 599 andValue: a2encoded \
597 withAccuracy: accuracyencoded \ 600 withAccuracy: accuracyencoded \
598 inFile: [NSString stringWithUTF8String:__FILE__] \ 601 inFile: [NSString stringWithUTF8String:__FILE__] \
@@ -602,7 +605,7 @@ withDescription: GHComposeString(description, ##__VA_ARGS__)]]; \ @@ -602,7 +605,7 @@ withDescription: GHComposeString(description, ##__VA_ARGS__)]]; \
602 } \ 605 } \
603 } \ 606 } \
604 @catch (id anException) {\ 607 @catch (id anException) {\
605 -[self failWithException:[NSException failureInRaise:[NSString stringWithFormat: @"(%s) == (%s)", #a1, #a2] \ 608 +[self failWithException:[NSException ghu_failureInRaise:[NSString stringWithFormat: @"(%s) == (%s)", #a1, #a2] \
606 exception:anException \ 609 exception:anException \
607 inFile:[NSString stringWithUTF8String:__FILE__] \ 610 inFile:[NSString stringWithUTF8String:__FILE__] \
608 atLine:__LINE__ \ 611 atLine:__LINE__ \
@@ -618,7 +621,7 @@ withDescription:GHComposeString(description, ##__VA_ARGS__)]]; \ @@ -618,7 +621,7 @@ withDescription:GHComposeString(description, ##__VA_ARGS__)]]; \
618 _{... A variable number of arguments to the format string. Can be absent.} 621 _{... A variable number of arguments to the format string. Can be absent.}
619 "*/ 622 "*/
620 #define GHFail(description, ...) \ 623 #define GHFail(description, ...) \
621 -[self failWithException:[NSException failureInFile: [NSString stringWithUTF8String:__FILE__] \ 624 +[self failWithException:[NSException ghu_failureInFile: [NSString stringWithUTF8String:__FILE__] \
622 atLine: __LINE__ \ 625 atLine: __LINE__ \
623 withDescription: GHComposeString(description, ##__VA_ARGS__)]] 626 withDescription: GHComposeString(description, ##__VA_ARGS__)]]
624 627
@@ -637,7 +640,7 @@ id a1value = (a1); \ @@ -637,7 +640,7 @@ id a1value = (a1); \
637 if (a1value != nil) { \ 640 if (a1value != nil) { \
638 NSString *_a1 = [NSString stringWithUTF8String: #a1]; \ 641 NSString *_a1 = [NSString stringWithUTF8String: #a1]; \
639 NSString *_expression = [NSString stringWithFormat:@"((%@) == nil)", _a1]; \ 642 NSString *_expression = [NSString stringWithFormat:@"((%@) == nil)", _a1]; \
640 -[self failWithException:[NSException failureInCondition: _expression \ 643 +[self failWithException:[NSException ghu_failureInCondition: _expression \
641 isTrue: NO \ 644 isTrue: NO \
642 inFile: [NSString stringWithUTF8String:__FILE__] \ 645 inFile: [NSString stringWithUTF8String:__FILE__] \
643 atLine: __LINE__ \ 646 atLine: __LINE__ \
@@ -645,7 +648,7 @@ withDescription: GHComposeString(description, ##__VA_ARGS__)]]; \ @@ -645,7 +648,7 @@ withDescription: GHComposeString(description, ##__VA_ARGS__)]]; \
645 } \ 648 } \
646 }\ 649 }\
647 @catch (id anException) {\ 650 @catch (id anException) {\
648 -[self failWithException:[NSException failureInRaise:[NSString stringWithFormat: @"(%s) == nil fails", #a1] \ 651 +[self failWithException:[NSException ghu_failureInRaise:[NSString stringWithFormat: @"(%s) == nil fails", #a1] \
649 exception:anException \ 652 exception:anException \
650 inFile:[NSString stringWithUTF8String:__FILE__] \ 653 inFile:[NSString stringWithUTF8String:__FILE__] \
651 atLine:__LINE__ \ 654 atLine:__LINE__ \
@@ -667,7 +670,7 @@ id a1value = (a1); \ @@ -667,7 +670,7 @@ id a1value = (a1); \
667 if (a1value == nil) { \ 670 if (a1value == nil) { \
668 NSString *_a1 = [NSString stringWithUTF8String: #a1]; \ 671 NSString *_a1 = [NSString stringWithUTF8String: #a1]; \
669 NSString *_expression = [NSString stringWithFormat:@"((%@) != nil)", _a1]; \ 672 NSString *_expression = [NSString stringWithFormat:@"((%@) != nil)", _a1]; \
670 -[self failWithException:[NSException failureInCondition: _expression \ 673 +[self failWithException:[NSException ghu_failureInCondition: _expression \
671 isTrue: NO \ 674 isTrue: NO \
672 inFile: [NSString stringWithUTF8String:__FILE__] \ 675 inFile: [NSString stringWithUTF8String:__FILE__] \
673 atLine: __LINE__ \ 676 atLine: __LINE__ \
@@ -675,7 +678,7 @@ withDescription: GHComposeString(description, ##__VA_ARGS__)]]; \ @@ -675,7 +678,7 @@ withDescription: GHComposeString(description, ##__VA_ARGS__)]]; \
675 } \ 678 } \
676 }\ 679 }\
677 @catch (id anException) {\ 680 @catch (id anException) {\
678 -[self failWithException:[NSException failureInRaise:[NSString stringWithFormat: @"(%s) != nil fails", #a1] \ 681 +[self failWithException:[NSException ghu_failureInRaise:[NSString stringWithFormat: @"(%s) != nil fails", #a1] \
679 exception:anException \ 682 exception:anException \
680 inFile:[NSString stringWithUTF8String:__FILE__] \ 683 inFile:[NSString stringWithUTF8String:__FILE__] \
681 atLine:__LINE__ \ 684 atLine:__LINE__ \
@@ -695,7 +698,7 @@ do { \ @@ -695,7 +698,7 @@ do { \
695 BOOL _evaluatedExpression = (expr);\ 698 BOOL _evaluatedExpression = (expr);\
696 if (!_evaluatedExpression) {\ 699 if (!_evaluatedExpression) {\
697 NSString *_expression = [NSString stringWithUTF8String: #expr];\ 700 NSString *_expression = [NSString stringWithUTF8String: #expr];\
698 -[self failWithException:[NSException failureInCondition: _expression \ 701 +[self failWithException:[NSException ghu_failureInCondition: _expression \
699 isTrue: YES \ 702 isTrue: YES \
700 inFile: [NSString stringWithUTF8String:__FILE__] \ 703 inFile: [NSString stringWithUTF8String:__FILE__] \
701 atLine: __LINE__ \ 704 atLine: __LINE__ \
@@ -717,7 +720,7 @@ do { \ @@ -717,7 +720,7 @@ do { \
717 BOOL _evaluatedExpression = (expr);\ 720 BOOL _evaluatedExpression = (expr);\
718 if (!_evaluatedExpression) {\ 721 if (!_evaluatedExpression) {\
719 NSString *_expression = [NSString stringWithUTF8String: #expr];\ 722 NSString *_expression = [NSString stringWithUTF8String: #expr];\
720 -[self failWithException:[NSException failureInCondition: _expression \ 723 +[self failWithException:[NSException ghu_failureInCondition: _expression \
721 isTrue: NO \ 724 isTrue: NO \
722 inFile: [NSString stringWithUTF8String:__FILE__] \ 725 inFile: [NSString stringWithUTF8String:__FILE__] \
723 atLine: __LINE__ \ 726 atLine: __LINE__ \
@@ -725,7 +728,7 @@ withDescription: GHComposeString(description, ##__VA_ARGS__)]]; \ @@ -725,7 +728,7 @@ withDescription: GHComposeString(description, ##__VA_ARGS__)]]; \
725 } \ 728 } \
726 } \ 729 } \
727 @catch (id anException) {\ 730 @catch (id anException) {\
728 -[self failWithException:[NSException failureInRaise:[NSString stringWithFormat: @"(%s) ", #expr] \ 731 +[self failWithException:[NSException ghu_failureInRaise:[NSString stringWithFormat: @"(%s) ", #expr] \
729 exception:anException \ 732 exception:anException \
730 inFile:[NSString stringWithUTF8String:__FILE__] \ 733 inFile:[NSString stringWithUTF8String:__FILE__] \
731 atLine:__LINE__ \ 734 atLine:__LINE__ \
@@ -745,7 +748,7 @@ do { \ @@ -745,7 +748,7 @@ do { \
745 BOOL _evaluatedExpression = (expr);\ 748 BOOL _evaluatedExpression = (expr);\
746 if (_evaluatedExpression) {\ 749 if (_evaluatedExpression) {\
747 NSString *_expression = [NSString stringWithUTF8String: #expr];\ 750 NSString *_expression = [NSString stringWithUTF8String: #expr];\
748 -[self failWithException:[NSException failureInCondition: _expression \ 751 +[self failWithException:[NSException ghu_failureInCondition: _expression \
749 isTrue: NO \ 752 isTrue: NO \
750 inFile: [NSString stringWithUTF8String:__FILE__] \ 753 inFile: [NSString stringWithUTF8String:__FILE__] \
751 atLine: __LINE__ \ 754 atLine: __LINE__ \
@@ -767,7 +770,7 @@ do { \ @@ -767,7 +770,7 @@ do { \
767 BOOL _evaluatedExpression = (expr);\ 770 BOOL _evaluatedExpression = (expr);\
768 if (_evaluatedExpression) {\ 771 if (_evaluatedExpression) {\
769 NSString *_expression = [NSString stringWithUTF8String: #expr];\ 772 NSString *_expression = [NSString stringWithUTF8String: #expr];\
770 -[self failWithException:[NSException failureInCondition: _expression \ 773 +[self failWithException:[NSException ghu_failureInCondition: _expression \
771 isTrue: YES \ 774 isTrue: YES \
772 inFile: [NSString stringWithUTF8String:__FILE__] \ 775 inFile: [NSString stringWithUTF8String:__FILE__] \
773 atLine: __LINE__ \ 776 atLine: __LINE__ \
@@ -775,7 +778,7 @@ withDescription: GHComposeString(description, ##__VA_ARGS__)]]; \ @@ -775,7 +778,7 @@ withDescription: GHComposeString(description, ##__VA_ARGS__)]]; \
775 } \ 778 } \
776 } \ 779 } \
777 @catch (id anException) {\ 780 @catch (id anException) {\
778 -[self failWithException:[NSException failureInRaise:[NSString stringWithFormat: @"!(%s) ", #expr] \ 781 +[self failWithException:[NSException ghu_failureInRaise:[NSString stringWithFormat: @"!(%s) ", #expr] \
779 exception:anException \ 782 exception:anException \
780 inFile:[NSString stringWithUTF8String:__FILE__] \ 783 inFile:[NSString stringWithUTF8String:__FILE__] \
781 atLine:__LINE__ \ 784 atLine:__LINE__ \
@@ -798,7 +801,7 @@ do { \ @@ -798,7 +801,7 @@ do { \
798 @catch (id anException) { \ 801 @catch (id anException) { \
799 continue; \ 802 continue; \
800 }\ 803 }\
801 -[self failWithException:[NSException failureInRaise: [NSString stringWithUTF8String:#expr] \ 804 +[self failWithException:[NSException ghu_failureInRaise: [NSString stringWithUTF8String:#expr] \
802 exception: nil \ 805 exception: nil \
803 inFile: [NSString stringWithUTF8String:__FILE__] \ 806 inFile: [NSString stringWithUTF8String:__FILE__] \
804 atLine: __LINE__ \ 807 atLine: __LINE__ \
@@ -824,7 +827,7 @@ continue; \ @@ -824,7 +827,7 @@ continue; \
824 }\ 827 }\
825 @catch (id anException) {\ 828 @catch (id anException) {\
826 NSString *_descrip = GHComposeString(@"(Expected exception: %@) %@", NSStringFromClass([specificException class]), description);\ 829 NSString *_descrip = GHComposeString(@"(Expected exception: %@) %@", NSStringFromClass([specificException class]), description);\
827 -[self failWithException:[NSException failureInRaise: [NSString stringWithUTF8String:#expr] \ 830 +[self failWithException:[NSException ghu_failureInRaise: [NSString stringWithUTF8String:#expr] \
828 exception: anException \ 831 exception: anException \
829 inFile: [NSString stringWithUTF8String:__FILE__] \ 832 inFile: [NSString stringWithUTF8String:__FILE__] \
830 atLine: __LINE__ \ 833 atLine: __LINE__ \
@@ -832,7 +835,7 @@ withDescription: GHComposeString(_descrip, ##__VA_ARGS__)]]; \ @@ -832,7 +835,7 @@ withDescription: GHComposeString(_descrip, ##__VA_ARGS__)]]; \
832 continue; \ 835 continue; \
833 }\ 836 }\
834 NSString *_descrip = GHComposeString(@"(Expected exception: %@) %@", NSStringFromClass([specificException class]), description);\ 837 NSString *_descrip = GHComposeString(@"(Expected exception: %@) %@", NSStringFromClass([specificException class]), description);\
835 -[self failWithException:[NSException failureInRaise: [NSString stringWithUTF8String:#expr] \ 838 +[self failWithException:[NSException ghu_failureInRaise: [NSString stringWithUTF8String:#expr] \
836 exception: nil \ 839 exception: nil \
837 inFile: [NSString stringWithUTF8String:__FILE__] \ 840 inFile: [NSString stringWithUTF8String:__FILE__] \
838 atLine: __LINE__ \ 841 atLine: __LINE__ \
@@ -861,7 +864,7 @@ do { \ @@ -861,7 +864,7 @@ do { \
861 if ([aName isEqualToString: [anException name]]) continue; \ 864 if ([aName isEqualToString: [anException name]]) continue; \
862 NSString *_descrip = GHComposeString(@"(Expected exception: %@ (name: %@)) %@", NSStringFromClass([specificException class]), aName, description);\ 865 NSString *_descrip = GHComposeString(@"(Expected exception: %@ (name: %@)) %@", NSStringFromClass([specificException class]), aName, description);\
863 [self failWithException: \ 866 [self failWithException: \
864 -[NSException failureInRaise: [NSString stringWithUTF8String:#expr] \ 867 +[NSException ghu_failureInRaise: [NSString stringWithUTF8String:#expr] \
865 exception: anException \ 868 exception: anException \
866 inFile: [NSString stringWithUTF8String:__FILE__] \ 869 inFile: [NSString stringWithUTF8String:__FILE__] \
867 atLine: __LINE__ \ 870 atLine: __LINE__ \
@@ -871,7 +874,7 @@ continue; \ @@ -871,7 +874,7 @@ continue; \
871 @catch (id anException) {\ 874 @catch (id anException) {\
872 NSString *_descrip = GHComposeString(@"(Expected exception: %@) %@", NSStringFromClass([specificException class]), description);\ 875 NSString *_descrip = GHComposeString(@"(Expected exception: %@) %@", NSStringFromClass([specificException class]), description);\
873 [self failWithException: \ 876 [self failWithException: \
874 -[NSException failureInRaise: [NSString stringWithUTF8String:#expr] \ 877 +[NSException ghu_failureInRaise: [NSString stringWithUTF8String:#expr] \
875 exception: anException \ 878 exception: anException \
876 inFile: [NSString stringWithUTF8String:__FILE__] \ 879 inFile: [NSString stringWithUTF8String:__FILE__] \
877 atLine: __LINE__ \ 880 atLine: __LINE__ \
@@ -880,7 +883,7 @@ continue; \ @@ -880,7 +883,7 @@ continue; \
880 }\ 883 }\
881 NSString *_descrip = GHComposeString(@"(Expected exception: %@) %@", NSStringFromClass([specificException class]), description);\ 884 NSString *_descrip = GHComposeString(@"(Expected exception: %@) %@", NSStringFromClass([specificException class]), description);\
882 [self failWithException: \ 885 [self failWithException: \
883 -[NSException failureInRaise: [NSString stringWithUTF8String:#expr] \ 886 +[NSException ghu_failureInRaise: [NSString stringWithUTF8String:#expr] \
884 exception: nil \ 887 exception: nil \
885 inFile: [NSString stringWithUTF8String:__FILE__] \ 888 inFile: [NSString stringWithUTF8String:__FILE__] \
886 atLine: __LINE__ \ 889 atLine: __LINE__ \
@@ -900,7 +903,7 @@ do { \ @@ -900,7 +903,7 @@ do { \
900 (expr);\ 903 (expr);\
901 } \ 904 } \
902 @catch (id anException) { \ 905 @catch (id anException) { \
903 -[self failWithException:[NSException failureInRaise: [NSString stringWithUTF8String:#expr] \ 906 +[self failWithException:[NSException ghu_failureInRaise: [NSString stringWithUTF8String:#expr] \
904 exception: anException \ 907 exception: anException \
905 inFile: [NSString stringWithUTF8String:__FILE__] \ 908 inFile: [NSString stringWithUTF8String:__FILE__] \
906 atLine: __LINE__ \ 909 atLine: __LINE__ \
@@ -923,7 +926,7 @@ do { \ @@ -923,7 +926,7 @@ do { \
923 (expr);\ 926 (expr);\
924 } \ 927 } \
925 @catch (specificException *anException) { \ 928 @catch (specificException *anException) { \
926 -[self failWithException:[NSException failureInRaise: [NSString stringWithUTF8String:#expr] \ 929 +[self failWithException:[NSException ghu_failureInRaise: [NSString stringWithUTF8String:#expr] \
927 exception: anException \ 930 exception: anException \
928 inFile: [NSString stringWithUTF8String:__FILE__] \ 931 inFile: [NSString stringWithUTF8String:__FILE__] \
929 atLine: __LINE__ \ 932 atLine: __LINE__ \
@@ -956,7 +959,7 @@ do { \ @@ -956,7 +959,7 @@ do { \
956 if ([aName isEqualToString: [anException name]]) { \ 959 if ([aName isEqualToString: [anException name]]) { \
957 NSString *_descrip = GHComposeString(@"(Expected exception: %@ (name: %@)) %@", NSStringFromClass([specificException class]), aName, description);\ 960 NSString *_descrip = GHComposeString(@"(Expected exception: %@ (name: %@)) %@", NSStringFromClass([specificException class]), aName, description);\
958 [self failWithException: \ 961 [self failWithException: \
959 -[NSException failureInRaise: [NSString stringWithUTF8String:#expr] \ 962 +[NSException ghu_failureInRaise: [NSString stringWithUTF8String:#expr] \
960 exception: anException \ 963 exception: anException \
961 inFile: [NSString stringWithUTF8String:__FILE__] \ 964 inFile: [NSString stringWithUTF8String:__FILE__] \
962 atLine: __LINE__ \ 965 atLine: __LINE__ \
@@ -971,30 +974,30 @@ continue; \ @@ -971,30 +974,30 @@ continue; \
971 974
972 975
973 @interface NSException (GHTestMacros_GTMSenTestAdditions) 976 @interface NSException (GHTestMacros_GTMSenTestAdditions)
974 -+ (NSException *)failureInFile:(NSString *)filename 977 ++ (NSException *)ghu_failureInFile:(NSString *)filename
975 atLine:(int)lineNumber 978 atLine:(int)lineNumber
976 withDescription:(NSString *)formatString, ...; 979 withDescription:(NSString *)formatString, ...;
977 -+ (NSException *)failureInCondition:(NSString *)condition 980 ++ (NSException *)ghu_failureInCondition:(NSString *)condition
978 isTrue:(BOOL)isTrue 981 isTrue:(BOOL)isTrue
979 inFile:(NSString *)filename 982 inFile:(NSString *)filename
980 atLine:(int)lineNumber 983 atLine:(int)lineNumber
981 withDescription:(NSString *)formatString, ...; 984 withDescription:(NSString *)formatString, ...;
982 -+ (NSException *)failureInEqualityBetweenObject:(id)left 985 ++ (NSException *)ghu_failureInEqualityBetweenObject:(id)left
983 andObject:(id)right 986 andObject:(id)right
984 inFile:(NSString *)filename 987 inFile:(NSString *)filename
985 atLine:(int)lineNumber 988 atLine:(int)lineNumber
986 withDescription:(NSString *)formatString, ...; 989 withDescription:(NSString *)formatString, ...;
987 -+ (NSException *)failureInEqualityBetweenValue:(NSValue *)left 990 ++ (NSException *)ghu_failureInEqualityBetweenValue:(NSValue *)left
988 andValue:(NSValue *)right 991 andValue:(NSValue *)right
989 withAccuracy:(NSValue *)accuracy 992 withAccuracy:(NSValue *)accuracy
990 inFile:(NSString *)filename 993 inFile:(NSString *)filename
991 atLine:(int) ineNumber 994 atLine:(int) ineNumber
992 withDescription:(NSString *)formatString, ...; 995 withDescription:(NSString *)formatString, ...;
993 -+ (NSException *)failureInRaise:(NSString *)expression 996 ++ (NSException *)ghu_failureInRaise:(NSString *)expression
994 inFile:(NSString *)filename 997 inFile:(NSString *)filename
995 atLine:(int)lineNumber 998 atLine:(int)lineNumber
996 withDescription:(NSString *)formatString, ...; 999 withDescription:(NSString *)formatString, ...;
997 -+ (NSException *)failureInRaise:(NSString *)expression 1000 ++ (NSException *)ghu_failureInRaise:(NSString *)expression
998 exception:(NSException *)exception 1001 exception:(NSException *)exception
999 inFile:(NSString *)filename 1002 inFile:(NSString *)filename
1000 atLine:(int)lineNumber 1003 atLine:(int)lineNumber
@@ -7,9 +7,9 @@ @@ -7,9 +7,9 @@
7 // 7 //
8 8
9 #import "GHTestViewModel.h" 9 #import "GHTestViewModel.h"
10 -  
11 @class GHTestOutlineViewModel; 10 @class GHTestOutlineViewModel;
12 11
  12 +
13 @protocol GHTestOutlineViewModelDelegate <NSObject> 13 @protocol GHTestOutlineViewModelDelegate <NSObject>
14 - (void)testOutlineViewModelDidChangeSelection:(GHTestOutlineViewModel *)testOutlineViewModel; 14 - (void)testOutlineViewModelDidChangeSelection:(GHTestOutlineViewModel *)testOutlineViewModel;
15 @end 15 @end
@@ -143,6 +143,11 @@ @@ -143,6 +143,11 @@
143 143
144 - (void)cancel; 144 - (void)cancel;
145 145
  146 +/*!
  147 + Write message to console.
  148 + */
  149 +- (void)log:(NSString *)message;
  150 +
146 @end 151 @end
147 152
148 153
@@ -85,6 +85,13 @@ extern NSString *GHUnitTest; @@ -85,6 +85,13 @@ extern NSString *GHUnitTest;
85 + (GHTestSuite *)suiteWithTestFilter:(NSString *)testFilter; 85 + (GHTestSuite *)suiteWithTestFilter:(NSString *)testFilter;
86 86
87 /*! 87 /*!
  88 + Create suite of tests that start with prefix.
  89 + @param prefix If test case class starts with the prefix; If nil or empty string, returns all tests
  90 + @param options Compare options
  91 + */
  92 ++ (GHTestSuite *)suiteWithPrefix:(NSString *)prefix options:(NSStringCompareOptions)options;
  93 +
  94 +/*!
88 Suite for a single test/method. 95 Suite for a single test/method.
89 @param testCaseClass 96 @param testCaseClass
90 @param method 97 @param method
@@ -80,4 +80,6 @@ @@ -80,4 +80,6 @@
80 - (void)loadDefaults; 80 - (void)loadDefaults;
81 - (void)saveDefaults; 81 - (void)saveDefaults;
82 82
  83 +- (BOOL)isShowingDetails;
  84 +
83 @end 85 @end
@@ -110,30 +110,33 @@ @@ -110,30 +110,33 @@
110 NSMutableArray */* of GHTestNode*/children_; 110 NSMutableArray */* of GHTestNode*/children_;
111 111
112 id<GHTestNodeDelegate> delegate_; 112 id<GHTestNodeDelegate> delegate_;
113 -}  
114 113
  114 +}
115 115
116 116
117 -@property (readonly, nonatomic) NSString *identifier;  
118 -@property (readonly, nonatomic) NSString *name;  
119 @property (readonly, nonatomic) NSArray */* of GHTestNode*/children; 117 @property (readonly, nonatomic) NSArray */* of GHTestNode*/children;
120 @property (readonly, nonatomic) id<GHTest> test; 118 @property (readonly, nonatomic) id<GHTest> test;
121 -@property (readonly, nonatomic) GHTestStatus status;  
122 -@property (readonly, nonatomic) NSString *statusString;  
123 -@property (readonly, nonatomic) NSString *stackTrace;  
124 -@property (readonly, nonatomic) NSString *log;  
125 -@property (readonly, nonatomic) BOOL isRunning;  
126 -@property (readonly, nonatomic) BOOL isEnded;  
127 -@property (readonly, nonatomic) BOOL isGroupTest; // YES if test has "sub tests"  
128 -  
129 -@property (assign, nonatomic, getter=isSelected) BOOL selected;  
130 @property (assign, nonatomic) id<GHTestNodeDelegate> delegate; 119 @property (assign, nonatomic) id<GHTestNodeDelegate> delegate;
131 120
132 - (id)initWithTest:(id<GHTest>)test children:(NSArray */*of GHTestNode */)children source:(GHTestViewModel *)source; 121 - (id)initWithTest:(id<GHTest>)test children:(NSArray */*of GHTestNode */)children source:(GHTestViewModel *)source;
133 + (GHTestNode *)nodeWithTest:(id<GHTest>)test children:(NSArray */*of GHTestNode */)children source:(GHTestViewModel *)source; 122 + (GHTestNode *)nodeWithTest:(id<GHTest>)test children:(NSArray */*of GHTestNode */)children source:(GHTestViewModel *)source;
134 123
  124 +- (NSString *)identifier;
  125 +- (NSString *)name;
135 - (NSString *)nameWithStatus; 126 - (NSString *)nameWithStatus;
136 127
  128 +- (GHTestStatus)status;
  129 +- (NSString *)statusString;
  130 +- (NSString *)stackTrace;
  131 +- (NSString *)log;
  132 +- (BOOL)isRunning;
  133 +- (BOOL)isDisabled;
  134 +- (BOOL)isEnded;
  135 +- (BOOL)isGroupTest; // YES if test has "sub tests"
  136 +
  137 +- (BOOL)isSelected;
  138 +- (void)setSelected:(BOOL)selected;
  139 +
137 - (BOOL)hasChildren; 140 - (BOOL)hasChildren;
138 - (BOOL)failed; 141 - (BOOL)failed;
139 142
@@ -35,4 +35,6 @@ @@ -35,4 +35,6 @@
35 35
36 @property (retain, nonatomic) IBOutlet GHTestViewController *viewController; 36 @property (retain, nonatomic) IBOutlet GHTestViewController *viewController;
37 37
  38 +- (IBAction)runTests:(id)sender;
  39 +- (IBAction)edit:(id)sender;
38 @end 40 @end
@@ -46,6 +46,8 @@ @@ -46,6 +46,8 @@
46 // the License. 46 // the License.
47 // 47 //
48 48
  49 +extern NSString *GHUStackTraceFromException(NSException *e);
  50 +
49 // GTM_BEGIN 51 // GTM_BEGIN
50 BOOL isTestFixtureOfClass(Class aClass, Class testCaseClass); 52 BOOL isTestFixtureOfClass(Class aClass, Class testCaseClass);
51 // GTM_END 53 // GTM_END
@@ -102,3 +104,6 @@ BOOL isTestFixtureOfClass(Class aClass, Class testCaseClass); @@ -102,3 +104,6 @@ BOOL isTestFixtureOfClass(Class aClass, Class testCaseClass);
102 104
103 @end 105 @end
104 106
  107 +@protocol GHSenTestCase
  108 +- (void)raiseAfterFailure;
  109 +@end
@@ -34,7 +34,9 @@ @@ -34,7 +34,9 @@
34 #import "GHTestRunner.h" 34 #import "GHTestRunner.h"
35 35
36 #ifdef DEBUG 36 #ifdef DEBUG
37 -#define GHUDebug(fmt, ...) NSLog(fmt, ##__VA_ARGS__) 37 +#define GHUDebug(fmt, ...) do { \
  38 +fputs([[[NSString stringWithFormat:fmt, ##__VA_ARGS__] stringByAppendingString:@"\n"] UTF8String], stdout); \
  39 +} while(0)
38 #else 40 #else
39 #define GHUDebug(fmt, ...) do {} while(0) 41 #define GHUDebug(fmt, ...) do {} while(0)
40 #endif 42 #endif
  1 +//
  2 +// GTMStackTrace.h
  3 +//
  4 +// Copyright 2007-2008 Google Inc.
  5 +//
  6 +// Licensed under the Apache License, Version 2.0 (the "License"); you may not
  7 +// use this file except in compliance with the License. You may obtain a copy
  8 +// of the License at
  9 +//
  10 +// http://www.apache.org/licenses/LICENSE-2.0
  11 +//
  12 +// Unless required by applicable law or agreed to in writing, software
  13 +// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  14 +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  15 +// License for the specific language governing permissions and limitations under
  16 +// the License.
  17 +//
  18 +
  19 +#include <CoreFoundation/CoreFoundation.h>
  20 +#import "GTMDefines.h"
  21 +
  22 +#ifdef __cplusplus
  23 +extern "C" {
  24 +#endif
  25 +
  26 +struct GHU_GTMAddressDescriptor {
  27 + const void *address; // address
  28 + const char *symbol; // nearest symbol to address
  29 + const char *class_name; // if it is an obj-c method, the method's class
  30 + BOOL is_class_method; // if it is an obj-c method, type of method
  31 + const char *filename; // file that the method came from.
  32 +};
  33 +
  34 +// Returns a string containing a nicely formatted stack trace.
  35 +//
  36 +// This function gets the stack trace for the current thread. It will
  37 +// be from the caller of GTMStackTrace upwards to the top the calling stack.
  38 +// Typically this function will be used along with some logging,
  39 +// as in the following:
  40 +//
  41 +// MyAppLogger(@"Should never get here:\n%@", GTMStackTrace());
  42 +//
  43 +// Here is a sample stack trace returned from this function:
  44 +//
  45 +// #0 0x00002d92 D () [/Users/me/./StackLog]
  46 +// #1 0x00002e45 C () [/Users/me/./StackLog]
  47 +// #2 0x00002e53 B () [/Users/me/./StackLog]
  48 +// #3 0x00002e61 A () [/Users/me/./StackLog]
  49 +// #4 0x00002e6f main () [/Users/me/./StackLog]
  50 +// #5 0x00002692 tart () [/Users/me/./StackLog]
  51 +// #6 0x000025b9 tart () [/Users/me/./StackLog]
  52 +//
  53 +
  54 +NSString *GHU_GTMStackTrace(void);
  55 +
  56 +#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
  57 +// Returns a string containing a nicely formatted stack trace from the
  58 +// exception. Only available on 10.5 or later, uses
  59 +// -[NSException callStackReturnAddresses].
  60 +//
  61 +NSString *GHU_GTMStackTraceFromException(NSException *e);
  62 +#endif
  63 +
  64 +#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
  65 +// Returns an array of program counters from the current thread's stack.
  66 +// *** You should probably use GTMStackTrace() instead of this function ***
  67 +// However, if you actually want all the PCs in "void *" form, then this
  68 +// funtion is more convenient. This will include PCs of GTMStaceTrace and
  69 +// its inner utility functions that you may want to strip out.
  70 +//
  71 +// You can use +[NSThread callStackReturnAddresses] in 10.5 or later.
  72 +//
  73 +// Args:
  74 +// outPcs - an array of "void *" pointers to the program counters found on the
  75 +// current thread's stack.
  76 +// count - the number of entries in the outPcs array
  77 +//
  78 +// Returns:
  79 +// The number of program counters actually added to outPcs.
  80 +//
  81 +NSUInteger GHU_GTMGetStackProgramCounters(void *outPcs[], NSUInteger count);
  82 +#endif // MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
  83 +
  84 +// Returns an array of GTMAddressDescriptors from the current thread's stack.
  85 +// *** You should probably use GTMStackTrace() instead of this function ***
  86 +// However, if you actually want all the PCs with symbols, this is the way
  87 +// to get them. There is no memory allocations done, so no clean up is required
  88 +// except for the caller to free outDescs if they allocated it themselves.
  89 +// This will include PCs of GTMStaceTrace and its inner utility functions that
  90 +// you may want to strip out.
  91 +//
  92 +// Args:
  93 +// outDescs - an array of "struct GTMAddressDescriptor" pointers corresponding
  94 +// to the program counters found on the current thread's stack.
  95 +// count - the number of entries in the outDescs array
  96 +//
  97 +// Returns:
  98 +// The number of program counters actually added to outPcs.
  99 +//
  100 +NSUInteger GHU_GTMGetStackAddressDescriptors(struct GHU_GTMAddressDescriptor outDescs[],
  101 + NSUInteger count);
  102 +
  103 +#ifdef __cplusplus
  104 +}
  105 +#endif
  1 +//
  2 +// NSException+GHTestFailureExceptions.h
  3 +//
  4 +// Created by Johannes Rudolph on 23.09.09.
  5 +// Copyright 2009. All rights reserved.
  6 +//
  7 +// Permission is hereby granted, free of charge, to any person
  8 +// obtaining a copy of this software and associated documentation
  9 +// files (the "Software"), to deal in the Software without
  10 +// restriction, including without limitation the rights to use,
  11 +// copy, modify, merge, publish, distribute, sublicense, and/or sell
  12 +// copies of the Software, and to permit persons to whom the
  13 +// Software is furnished to do so, subject to the following
  14 +// conditions:
  15 +//
  16 +// The above copyright notice and this permission notice shall be
  17 +// included in all copies or substantial portions of the Software.
  18 +//
  19 +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  20 +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  21 +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  22 +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  23 +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  24 +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  25 +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  26 +// OTHER DEALINGS IN THE SOFTWARE.
  27 +//
  28 +
  29 +//
  30 +// Portions of this file fall under the following license, marked with:
  31 +// GTM_BEGIN : GTM_END
  32 +//
  33 +// Copyright 2008 Google Inc.
  34 +//
  35 +// Licensed under the Apache License, Version 2.0 (the "License"); you may not
  36 +// use this file except in compliance with the License. You may obtain a copy
  37 +// of the License at
  38 +//
  39 +// http://www.apache.org/licenses/LICENSE-2.0
  40 +//
  41 +// Unless required by applicable law or agreed to in writing, software
  42 +// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  43 +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  44 +// License for the specific language governing permissions and limitations under
  45 +// the License.
  46 +//
  47 +
  48 +// GTM_BEGIN
  49 +
  50 +#import <Foundation/Foundation.h>
  51 +
  52 +@interface NSException (GHUTestFailureExceptions)
  53 ++ (NSException *)ghu_failureInFile:(NSString *)filename
  54 + atLine:(int)lineNumber
  55 + withDescription:(NSString *)formatString, ...;
  56 ++ (NSException *)ghu_failureInCondition:(NSString *)condition
  57 + isTrue:(BOOL)isTrue
  58 + inFile:(NSString *)filename
  59 + atLine:(int)lineNumber
  60 + withDescription:(NSString *)formatString, ...;
  61 ++ (NSException *)ghu_failureInEqualityBetweenObject:(id)left
  62 + andObject:(id)right
  63 + inFile:(NSString *)filename
  64 + atLine:(int)lineNumber
  65 + withDescription:(NSString *)formatString, ...;
  66 ++ (NSException *)ghu_failureInEqualityBetweenValue:(NSValue *)left
  67 + andValue:(NSValue *)right
  68 + withAccuracy:(NSValue *)accuracy
  69 + inFile:(NSString *)filename
  70 + atLine:(int) ineNumber
  71 + withDescription:(NSString *)formatString, ...;
  72 ++ (NSException *)ghu_failureInRaise:(NSString *)expression
  73 + inFile:(NSString *)filename
  74 + atLine:(int)lineNumber
  75 + withDescription:(NSString *)formatString, ...;
  76 ++ (NSException *)ghu_failureInRaise:(NSString *)expression
  77 + exception:(NSException *)exception
  78 + inFile:(NSString *)filename
  79 + atLine:(int)lineNumber
  80 + withDescription:(NSString *)formatString, ...;
  81 +@end
  82 +
  83 +// GTM_END
  1 +//
  2 +// NSValue+GHValueFormatter.h
  3 +//
  4 +// Created by Johannes Rudolph on 23.9.2009.
  5 +// Copyright 2009. All rights reserved.
  6 +//
  7 +// Permission is hereby granted, free of charge, to any person
  8 +// obtaining a copy of this software and associated documentation
  9 +// files (the "Software"), to deal in the Software without
  10 +// restriction, including without limitation the rights to use,
  11 +// copy, modify, merge, publish, distribute, sublicense, and/or sell
  12 +// copies of the Software, and to permit persons to whom the
  13 +// Software is furnished to do so, subject to the following
  14 +// conditions:
  15 +//
  16 +// The above copyright notice and this permission notice shall be
  17 +// included in all copies or substantial portions of the Software.
  18 +//
  19 +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  20 +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  21 +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  22 +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  23 +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  24 +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  25 +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  26 +// OTHER DEALINGS IN THE SOFTWARE.
  27 +//
  28 +
  29 +//
  30 +// Portions of this file fall under the following license, marked with
  31 +// SENTE_BEGIN - SENTE_END
  32 +//
  33 +// Copyright (c) 1997-2005, Sen:te (Sente SA). All rights reserved.
  34 +//
  35 +// Use of this source code is governed by the following license:
  36 +//
  37 +// Redistribution and use in source and binary forms, with or without modification,
  38 +// are permitted provided that the following conditions are met:
  39 +//
  40 +// (1) Redistributions of source code must retain the above copyright notice,
  41 +// this list of conditions and the following disclaimer.
  42 +//
  43 +// (2) Redistributions in binary form must reproduce the above copyright notice,
  44 +// this list of conditions and the following disclaimer in the documentation
  45 +// and/or other materials provided with the distribution.
  46 +//
  47 +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
  48 +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  49 +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  50 +// IN NO EVENT SHALL Sente SA OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  51 +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
  52 +// OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  53 +// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  54 +// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  55 +// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  56 +//
  57 +// Note: this license is equivalent to the FreeBSD license.
  58 +//
  59 +// This notice may not be removed from this file.
  60 +
  61 +#import <Foundation/Foundation.h>
  62 +
  63 +// SENTE_BEGIN
  64 +@interface NSValue (GHValueFormatter)
  65 +- (NSString *)ghu_contentDescription;
  66 +@end
  67 +// SENTE_END
@@ -17,6 +17,6 @@ @@ -17,6 +17,6 @@
17 <key>CFBundleSignature</key> 17 <key>CFBundleSignature</key>
18 <string>GABE</string> 18 <string>GABE</string>
19 <key>CFBundleVersion</key> 19 <key>CFBundleVersion</key>
20 - <string>0.4.4</string> 20 + <string>0.4.14</string>
21 </dict> 21 </dict>
22 </plist> 22 </plist>
@@ -63,7 +63,7 @@ typedef struct { @@ -63,7 +63,7 @@ typedef struct {
63 */ 63 */
64 extern GHTestStats GHTestStatsMake(NSInteger succeedCount, NSInteger failureCount, NSInteger cancelCount, NSInteger testCount); 64 extern GHTestStats GHTestStatsMake(NSInteger succeedCount, NSInteger failureCount, NSInteger cancelCount, NSInteger testCount);
65 65
66 -const GHTestStats GHTestStatsEmpty; 66 +extern const GHTestStats GHTestStatsEmpty;
67 67
68 extern NSString *NSStringFromGHTestStats(GHTestStats stats); 68 extern NSString *NSStringFromGHTestStats(GHTestStats stats);
69 69
@@ -83,7 +83,7 @@ @@ -83,7 +83,7 @@
83 - (void)testB { } 83 - (void)testB { }
84 84
85 // Override any exceptions; By default exceptions are raised, causing a test failure 85 // Override any exceptions; By default exceptions are raised, causing a test failure
86 - - (void)failWithException:(NSException*)exception { } 86 + - (void)failWithException:(NSException *)exception { }
87 87
88 @end 88 @end
89 @endcode 89 @endcode
@@ -77,6 +77,9 @@ @@ -77,6 +77,9 @@
77 // the License. 77 // the License.
78 // 78 //
79 79
  80 +#import "NSException+GHTestFailureExceptions.h"
  81 +#import "NSValue+GHValueFormatter.h"
  82 +
80 // GTM_BEGIN 83 // GTM_BEGIN
81 84
82 extern NSString *const GHTestFilenameKey; 85 extern NSString *const GHTestFilenameKey;
@@ -100,13 +103,13 @@ NSString *_expression = [NSString stringWithFormat:@"Expected noErr, got %ld for @@ -100,13 +103,13 @@ NSString *_expression = [NSString stringWithFormat:@"Expected noErr, got %ld for
100 if (description) { \ 103 if (description) { \
101 _expression = [NSString stringWithFormat:@"%@: %@", _expression, GHComposeString(description, ##__VA_ARGS__)]; \ 104 _expression = [NSString stringWithFormat:@"%@: %@", _expression, GHComposeString(description, ##__VA_ARGS__)]; \
102 } \ 105 } \
103 -[self failWithException:[NSException failureInFile:[NSString stringWithUTF8String:__FILE__] \ 106 +[self failWithException:[NSException ghu_failureInFile:[NSString stringWithUTF8String:__FILE__] \
104 atLine:__LINE__ \ 107 atLine:__LINE__ \
105 withDescription:_expression]]; \ 108 withDescription:_expression]]; \
106 } \ 109 } \
107 }\ 110 }\
108 @catch (id anException) {\ 111 @catch (id anException) {\
109 -[self failWithException:[NSException failureInRaise:[NSString stringWithFormat:@"(%s) == noErr fails", #a1] \ 112 +[self failWithException:[NSException ghu_failureInRaise:[NSString stringWithFormat:@"(%s) == noErr fails", #a1] \
110 exception:anException \ 113 exception:anException \
111 inFile:[NSString stringWithUTF8String:__FILE__] \ 114 inFile:[NSString stringWithUTF8String:__FILE__] \
112 atLine:__LINE__ \ 115 atLine:__LINE__ \
@@ -131,13 +134,13 @@ NSString *_expression = [NSString stringWithFormat:@"Expected %s(%ld) but got %l @@ -131,13 +134,13 @@ NSString *_expression = [NSString stringWithFormat:@"Expected %s(%ld) but got %l
131 if (description) { \ 134 if (description) { \
132 _expression = [NSString stringWithFormat:@"%@: %@", _expression, GHComposeString(description, ##__VA_ARGS__)]; \ 135 _expression = [NSString stringWithFormat:@"%@: %@", _expression, GHComposeString(description, ##__VA_ARGS__)]; \
133 } \ 136 } \
134 -[self failWithException:[NSException failureInFile:[NSString stringWithUTF8String:__FILE__] \ 137 +[self failWithException:[NSException ghu_failureInFile:[NSString stringWithUTF8String:__FILE__] \
135 atLine:__LINE__ \ 138 atLine:__LINE__ \
136 withDescription:_expression]]; \ 139 withDescription:_expression]]; \
137 } \ 140 } \
138 }\ 141 }\
139 @catch (id anException) {\ 142 @catch (id anException) {\
140 -[self failWithException:[NSException failureInRaise:[NSString stringWithFormat:@"(%s) == (%s) fails", #a1, #a2] \ 143 +[self failWithException:[NSException ghu_failureInRaise:[NSString stringWithFormat:@"(%s) == (%s) fails", #a1, #a2] \
141 exception:anException \ 144 exception:anException \
142 inFile:[NSString stringWithUTF8String:__FILE__] \ 145 inFile:[NSString stringWithUTF8String:__FILE__] \
143 atLine:__LINE__ \ 146 atLine:__LINE__ \
@@ -161,13 +164,13 @@ NSString *_expression = [NSString stringWithFormat:@"(%s) != NULL", #a1]; \ @@ -161,13 +164,13 @@ NSString *_expression = [NSString stringWithFormat:@"(%s) != NULL", #a1]; \
161 if (description) { \ 164 if (description) { \
162 _expression = [NSString stringWithFormat:@"%@: %@", _expression, GHComposeString(description, ##__VA_ARGS__)]; \ 165 _expression = [NSString stringWithFormat:@"%@: %@", _expression, GHComposeString(description, ##__VA_ARGS__)]; \
163 } \ 166 } \
164 -[self failWithException:[NSException failureInFile:[NSString stringWithUTF8String:__FILE__] \ 167 +[self failWithException:[NSException ghu_failureInFile:[NSString stringWithUTF8String:__FILE__] \
165 atLine:__LINE__ \ 168 atLine:__LINE__ \
166 withDescription:_expression]]; \ 169 withDescription:_expression]]; \
167 } \ 170 } \
168 }\ 171 }\
169 @catch (id anException) {\ 172 @catch (id anException) {\
170 -[self failWithException:[NSException failureInRaise:[NSString stringWithFormat:@"(%s) != NULL fails", #a1] \ 173 +[self failWithException:[NSException ghu_failureInRaise:[NSString stringWithFormat:@"(%s) != NULL fails", #a1] \
171 exception:anException \ 174 exception:anException \
172 inFile:[NSString stringWithUTF8String:__FILE__] \ 175 inFile:[NSString stringWithUTF8String:__FILE__] \
173 atLine:__LINE__ \ 176 atLine:__LINE__ \
@@ -190,13 +193,13 @@ NSString *_expression = [NSString stringWithFormat:@"(%s) == NULL", #a1]; \ @@ -190,13 +193,13 @@ NSString *_expression = [NSString stringWithFormat:@"(%s) == NULL", #a1]; \
190 if (description) { \ 193 if (description) { \
191 _expression = [NSString stringWithFormat:@"%@: %@", _expression, GHComposeString(description, ##__VA_ARGS__)]; \ 194 _expression = [NSString stringWithFormat:@"%@: %@", _expression, GHComposeString(description, ##__VA_ARGS__)]; \
192 } \ 195 } \
193 -[self failWithException:[NSException failureInFile:[NSString stringWithUTF8String:__FILE__] \ 196 +[self failWithException:[NSException ghu_failureInFile:[NSString stringWithUTF8String:__FILE__] \
194 atLine:__LINE__ \ 197 atLine:__LINE__ \
195 withDescription:_expression]]; \ 198 withDescription:_expression]]; \
196 } \ 199 } \
197 }\ 200 }\
198 @catch (id anException) {\ 201 @catch (id anException) {\
199 -[self failWithException:[NSException failureInRaise:[NSString stringWithFormat:@"(%s) == NULL fails", #a1] \ 202 +[self failWithException:[NSException ghu_failureInRaise:[NSString stringWithFormat:@"(%s) == NULL fails", #a1] \
200 exception:anException \ 203 exception:anException \
201 inFile:[NSString stringWithUTF8String:__FILE__] \ 204 inFile:[NSString stringWithUTF8String:__FILE__] \
202 atLine:__LINE__ \ 205 atLine:__LINE__ \
@@ -216,7 +219,7 @@ withDescription:GHComposeString(description, ##__VA_ARGS__)]]; \ @@ -216,7 +219,7 @@ withDescription:GHComposeString(description, ##__VA_ARGS__)]]; \
216 do { \ 219 do { \
217 @try {\ 220 @try {\
218 if (@encode(__typeof__(a1)) != @encode(__typeof__(a2))) { \ 221 if (@encode(__typeof__(a1)) != @encode(__typeof__(a2))) { \
219 -[self failWithException:[NSException failureInFile:[NSString stringWithUTF8String:__FILE__] \ 222 +[self failWithException:[NSException ghu_failureInFile:[NSString stringWithUTF8String:__FILE__] \
220 atLine:__LINE__ \ 223 atLine:__LINE__ \
221 withDescription:[@"Type mismatch -- " stringByAppendingString:GHComposeString(description, ##__VA_ARGS__)]]]; \ 224 withDescription:[@"Type mismatch -- " stringByAppendingString:GHComposeString(description, ##__VA_ARGS__)]]]; \
222 } else { \ 225 } else { \
@@ -229,14 +232,14 @@ NSString *_expression = [NSString stringWithFormat:@"(%s) != (%s)", #a1, #a2]; \ @@ -229,14 +232,14 @@ NSString *_expression = [NSString stringWithFormat:@"(%s) != (%s)", #a1, #a2]; \
229 if (description) { \ 232 if (description) { \
230 _expression = [NSString stringWithFormat:@"%@: %@", _expression, GHComposeString(description, ##__VA_ARGS__)]; \ 233 _expression = [NSString stringWithFormat:@"%@: %@", _expression, GHComposeString(description, ##__VA_ARGS__)]; \
231 } \ 234 } \
232 -[self failWithException:[NSException failureInFile:[NSString stringWithUTF8String:__FILE__] \ 235 +[self failWithException:[NSException ghu_failureInFile:[NSString stringWithUTF8String:__FILE__] \
233 atLine:__LINE__ \ 236 atLine:__LINE__ \
234 withDescription:_expression]]; \ 237 withDescription:_expression]]; \
235 } \ 238 } \
236 } \ 239 } \
237 } \ 240 } \
238 @catch (id anException) {\ 241 @catch (id anException) {\
239 -[self failWithException:[NSException failureInRaise:[NSString stringWithFormat:@"(%s) != (%s)", #a1, #a2] \ 242 +[self failWithException:[NSException ghu_failureInRaise:[NSString stringWithFormat:@"(%s) != (%s)", #a1, #a2] \
240 exception:anException \ 243 exception:anException \
241 inFile:[NSString stringWithUTF8String:__FILE__] \ 244 inFile:[NSString stringWithUTF8String:__FILE__] \
242 atLine:__LINE__ \ 245 atLine:__LINE__ \
@@ -263,12 +266,12 @@ NSString *_expression = [NSString stringWithFormat:@"%s('%@') != %s('%@')", #a1, @@ -263,12 +266,12 @@ NSString *_expression = [NSString stringWithFormat:@"%s('%@') != %s('%@')", #a1,
263 if (desc) { \ 266 if (desc) { \
264 _expression = [NSString stringWithFormat:@"%@: %@", _expression, GHComposeString(desc, ##__VA_ARGS__)]; \ 267 _expression = [NSString stringWithFormat:@"%@: %@", _expression, GHComposeString(desc, ##__VA_ARGS__)]; \
265 } \ 268 } \
266 -[self failWithException:[NSException failureInFile:[NSString stringWithUTF8String:__FILE__] \ 269 +[self failWithException:[NSException ghu_failureInFile:[NSString stringWithUTF8String:__FILE__] \
267 atLine:__LINE__ \ 270 atLine:__LINE__ \
268 withDescription:_expression]]; \ 271 withDescription:_expression]]; \
269 }\ 272 }\
270 @catch (id anException) {\ 273 @catch (id anException) {\
271 -[self failWithException:[NSException failureInRaise:[NSString stringWithFormat: @"(%s) != (%s)", #a1, #a2] \ 274 +[self failWithException:[NSException ghu_failureInRaise:[NSString stringWithFormat: @"(%s) != (%s)", #a1, #a2] \
272 exception:anException \ 275 exception:anException \
273 inFile:[NSString stringWithUTF8String:__FILE__] \ 276 inFile:[NSString stringWithUTF8String:__FILE__] \
274 atLine:__LINE__ \ 277 atLine:__LINE__ \
@@ -288,7 +291,7 @@ withDescription:GHComposeString(desc, ##__VA_ARGS__)]]; \ @@ -288,7 +291,7 @@ withDescription:GHComposeString(desc, ##__VA_ARGS__)]]; \
288 do { \ 291 do { \
289 @try {\ 292 @try {\
290 if (@encode(__typeof__(a1)) != @encode(__typeof__(a2))) { \ 293 if (@encode(__typeof__(a1)) != @encode(__typeof__(a2))) { \
291 -[self failWithException:[NSException failureInFile:[NSString stringWithUTF8String:__FILE__] \ 294 +[self failWithException:[NSException ghu_failureInFile:[NSString stringWithUTF8String:__FILE__] \
292 atLine:__LINE__ \ 295 atLine:__LINE__ \
293 withDescription:[@"Type mismatch -- " stringByAppendingString:GHComposeString(description, ##__VA_ARGS__)]]]; \ 296 withDescription:[@"Type mismatch -- " stringByAppendingString:GHComposeString(description, ##__VA_ARGS__)]]]; \
294 } else { \ 297 } else { \
@@ -301,7 +304,7 @@ NSString *_expression = [NSString stringWithFormat:@"%s (%lg) %s %s (%lg)", #a1, @@ -301,7 +304,7 @@ NSString *_expression = [NSString stringWithFormat:@"%s (%lg) %s %s (%lg)", #a1,
301 if (description) { \ 304 if (description) { \
302 _expression = [NSString stringWithFormat:@"%@: %@", _expression, GHComposeString(description, ##__VA_ARGS__)]; \ 305 _expression = [NSString stringWithFormat:@"%@: %@", _expression, GHComposeString(description, ##__VA_ARGS__)]; \
303 } \ 306 } \
304 -[self failWithException:[NSException failureInFile:[NSString stringWithUTF8String:__FILE__] \ 307 +[self failWithException:[NSException ghu_failureInFile:[NSString stringWithUTF8String:__FILE__] \
305 atLine:__LINE__ \ 308 atLine:__LINE__ \
306 withDescription:_expression]]; \ 309 withDescription:_expression]]; \
307 } \ 310 } \
@@ -309,7 +312,7 @@ withDescription:_expression]]; \ @@ -309,7 +312,7 @@ withDescription:_expression]]; \
309 } \ 312 } \
310 @catch (id anException) {\ 313 @catch (id anException) {\
311 [self failWithException:[NSException \ 314 [self failWithException:[NSException \
312 -failureInRaise:[NSString stringWithFormat:@"(%s) %s (%s)", #a1, #op, #a2] \ 315 +ghu_failureInRaise:[NSString stringWithFormat:@"(%s) %s (%s)", #a1, #op, #a2] \
313 exception:anException \ 316 exception:anException \
314 inFile:[NSString stringWithUTF8String:__FILE__] \ 317 inFile:[NSString stringWithUTF8String:__FILE__] \
315 atLine:__LINE__ \ 318 atLine:__LINE__ \
@@ -381,14 +384,14 @@ if (a1value == a2value) continue; \ @@ -381,14 +384,14 @@ if (a1value == a2value) continue; \
381 if ([a1value isKindOfClass:[NSString class]] && \ 384 if ([a1value isKindOfClass:[NSString class]] && \
382 [a2value isKindOfClass:[NSString class]] && \ 385 [a2value isKindOfClass:[NSString class]] && \
383 [a1value compare:a2value options:0] == NSOrderedSame) continue; \ 386 [a1value compare:a2value options:0] == NSOrderedSame) continue; \
384 -[self failWithException:[NSException failureInEqualityBetweenObject: a1value \ 387 +[self failWithException:[NSException ghu_failureInEqualityBetweenObject: a1value \
385 andObject: a2value \ 388 andObject: a2value \
386 inFile: [NSString stringWithUTF8String:__FILE__] \ 389 inFile: [NSString stringWithUTF8String:__FILE__] \
387 atLine: __LINE__ \ 390 atLine: __LINE__ \
388 withDescription: GHComposeString(description, ##__VA_ARGS__)]]; \ 391 withDescription: GHComposeString(description, ##__VA_ARGS__)]]; \
389 }\ 392 }\
390 @catch (id anException) {\ 393 @catch (id anException) {\
391 -[self failWithException:[NSException failureInRaise:[NSString stringWithFormat: @"(%s) == (%s)", #a1, #a2] \ 394 +[self failWithException:[NSException ghu_failureInRaise:[NSString stringWithFormat: @"(%s) == (%s)", #a1, #a2] \
392 exception:anException \ 395 exception:anException \
393 inFile:[NSString stringWithUTF8String:__FILE__] \ 396 inFile:[NSString stringWithUTF8String:__FILE__] \
394 atLine:__LINE__ \ 397 atLine:__LINE__ \
@@ -415,14 +418,14 @@ id a2value = (a2); \ @@ -415,14 +418,14 @@ id a2value = (a2); \
415 if ([a1value isKindOfClass:[NSString class]] && \ 418 if ([a1value isKindOfClass:[NSString class]] && \
416 [a2value isKindOfClass:[NSString class]] && \ 419 [a2value isKindOfClass:[NSString class]] && \
417 [a1value compare:a2value options:0] != NSOrderedSame) continue; \ 420 [a1value compare:a2value options:0] != NSOrderedSame) continue; \
418 -[self failWithException:[NSException failureInEqualityBetweenObject: a1value \ 421 +[self failWithException:[NSException ghu_failureInEqualityBetweenObject: a1value \
419 andObject: a2value \ 422 andObject: a2value \
420 inFile: [NSString stringWithUTF8String:__FILE__] \ 423 inFile: [NSString stringWithUTF8String:__FILE__] \
421 atLine: __LINE__ \ 424 atLine: __LINE__ \
422 withDescription: GHComposeString(description, ##__VA_ARGS__)]]; \ 425 withDescription: GHComposeString(description, ##__VA_ARGS__)]]; \
423 }\ 426 }\
424 @catch (id anException) {\ 427 @catch (id anException) {\
425 -[self failWithException:[NSException failureInRaise:[NSString stringWithFormat: @"(%s) != (%s)", #a1, #a2] \ 428 +[self failWithException:[NSException ghu_failureInRaise:[NSString stringWithFormat: @"(%s) != (%s)", #a1, #a2] \
426 exception:anException \ 429 exception:anException \
427 inFile:[NSString stringWithUTF8String:__FILE__] \ 430 inFile:[NSString stringWithUTF8String:__FILE__] \
428 atLine:__LINE__ \ 431 atLine:__LINE__ \
@@ -444,14 +447,14 @@ const char* a1value = (a1); \ @@ -444,14 +447,14 @@ const char* a1value = (a1); \
444 const char* a2value = (a2); \ 447 const char* a2value = (a2); \
445 if (a1value == a2value) continue; \ 448 if (a1value == a2value) continue; \
446 if (strcmp(a1value, a2value) == 0) continue; \ 449 if (strcmp(a1value, a2value) == 0) continue; \
447 -[self failWithException:[NSException failureInEqualityBetweenObject: [NSString stringWithUTF8String:a1value] \ 450 +[self failWithException:[NSException ghu_failureInEqualityBetweenObject: [NSString stringWithUTF8String:a1value] \
448 andObject: [NSString stringWithUTF8String:a2value] \ 451 andObject: [NSString stringWithUTF8String:a2value] \
449 inFile: [NSString stringWithUTF8String:__FILE__] \ 452 inFile: [NSString stringWithUTF8String:__FILE__] \
450 atLine: __LINE__ \ 453 atLine: __LINE__ \
451 withDescription: GHComposeString(description, ##__VA_ARGS__)]]; \ 454 withDescription: GHComposeString(description, ##__VA_ARGS__)]]; \
452 }\ 455 }\
453 @catch (id anException) {\ 456 @catch (id anException) {\
454 -[self failWithException:[NSException failureInRaise:[NSString stringWithFormat: @"(%s) == (%s)", #a1, #a2] \ 457 +[self failWithException:[NSException ghu_failureInRaise:[NSString stringWithFormat: @"(%s) == (%s)", #a1, #a2] \
455 exception:anException \ 458 exception:anException \
456 inFile:[NSString stringWithUTF8String:__FILE__] \ 459 inFile:[NSString stringWithUTF8String:__FILE__] \
457 atLine:__LINE__ \ 460 atLine:__LINE__ \
@@ -472,14 +475,14 @@ do { \ @@ -472,14 +475,14 @@ do { \
472 const char* a1value = (a1); \ 475 const char* a1value = (a1); \
473 const char* a2value = (a2); \ 476 const char* a2value = (a2); \
474 if (strcmp(a1value, a2value) != 0) continue; \ 477 if (strcmp(a1value, a2value) != 0) continue; \
475 -[self failWithException:[NSException failureInEqualityBetweenObject: [NSString stringWithUTF8String:a1value] \ 478 +[self failWithException:[NSException ghu_failureInEqualityBetweenObject: [NSString stringWithUTF8String:a1value] \
476 andObject: [NSString stringWithUTF8String:a2value] \ 479 andObject: [NSString stringWithUTF8String:a2value] \
477 inFile: [NSString stringWithUTF8String:__FILE__] \ 480 inFile: [NSString stringWithUTF8String:__FILE__] \
478 atLine: __LINE__ \ 481 atLine: __LINE__ \
479 withDescription: GHComposeString(description, ##__VA_ARGS__)]]; \ 482 withDescription: GHComposeString(description, ##__VA_ARGS__)]]; \
480 }\ 483 }\
481 @catch (id anException) {\ 484 @catch (id anException) {\
482 -[self failWithException:[NSException failureInRaise:[NSString stringWithFormat: @"(%s) != (%s)", #a1, #a2] \ 485 +[self failWithException:[NSException ghu_failureInRaise:[NSString stringWithFormat: @"(%s) != (%s)", #a1, #a2] \
483 exception:anException \ 486 exception:anException \
484 inFile:[NSString stringWithUTF8String:__FILE__] \ 487 inFile:[NSString stringWithUTF8String:__FILE__] \
485 atLine:__LINE__ \ 488 atLine:__LINE__ \
@@ -507,14 +510,14 @@ if (a1value == a2value) continue; \ @@ -507,14 +510,14 @@ if (a1value == a2value) continue; \
507 if ( (@encode(__typeof__(a1value)) == @encode(id)) && \ 510 if ( (@encode(__typeof__(a1value)) == @encode(id)) && \
508 (@encode(__typeof__(a2value)) == @encode(id)) && \ 511 (@encode(__typeof__(a2value)) == @encode(id)) && \
509 [(id)a1value isEqual: (id)a2value] ) continue; \ 512 [(id)a1value isEqual: (id)a2value] ) continue; \
510 -[self failWithException:[NSException failureInEqualityBetweenObject: a1value \ 513 +[self failWithException:[NSException ghu_failureInEqualityBetweenObject: a1value \
511 andObject: a2value \ 514 andObject: a2value \
512 inFile: [NSString stringWithUTF8String:__FILE__] \ 515 inFile: [NSString stringWithUTF8String:__FILE__] \
513 atLine: __LINE__ \ 516 atLine: __LINE__ \
514 withDescription: GHComposeString(description, ##__VA_ARGS__)]]; \ 517 withDescription: GHComposeString(description, ##__VA_ARGS__)]]; \
515 }\ 518 }\
516 @catch (id anException) {\ 519 @catch (id anException) {\
517 -[self failWithException:[NSException failureInRaise:[NSString stringWithFormat: @"(%s) == (%s)", #a1, #a2] \ 520 +[self failWithException:[NSException ghu_failureInRaise:[NSString stringWithFormat: @"(%s) == (%s)", #a1, #a2] \
518 exception:anException \ 521 exception:anException \
519 inFile:[NSString stringWithUTF8String:__FILE__] \ 522 inFile:[NSString stringWithUTF8String:__FILE__] \
520 atLine:__LINE__ \ 523 atLine:__LINE__ \
@@ -535,7 +538,7 @@ withDescription:GHComposeString(description, ##__VA_ARGS__)]]; \ @@ -535,7 +538,7 @@ withDescription:GHComposeString(description, ##__VA_ARGS__)]]; \
535 do { \ 538 do { \
536 @try {\ 539 @try {\
537 if (@encode(__typeof__(a1)) != @encode(__typeof__(a2))) { \ 540 if (@encode(__typeof__(a1)) != @encode(__typeof__(a2))) { \
538 -[self failWithException:[NSException failureInFile:[NSString stringWithUTF8String:__FILE__] \ 541 +[self failWithException:[NSException ghu_failureInFile:[NSString stringWithUTF8String:__FILE__] \
539 atLine:__LINE__ \ 542 atLine:__LINE__ \
540 withDescription:[@"Type mismatch -- " stringByAppendingString:GHComposeString(description, ##__VA_ARGS__)]]]; \ 543 withDescription:[@"Type mismatch -- " stringByAppendingString:GHComposeString(description, ##__VA_ARGS__)]]]; \
541 } else { \ 544 } else { \
@@ -544,7 +547,7 @@ __typeof__(a2) a2value = (a2); \ @@ -544,7 +547,7 @@ __typeof__(a2) a2value = (a2); \
544 NSValue *a1encoded = [NSValue value:&a1value withObjCType: @encode(__typeof__(a1))]; \ 547 NSValue *a1encoded = [NSValue value:&a1value withObjCType: @encode(__typeof__(a1))]; \
545 NSValue *a2encoded = [NSValue value:&a2value withObjCType: @encode(__typeof__(a2))]; \ 548 NSValue *a2encoded = [NSValue value:&a2value withObjCType: @encode(__typeof__(a2))]; \
546 if (![a1encoded isEqualToValue:a2encoded]) { \ 549 if (![a1encoded isEqualToValue:a2encoded]) { \
547 -[self failWithException:[NSException failureInEqualityBetweenValue: a1encoded \ 550 +[self failWithException:[NSException ghu_failureInEqualityBetweenValue: a1encoded \
548 andValue: a2encoded \ 551 andValue: a2encoded \
549 withAccuracy: nil \ 552 withAccuracy: nil \
550 inFile: [NSString stringWithUTF8String:__FILE__] \ 553 inFile: [NSString stringWithUTF8String:__FILE__] \
@@ -554,7 +557,7 @@ withDescription: GHComposeString(description, ##__VA_ARGS__)]]; \ @@ -554,7 +557,7 @@ withDescription: GHComposeString(description, ##__VA_ARGS__)]]; \
554 } \ 557 } \
555 } \ 558 } \
556 @catch (id anException) {\ 559 @catch (id anException) {\
557 -[self failWithException:[NSException failureInRaise:[NSString stringWithFormat: @"(%s) == (%s)", #a1, #a2] \ 560 +[self failWithException:[NSException ghu_failureInRaise:[NSString stringWithFormat: @"(%s) == (%s)", #a1, #a2] \
558 exception:anException \ 561 exception:anException \
559 inFile:[NSString stringWithUTF8String:__FILE__] \ 562 inFile:[NSString stringWithUTF8String:__FILE__] \
560 atLine:__LINE__ \ 563 atLine:__LINE__ \
@@ -581,7 +584,7 @@ withDescription:GHComposeString(description, ##__VA_ARGS__)]]; \ @@ -581,7 +584,7 @@ withDescription:GHComposeString(description, ##__VA_ARGS__)]]; \
581 do { \ 584 do { \
582 @try {\ 585 @try {\
583 if (@encode(__typeof__(a1)) != @encode(__typeof__(a2))) { \ 586 if (@encode(__typeof__(a1)) != @encode(__typeof__(a2))) { \
584 -[self failWithException:[NSException failureInFile:[NSString stringWithUTF8String:__FILE__] \ 587 +[self failWithException:[NSException ghu_failureInFile:[NSString stringWithUTF8String:__FILE__] \
585 atLine:__LINE__ \ 588 atLine:__LINE__ \
586 withDescription:[@"Type mismatch -- " stringByAppendingString:GHComposeString(description, ##__VA_ARGS__)]]]; \ 589 withDescription:[@"Type mismatch -- " stringByAppendingString:GHComposeString(description, ##__VA_ARGS__)]]]; \
587 } else { \ 590 } else { \
@@ -592,7 +595,7 @@ if (GHAbsoluteDifference(a1value, a2value) > accuracyvalue) { \ @@ -592,7 +595,7 @@ if (GHAbsoluteDifference(a1value, a2value) > accuracyvalue) { \
592 NSValue *a1encoded = [NSValue value:&a1value withObjCType:@encode(__typeof__(a1))]; \ 595 NSValue *a1encoded = [NSValue value:&a1value withObjCType:@encode(__typeof__(a1))]; \
593 NSValue *a2encoded = [NSValue value:&a2value withObjCType:@encode(__typeof__(a2))]; \ 596 NSValue *a2encoded = [NSValue value:&a2value withObjCType:@encode(__typeof__(a2))]; \
594 NSValue *accuracyencoded = [NSValue value:&accuracyvalue withObjCType:@encode(__typeof__(accuracy))]; \ 597 NSValue *accuracyencoded = [NSValue value:&accuracyvalue withObjCType:@encode(__typeof__(accuracy))]; \
595 -[self failWithException:[NSException failureInEqualityBetweenValue: a1encoded \ 598 +[self failWithException:[NSException ghu_failureInEqualityBetweenValue: a1encoded \
596 andValue: a2encoded \ 599 andValue: a2encoded \
597 withAccuracy: accuracyencoded \ 600 withAccuracy: accuracyencoded \
598 inFile: [NSString stringWithUTF8String:__FILE__] \ 601 inFile: [NSString stringWithUTF8String:__FILE__] \
@@ -602,7 +605,7 @@ withDescription: GHComposeString(description, ##__VA_ARGS__)]]; \ @@ -602,7 +605,7 @@ withDescription: GHComposeString(description, ##__VA_ARGS__)]]; \
602 } \ 605 } \
603 } \ 606 } \
604 @catch (id anException) {\ 607 @catch (id anException) {\
605 -[self failWithException:[NSException failureInRaise:[NSString stringWithFormat: @"(%s) == (%s)", #a1, #a2] \ 608 +[self failWithException:[NSException ghu_failureInRaise:[NSString stringWithFormat: @"(%s) == (%s)", #a1, #a2] \
606 exception:anException \ 609 exception:anException \
607 inFile:[NSString stringWithUTF8String:__FILE__] \ 610 inFile:[NSString stringWithUTF8String:__FILE__] \
608 atLine:__LINE__ \ 611 atLine:__LINE__ \
@@ -618,7 +621,7 @@ withDescription:GHComposeString(description, ##__VA_ARGS__)]]; \ @@ -618,7 +621,7 @@ withDescription:GHComposeString(description, ##__VA_ARGS__)]]; \
618 _{... A variable number of arguments to the format string. Can be absent.} 621 _{... A variable number of arguments to the format string. Can be absent.}
619 "*/ 622 "*/
620 #define GHFail(description, ...) \ 623 #define GHFail(description, ...) \
621 -[self failWithException:[NSException failureInFile: [NSString stringWithUTF8String:__FILE__] \ 624 +[self failWithException:[NSException ghu_failureInFile: [NSString stringWithUTF8String:__FILE__] \
622 atLine: __LINE__ \ 625 atLine: __LINE__ \
623 withDescription: GHComposeString(description, ##__VA_ARGS__)]] 626 withDescription: GHComposeString(description, ##__VA_ARGS__)]]
624 627
@@ -637,7 +640,7 @@ id a1value = (a1); \ @@ -637,7 +640,7 @@ id a1value = (a1); \
637 if (a1value != nil) { \ 640 if (a1value != nil) { \
638 NSString *_a1 = [NSString stringWithUTF8String: #a1]; \ 641 NSString *_a1 = [NSString stringWithUTF8String: #a1]; \
639 NSString *_expression = [NSString stringWithFormat:@"((%@) == nil)", _a1]; \ 642 NSString *_expression = [NSString stringWithFormat:@"((%@) == nil)", _a1]; \
640 -[self failWithException:[NSException failureInCondition: _expression \ 643 +[self failWithException:[NSException ghu_failureInCondition: _expression \
641 isTrue: NO \ 644 isTrue: NO \
642 inFile: [NSString stringWithUTF8String:__FILE__] \ 645 inFile: [NSString stringWithUTF8String:__FILE__] \
643 atLine: __LINE__ \ 646 atLine: __LINE__ \
@@ -645,7 +648,7 @@ withDescription: GHComposeString(description, ##__VA_ARGS__)]]; \ @@ -645,7 +648,7 @@ withDescription: GHComposeString(description, ##__VA_ARGS__)]]; \
645 } \ 648 } \
646 }\ 649 }\
647 @catch (id anException) {\ 650 @catch (id anException) {\
648 -[self failWithException:[NSException failureInRaise:[NSString stringWithFormat: @"(%s) == nil fails", #a1] \ 651 +[self failWithException:[NSException ghu_failureInRaise:[NSString stringWithFormat: @"(%s) == nil fails", #a1] \
649 exception:anException \ 652 exception:anException \
650 inFile:[NSString stringWithUTF8String:__FILE__] \ 653 inFile:[NSString stringWithUTF8String:__FILE__] \
651 atLine:__LINE__ \ 654 atLine:__LINE__ \
@@ -667,7 +670,7 @@ id a1value = (a1); \ @@ -667,7 +670,7 @@ id a1value = (a1); \
667 if (a1value == nil) { \ 670 if (a1value == nil) { \
668 NSString *_a1 = [NSString stringWithUTF8String: #a1]; \ 671 NSString *_a1 = [NSString stringWithUTF8String: #a1]; \
669 NSString *_expression = [NSString stringWithFormat:@"((%@) != nil)", _a1]; \ 672 NSString *_expression = [NSString stringWithFormat:@"((%@) != nil)", _a1]; \
670 -[self failWithException:[NSException failureInCondition: _expression \ 673 +[self failWithException:[NSException ghu_failureInCondition: _expression \
671 isTrue: NO \ 674 isTrue: NO \
672 inFile: [NSString stringWithUTF8String:__FILE__] \ 675 inFile: [NSString stringWithUTF8String:__FILE__] \
673 atLine: __LINE__ \ 676 atLine: __LINE__ \
@@ -675,7 +678,7 @@ withDescription: GHComposeString(description, ##__VA_ARGS__)]]; \ @@ -675,7 +678,7 @@ withDescription: GHComposeString(description, ##__VA_ARGS__)]]; \
675 } \ 678 } \
676 }\ 679 }\
677 @catch (id anException) {\ 680 @catch (id anException) {\
678 -[self failWithException:[NSException failureInRaise:[NSString stringWithFormat: @"(%s) != nil fails", #a1] \ 681 +[self failWithException:[NSException ghu_failureInRaise:[NSString stringWithFormat: @"(%s) != nil fails", #a1] \
679 exception:anException \ 682 exception:anException \
680 inFile:[NSString stringWithUTF8String:__FILE__] \ 683 inFile:[NSString stringWithUTF8String:__FILE__] \
681 atLine:__LINE__ \ 684 atLine:__LINE__ \
@@ -695,7 +698,7 @@ do { \ @@ -695,7 +698,7 @@ do { \
695 BOOL _evaluatedExpression = (expr);\ 698 BOOL _evaluatedExpression = (expr);\
696 if (!_evaluatedExpression) {\ 699 if (!_evaluatedExpression) {\
697 NSString *_expression = [NSString stringWithUTF8String: #expr];\ 700 NSString *_expression = [NSString stringWithUTF8String: #expr];\
698 -[self failWithException:[NSException failureInCondition: _expression \ 701 +[self failWithException:[NSException ghu_failureInCondition: _expression \
699 isTrue: YES \ 702 isTrue: YES \
700 inFile: [NSString stringWithUTF8String:__FILE__] \ 703 inFile: [NSString stringWithUTF8String:__FILE__] \
701 atLine: __LINE__ \ 704 atLine: __LINE__ \
@@ -717,7 +720,7 @@ do { \ @@ -717,7 +720,7 @@ do { \
717 BOOL _evaluatedExpression = (expr);\ 720 BOOL _evaluatedExpression = (expr);\
718 if (!_evaluatedExpression) {\ 721 if (!_evaluatedExpression) {\
719 NSString *_expression = [NSString stringWithUTF8String: #expr];\ 722 NSString *_expression = [NSString stringWithUTF8String: #expr];\
720 -[self failWithException:[NSException failureInCondition: _expression \ 723 +[self failWithException:[NSException ghu_failureInCondition: _expression \
721 isTrue: NO \ 724 isTrue: NO \
722 inFile: [NSString stringWithUTF8String:__FILE__] \ 725 inFile: [NSString stringWithUTF8String:__FILE__] \
723 atLine: __LINE__ \ 726 atLine: __LINE__ \
@@ -725,7 +728,7 @@ withDescription: GHComposeString(description, ##__VA_ARGS__)]]; \ @@ -725,7 +728,7 @@ withDescription: GHComposeString(description, ##__VA_ARGS__)]]; \
725 } \ 728 } \
726 } \ 729 } \
727 @catch (id anException) {\ 730 @catch (id anException) {\
728 -[self failWithException:[NSException failureInRaise:[NSString stringWithFormat: @"(%s) ", #expr] \ 731 +[self failWithException:[NSException ghu_failureInRaise:[NSString stringWithFormat: @"(%s) ", #expr] \
729 exception:anException \ 732 exception:anException \
730 inFile:[NSString stringWithUTF8String:__FILE__] \ 733 inFile:[NSString stringWithUTF8String:__FILE__] \
731 atLine:__LINE__ \ 734 atLine:__LINE__ \
@@ -745,7 +748,7 @@ do { \ @@ -745,7 +748,7 @@ do { \
745 BOOL _evaluatedExpression = (expr);\ 748 BOOL _evaluatedExpression = (expr);\
746 if (_evaluatedExpression) {\ 749 if (_evaluatedExpression) {\
747 NSString *_expression = [NSString stringWithUTF8String: #expr];\ 750 NSString *_expression = [NSString stringWithUTF8String: #expr];\
748 -[self failWithException:[NSException failureInCondition: _expression \ 751 +[self failWithException:[NSException ghu_failureInCondition: _expression \
749 isTrue: NO \ 752 isTrue: NO \
750 inFile: [NSString stringWithUTF8String:__FILE__] \ 753 inFile: [NSString stringWithUTF8String:__FILE__] \
751 atLine: __LINE__ \ 754 atLine: __LINE__ \
@@ -767,7 +770,7 @@ do { \ @@ -767,7 +770,7 @@ do { \
767 BOOL _evaluatedExpression = (expr);\ 770 BOOL _evaluatedExpression = (expr);\
768 if (_evaluatedExpression) {\ 771 if (_evaluatedExpression) {\
769 NSString *_expression = [NSString stringWithUTF8String: #expr];\ 772 NSString *_expression = [NSString stringWithUTF8String: #expr];\
770 -[self failWithException:[NSException failureInCondition: _expression \ 773 +[self failWithException:[NSException ghu_failureInCondition: _expression \
771 isTrue: YES \ 774 isTrue: YES \
772 inFile: [NSString stringWithUTF8String:__FILE__] \ 775 inFile: [NSString stringWithUTF8String:__FILE__] \
773 atLine: __LINE__ \ 776 atLine: __LINE__ \
@@ -775,7 +778,7 @@ withDescription: GHComposeString(description, ##__VA_ARGS__)]]; \ @@ -775,7 +778,7 @@ withDescription: GHComposeString(description, ##__VA_ARGS__)]]; \
775 } \ 778 } \
776 } \ 779 } \
777 @catch (id anException) {\ 780 @catch (id anException) {\
778 -[self failWithException:[NSException failureInRaise:[NSString stringWithFormat: @"!(%s) ", #expr] \ 781 +[self failWithException:[NSException ghu_failureInRaise:[NSString stringWithFormat: @"!(%s) ", #expr] \
779 exception:anException \ 782 exception:anException \
780 inFile:[NSString stringWithUTF8String:__FILE__] \ 783 inFile:[NSString stringWithUTF8String:__FILE__] \
781 atLine:__LINE__ \ 784 atLine:__LINE__ \
@@ -798,7 +801,7 @@ do { \ @@ -798,7 +801,7 @@ do { \
798 @catch (id anException) { \ 801 @catch (id anException) { \
799 continue; \ 802 continue; \
800 }\ 803 }\
801 -[self failWithException:[NSException failureInRaise: [NSString stringWithUTF8String:#expr] \ 804 +[self failWithException:[NSException ghu_failureInRaise: [NSString stringWithUTF8String:#expr] \
802 exception: nil \ 805 exception: nil \
803 inFile: [NSString stringWithUTF8String:__FILE__] \ 806 inFile: [NSString stringWithUTF8String:__FILE__] \
804 atLine: __LINE__ \ 807 atLine: __LINE__ \
@@ -824,7 +827,7 @@ continue; \ @@ -824,7 +827,7 @@ continue; \
824 }\ 827 }\
825 @catch (id anException) {\ 828 @catch (id anException) {\
826 NSString *_descrip = GHComposeString(@"(Expected exception: %@) %@", NSStringFromClass([specificException class]), description);\ 829 NSString *_descrip = GHComposeString(@"(Expected exception: %@) %@", NSStringFromClass([specificException class]), description);\
827 -[self failWithException:[NSException failureInRaise: [NSString stringWithUTF8String:#expr] \ 830 +[self failWithException:[NSException ghu_failureInRaise: [NSString stringWithUTF8String:#expr] \
828 exception: anException \ 831 exception: anException \
829 inFile: [NSString stringWithUTF8String:__FILE__] \ 832 inFile: [NSString stringWithUTF8String:__FILE__] \
830 atLine: __LINE__ \ 833 atLine: __LINE__ \
@@ -832,7 +835,7 @@ withDescription: GHComposeString(_descrip, ##__VA_ARGS__)]]; \ @@ -832,7 +835,7 @@ withDescription: GHComposeString(_descrip, ##__VA_ARGS__)]]; \
832 continue; \ 835 continue; \
833 }\ 836 }\
834 NSString *_descrip = GHComposeString(@"(Expected exception: %@) %@", NSStringFromClass([specificException class]), description);\ 837 NSString *_descrip = GHComposeString(@"(Expected exception: %@) %@", NSStringFromClass([specificException class]), description);\
835 -[self failWithException:[NSException failureInRaise: [NSString stringWithUTF8String:#expr] \ 838 +[self failWithException:[NSException ghu_failureInRaise: [NSString stringWithUTF8String:#expr] \
836 exception: nil \ 839 exception: nil \
837 inFile: [NSString stringWithUTF8String:__FILE__] \ 840 inFile: [NSString stringWithUTF8String:__FILE__] \
838 atLine: __LINE__ \ 841 atLine: __LINE__ \
@@ -861,7 +864,7 @@ do { \ @@ -861,7 +864,7 @@ do { \
861 if ([aName isEqualToString: [anException name]]) continue; \ 864 if ([aName isEqualToString: [anException name]]) continue; \
862 NSString *_descrip = GHComposeString(@"(Expected exception: %@ (name: %@)) %@", NSStringFromClass([specificException class]), aName, description);\ 865 NSString *_descrip = GHComposeString(@"(Expected exception: %@ (name: %@)) %@", NSStringFromClass([specificException class]), aName, description);\
863 [self failWithException: \ 866 [self failWithException: \
864 -[NSException failureInRaise: [NSString stringWithUTF8String:#expr] \ 867 +[NSException ghu_failureInRaise: [NSString stringWithUTF8String:#expr] \
865 exception: anException \ 868 exception: anException \
866 inFile: [NSString stringWithUTF8String:__FILE__] \ 869 inFile: [NSString stringWithUTF8String:__FILE__] \
867 atLine: __LINE__ \ 870 atLine: __LINE__ \
@@ -871,7 +874,7 @@ continue; \ @@ -871,7 +874,7 @@ continue; \
871 @catch (id anException) {\ 874 @catch (id anException) {\
872 NSString *_descrip = GHComposeString(@"(Expected exception: %@) %@", NSStringFromClass([specificException class]), description);\ 875 NSString *_descrip = GHComposeString(@"(Expected exception: %@) %@", NSStringFromClass([specificException class]), description);\
873 [self failWithException: \ 876 [self failWithException: \
874 -[NSException failureInRaise: [NSString stringWithUTF8String:#expr] \ 877 +[NSException ghu_failureInRaise: [NSString stringWithUTF8String:#expr] \
875 exception: anException \ 878 exception: anException \
876 inFile: [NSString stringWithUTF8String:__FILE__] \ 879 inFile: [NSString stringWithUTF8String:__FILE__] \
877 atLine: __LINE__ \ 880 atLine: __LINE__ \
@@ -880,7 +883,7 @@ continue; \ @@ -880,7 +883,7 @@ continue; \
880 }\ 883 }\
881 NSString *_descrip = GHComposeString(@"(Expected exception: %@) %@", NSStringFromClass([specificException class]), description);\ 884 NSString *_descrip = GHComposeString(@"(Expected exception: %@) %@", NSStringFromClass([specificException class]), description);\
882 [self failWithException: \ 885 [self failWithException: \
883 -[NSException failureInRaise: [NSString stringWithUTF8String:#expr] \ 886 +[NSException ghu_failureInRaise: [NSString stringWithUTF8String:#expr] \
884 exception: nil \ 887 exception: nil \
885 inFile: [NSString stringWithUTF8String:__FILE__] \ 888 inFile: [NSString stringWithUTF8String:__FILE__] \
886 atLine: __LINE__ \ 889 atLine: __LINE__ \
@@ -900,7 +903,7 @@ do { \ @@ -900,7 +903,7 @@ do { \
900 (expr);\ 903 (expr);\
901 } \ 904 } \
902 @catch (id anException) { \ 905 @catch (id anException) { \
903 -[self failWithException:[NSException failureInRaise: [NSString stringWithUTF8String:#expr] \ 906 +[self failWithException:[NSException ghu_failureInRaise: [NSString stringWithUTF8String:#expr] \
904 exception: anException \ 907 exception: anException \
905 inFile: [NSString stringWithUTF8String:__FILE__] \ 908 inFile: [NSString stringWithUTF8String:__FILE__] \
906 atLine: __LINE__ \ 909 atLine: __LINE__ \
@@ -923,7 +926,7 @@ do { \ @@ -923,7 +926,7 @@ do { \
923 (expr);\ 926 (expr);\
924 } \ 927 } \
925 @catch (specificException *anException) { \ 928 @catch (specificException *anException) { \
926 -[self failWithException:[NSException failureInRaise: [NSString stringWithUTF8String:#expr] \ 929 +[self failWithException:[NSException ghu_failureInRaise: [NSString stringWithUTF8String:#expr] \
927 exception: anException \ 930 exception: anException \
928 inFile: [NSString stringWithUTF8String:__FILE__] \ 931 inFile: [NSString stringWithUTF8String:__FILE__] \
929 atLine: __LINE__ \ 932 atLine: __LINE__ \
@@ -956,7 +959,7 @@ do { \ @@ -956,7 +959,7 @@ do { \
956 if ([aName isEqualToString: [anException name]]) { \ 959 if ([aName isEqualToString: [anException name]]) { \
957 NSString *_descrip = GHComposeString(@"(Expected exception: %@ (name: %@)) %@", NSStringFromClass([specificException class]), aName, description);\ 960 NSString *_descrip = GHComposeString(@"(Expected exception: %@ (name: %@)) %@", NSStringFromClass([specificException class]), aName, description);\
958 [self failWithException: \ 961 [self failWithException: \
959 -[NSException failureInRaise: [NSString stringWithUTF8String:#expr] \ 962 +[NSException ghu_failureInRaise: [NSString stringWithUTF8String:#expr] \
960 exception: anException \ 963 exception: anException \
961 inFile: [NSString stringWithUTF8String:__FILE__] \ 964 inFile: [NSString stringWithUTF8String:__FILE__] \
962 atLine: __LINE__ \ 965 atLine: __LINE__ \
@@ -971,30 +974,30 @@ continue; \ @@ -971,30 +974,30 @@ continue; \
971 974
972 975
973 @interface NSException (GHTestMacros_GTMSenTestAdditions) 976 @interface NSException (GHTestMacros_GTMSenTestAdditions)
974 -+ (NSException *)failureInFile:(NSString *)filename 977 ++ (NSException *)ghu_failureInFile:(NSString *)filename
975 atLine:(int)lineNumber 978 atLine:(int)lineNumber
976 withDescription:(NSString *)formatString, ...; 979 withDescription:(NSString *)formatString, ...;
977 -+ (NSException *)failureInCondition:(NSString *)condition 980 ++ (NSException *)ghu_failureInCondition:(NSString *)condition
978 isTrue:(BOOL)isTrue 981 isTrue:(BOOL)isTrue
979 inFile:(NSString *)filename 982 inFile:(NSString *)filename
980 atLine:(int)lineNumber 983 atLine:(int)lineNumber
981 withDescription:(NSString *)formatString, ...; 984 withDescription:(NSString *)formatString, ...;
982 -+ (NSException *)failureInEqualityBetweenObject:(id)left 985 ++ (NSException *)ghu_failureInEqualityBetweenObject:(id)left
983 andObject:(id)right 986 andObject:(id)right
984 inFile:(NSString *)filename 987 inFile:(NSString *)filename
985 atLine:(int)lineNumber 988 atLine:(int)lineNumber
986 withDescription:(NSString *)formatString, ...; 989 withDescription:(NSString *)formatString, ...;
987 -+ (NSException *)failureInEqualityBetweenValue:(NSValue *)left 990 ++ (NSException *)ghu_failureInEqualityBetweenValue:(NSValue *)left
988 andValue:(NSValue *)right 991 andValue:(NSValue *)right
989 withAccuracy:(NSValue *)accuracy 992 withAccuracy:(NSValue *)accuracy
990 inFile:(NSString *)filename 993 inFile:(NSString *)filename
991 atLine:(int) ineNumber 994 atLine:(int) ineNumber
992 withDescription:(NSString *)formatString, ...; 995 withDescription:(NSString *)formatString, ...;
993 -+ (NSException *)failureInRaise:(NSString *)expression 996 ++ (NSException *)ghu_failureInRaise:(NSString *)expression
994 inFile:(NSString *)filename 997 inFile:(NSString *)filename
995 atLine:(int)lineNumber 998 atLine:(int)lineNumber
996 withDescription:(NSString *)formatString, ...; 999 withDescription:(NSString *)formatString, ...;
997 -+ (NSException *)failureInRaise:(NSString *)expression 1000 ++ (NSException *)ghu_failureInRaise:(NSString *)expression
998 exception:(NSException *)exception 1001 exception:(NSException *)exception
999 inFile:(NSString *)filename 1002 inFile:(NSString *)filename
1000 atLine:(int)lineNumber 1003 atLine:(int)lineNumber
@@ -143,6 +143,11 @@ @@ -143,6 +143,11 @@
143 143
144 - (void)cancel; 144 - (void)cancel;
145 145
  146 +/*!
  147 + Write message to console.
  148 + */
  149 +- (void)log:(NSString *)message;
  150 +
146 @end 151 @end
147 152
148 153
@@ -85,6 +85,13 @@ extern NSString *GHUnitTest; @@ -85,6 +85,13 @@ extern NSString *GHUnitTest;
85 + (GHTestSuite *)suiteWithTestFilter:(NSString *)testFilter; 85 + (GHTestSuite *)suiteWithTestFilter:(NSString *)testFilter;
86 86
87 /*! 87 /*!
  88 + Create suite of tests that start with prefix.
  89 + @param prefix If test case class starts with the prefix; If nil or empty string, returns all tests
  90 + @param options Compare options
  91 + */
  92 ++ (GHTestSuite *)suiteWithPrefix:(NSString *)prefix options:(NSStringCompareOptions)options;
  93 +
  94 +/*!
88 Suite for a single test/method. 95 Suite for a single test/method.
89 @param testCaseClass 96 @param testCaseClass
90 @param method 97 @param method
@@ -46,6 +46,8 @@ @@ -46,6 +46,8 @@
46 // the License. 46 // the License.
47 // 47 //
48 48
  49 +extern NSString *GHUStackTraceFromException(NSException *e);
  50 +
49 // GTM_BEGIN 51 // GTM_BEGIN
50 BOOL isTestFixtureOfClass(Class aClass, Class testCaseClass); 52 BOOL isTestFixtureOfClass(Class aClass, Class testCaseClass);
51 // GTM_END 53 // GTM_END
@@ -102,3 +104,6 @@ BOOL isTestFixtureOfClass(Class aClass, Class testCaseClass); @@ -102,3 +104,6 @@ BOOL isTestFixtureOfClass(Class aClass, Class testCaseClass);
102 104
103 @end 105 @end
104 106
  107 +@protocol GHSenTestCase
  108 +- (void)raiseAfterFailure;
  109 +@end
@@ -34,7 +34,9 @@ @@ -34,7 +34,9 @@
34 #import "GHTestRunner.h" 34 #import "GHTestRunner.h"
35 35
36 #ifdef DEBUG 36 #ifdef DEBUG
37 -#define GHUDebug(fmt, ...) NSLog(fmt, ##__VA_ARGS__) 37 +#define GHUDebug(fmt, ...) do { \
  38 +fputs([[[NSString stringWithFormat:fmt, ##__VA_ARGS__] stringByAppendingString:@"\n"] UTF8String], stdout); \
  39 +} while(0)
38 #else 40 #else
39 #define GHUDebug(fmt, ...) do {} while(0) 41 #define GHUDebug(fmt, ...) do {} while(0)
40 #endif 42 #endif
  1 +//
  2 +// GHUnitIPhoneAppDelegate.h
  3 +// GHUnitIPhone
  4 +//
  5 +// Created by Gabriel Handford on 1/25/09.
  6 +// Copyright 2009. All rights reserved.
  7 +//
  8 +
  9 +#import <UIKit/UIKit.h>
  10 +
  11 +@interface GHUnitIPhoneAppDelegate : NSObject <UIApplicationDelegate> {
  12 + UIWindow *window_;
  13 +
  14 + UINavigationController *navigationController_;
  15 +}
  16 +
  17 +@end
  18 +
@@ -9,18 +9,37 @@ @@ -9,18 +9,37 @@
9 #import <UIKit/UIKit.h> 9 #import <UIKit/UIKit.h>
10 10
11 #import "GHUnit.h" 11 #import "GHUnit.h"
  12 +#import "GHTesting.h"
12 13
13 -extern BOOL NSDebugEnabled; 14 +// Default exception handler
14 -extern BOOL NSZombieEnabled; 15 +void exceptionHandler(NSException *exception) {
15 -extern BOOL NSDeallocateZombies; 16 + NSLog(@"%@\n%@", [exception reason], GHUStackTraceFromException(exception));
16 -extern BOOL NSHangOnUncaughtException; 17 +}
17 18
18 int main(int argc, char *argv[]) { 19 int main(int argc, char *argv[]) {
19 20
20 - NSDebugEnabled = YES; 21 + /*!
21 - NSZombieEnabled = YES; 22 + For debugging:
22 - NSDeallocateZombies = NO; 23 + Go into the "Get Info" contextual menu of your (test) executable (inside the "Executables" group in the left panel of XCode).
23 - NSHangOnUncaughtException = YES; 24 + Then go in the "Arguments" tab. You can add the following environment variables:
  25 +
  26 + Default: Set to:
  27 + NSDebugEnabled NO "YES"
  28 + NSZombieEnabled NO "YES"
  29 + NSDeallocateZombies NO "YES"
  30 + NSHangOnUncaughtException NO "YES"
  31 +
  32 + NSEnableAutoreleasePool YES "NO"
  33 + NSAutoreleaseFreedObjectCheckEnabled NO "YES"
  34 + NSAutoreleaseHighWaterMark 0 non-negative integer
  35 + NSAutoreleaseHighWaterResolution 0 non-negative integer
  36 +
  37 + For info on these varaiables see NSDebug.h; http://theshadow.uw.hu/iPhoneSDKdoc/Foundation.framework/NSDebug.h.html
  38 +
  39 + For malloc debugging see: http://developer.apple.com/mac/library/documentation/Performance/Conceptual/ManagingMemory/Articles/MallocDebug.html
  40 + */
  41 +
  42 + NSSetUncaughtExceptionHandler(&exceptionHandler);
24 43
25 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 44 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
26 45
  1 +
  2 +TEST_TARGET=Tests
  3 +SDK=iphonesimulator3.0
  4 +COMMAND=xcodebuild
  5 +
  6 +default:
  7 + # Set default make action here
  8 +
  9 +# If you need to clean a specific target/configuration: $(COMMAND) -target $(TARGET) -configuration DebugOrRelease -sdk $(SDK) clean
  10 +clean:
  11 + -rm -rf build/*
  12 +
  13 +test:
  14 + GHUNIT_CLI=1 $(COMMAND) -target $(TEST_TARGET) -configuration Debug -sdk $(SDK) build
  15 +
  1 +//
  2 +// NSException+GHTestFailureExceptions.h
  3 +//
  4 +// Created by Johannes Rudolph on 23.09.09.
  5 +// Copyright 2009. All rights reserved.
  6 +//
  7 +// Permission is hereby granted, free of charge, to any person
  8 +// obtaining a copy of this software and associated documentation
  9 +// files (the "Software"), to deal in the Software without
  10 +// restriction, including without limitation the rights to use,
  11 +// copy, modify, merge, publish, distribute, sublicense, and/or sell
  12 +// copies of the Software, and to permit persons to whom the
  13 +// Software is furnished to do so, subject to the following
  14 +// conditions:
  15 +//
  16 +// The above copyright notice and this permission notice shall be
  17 +// included in all copies or substantial portions of the Software.
  18 +//
  19 +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  20 +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  21 +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  22 +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  23 +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  24 +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  25 +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  26 +// OTHER DEALINGS IN THE SOFTWARE.
  27 +//
  28 +
  29 +//
  30 +// Portions of this file fall under the following license, marked with:
  31 +// GTM_BEGIN : GTM_END
  32 +//
  33 +// Copyright 2008 Google Inc.
  34 +//
  35 +// Licensed under the Apache License, Version 2.0 (the "License"); you may not
  36 +// use this file except in compliance with the License. You may obtain a copy
  37 +// of the License at
  38 +//
  39 +// http://www.apache.org/licenses/LICENSE-2.0
  40 +//
  41 +// Unless required by applicable law or agreed to in writing, software
  42 +// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  43 +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  44 +// License for the specific language governing permissions and limitations under
  45 +// the License.
  46 +//
  47 +
  48 +// GTM_BEGIN
  49 +
  50 +#import <Foundation/Foundation.h>
  51 +
  52 +@interface NSException (GHUTestFailureExceptions)
  53 ++ (NSException *)ghu_failureInFile:(NSString *)filename
  54 + atLine:(int)lineNumber
  55 + withDescription:(NSString *)formatString, ...;
  56 ++ (NSException *)ghu_failureInCondition:(NSString *)condition
  57 + isTrue:(BOOL)isTrue
  58 + inFile:(NSString *)filename
  59 + atLine:(int)lineNumber
  60 + withDescription:(NSString *)formatString, ...;
  61 ++ (NSException *)ghu_failureInEqualityBetweenObject:(id)left
  62 + andObject:(id)right
  63 + inFile:(NSString *)filename
  64 + atLine:(int)lineNumber
  65 + withDescription:(NSString *)formatString, ...;
  66 ++ (NSException *)ghu_failureInEqualityBetweenValue:(NSValue *)left
  67 + andValue:(NSValue *)right
  68 + withAccuracy:(NSValue *)accuracy
  69 + inFile:(NSString *)filename
  70 + atLine:(int) ineNumber
  71 + withDescription:(NSString *)formatString, ...;
  72 ++ (NSException *)ghu_failureInRaise:(NSString *)expression
  73 + inFile:(NSString *)filename
  74 + atLine:(int)lineNumber
  75 + withDescription:(NSString *)formatString, ...;
  76 ++ (NSException *)ghu_failureInRaise:(NSString *)expression
  77 + exception:(NSException *)exception
  78 + inFile:(NSString *)filename
  79 + atLine:(int)lineNumber
  80 + withDescription:(NSString *)formatString, ...;
  81 +@end
  82 +
  83 +// GTM_END
  1 +//
  2 +// NSValue+GHValueFormatter.h
  3 +//
  4 +// Created by Johannes Rudolph on 23.9.2009.
  5 +// Copyright 2009. All rights reserved.
  6 +//
  7 +// Permission is hereby granted, free of charge, to any person
  8 +// obtaining a copy of this software and associated documentation
  9 +// files (the "Software"), to deal in the Software without
  10 +// restriction, including without limitation the rights to use,
  11 +// copy, modify, merge, publish, distribute, sublicense, and/or sell
  12 +// copies of the Software, and to permit persons to whom the
  13 +// Software is furnished to do so, subject to the following
  14 +// conditions:
  15 +//
  16 +// The above copyright notice and this permission notice shall be
  17 +// included in all copies or substantial portions of the Software.
  18 +//
  19 +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  20 +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  21 +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  22 +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  23 +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  24 +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  25 +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  26 +// OTHER DEALINGS IN THE SOFTWARE.
  27 +//
  28 +
  29 +//
  30 +// Portions of this file fall under the following license, marked with
  31 +// SENTE_BEGIN - SENTE_END
  32 +//
  33 +// Copyright (c) 1997-2005, Sen:te (Sente SA). All rights reserved.
  34 +//
  35 +// Use of this source code is governed by the following license:
  36 +//
  37 +// Redistribution and use in source and binary forms, with or without modification,
  38 +// are permitted provided that the following conditions are met:
  39 +//
  40 +// (1) Redistributions of source code must retain the above copyright notice,
  41 +// this list of conditions and the following disclaimer.
  42 +//
  43 +// (2) Redistributions in binary form must reproduce the above copyright notice,
  44 +// this list of conditions and the following disclaimer in the documentation
  45 +// and/or other materials provided with the distribution.
  46 +//
  47 +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
  48 +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  49 +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  50 +// IN NO EVENT SHALL Sente SA OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  51 +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
  52 +// OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  53 +// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  54 +// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  55 +// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  56 +//
  57 +// Note: this license is equivalent to the FreeBSD license.
  58 +//
  59 +// This notice may not be removed from this file.
  60 +
  61 +#import <Foundation/Foundation.h>
  62 +
  63 +// SENTE_BEGIN
  64 +@interface NSValue (GHValueFormatter)
  65 +- (NSString *)ghu_contentDescription;
  66 +@end
  67 +// SENTE_END
@@ -20,7 +20,5 @@ @@ -20,7 +20,5 @@
20 <string>????</string> 20 <string>????</string>
21 <key>CFBundleVersion</key> 21 <key>CFBundleVersion</key>
22 <string>1.0</string> 22 <string>1.0</string>
23 - <key>NSMainNibFile</key>  
24 - <string>GHUnitIPhone</string>  
25 </dict> 23 </dict>
26 </plist> 24 </plist>
This diff was suppressed by a .gitattributes entry.