Skip to content

Instantly share code, notes, and snippets.

@JoshOldenburg
Created June 22, 2013 14:12
Show Gist options
  • Save JoshOldenburg/5841014 to your computer and use it in GitHub Desktop.
Save JoshOldenburg/5841014 to your computer and use it in GitHub Desktop.
JOAssertEqualsString for SenTestKit is like STAssertEquals but for NSString's.
#define JOAssertEqualsString(a1, a2, description, ...) \
do { \
@try {\
if (![a1 isKindOfClass:[NSString class]] || ![a2 isKindOfClass:[NSString class]]) { \
[self failWithException:([NSException failureInFile:[NSString stringWithUTF8String:__FILE__] \
atLine:__LINE__ \
withDescription:@"%@", [@"Type mismatch -- " stringByAppendingString:STComposeString(description, ##__VA_ARGS__)]])]; \
} \
else { \
if (![a1 isEqualToString:a2]) { \
[self failWithException:([NSException failureInEqualityBetweenObject:a1 \
andObject:a2 \
inFile:[NSString stringWithUTF8String:__FILE__] \
atLine:__LINE__ \
withDescription:@" -- %@", STComposeString(description, ##__VA_ARGS__)])]; \
} \
} \
} \
@catch (id anException) {\
[self failWithException:([NSException \
failureInRaise:[NSString stringWithFormat:@"(%s) == (%s)", #a1, #a2] \
exception:anException \
inFile:[NSString stringWithUTF8String:__FILE__] \
atLine:__LINE__ \
withDescription:@"%@", STComposeString(description, ##__VA_ARGS__)])]; \
}\
} while(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment