Index: src/test/OTAssert.h ================================================================== --- src/test/OTAssert.h +++ src/test/OTAssert.h @@ -29,14 +29,34 @@ #define OTAssertEqualObjects(a, b, ...) OTAssert([a isEqual: b], ## __VA_ARGS__) #define OTAssertNotEqualObjects(a, b, ...) \ OTAssert(![a isEqual: b], ## __VA_ARGS__) #define OTAssertNil(object, ...) OTAssert(object == nil, ## __VA_ARGS__) #define OTAssertNotNil(object, ...) OTAssert(object != nil, ## __VA_ARGS__) +#define OTAssertThrows(expression, ...) \ + { \ + bool OTThrown = false; \ + @try { \ + expression; \ + } @catch (id e) { \ + OTThrown = true; \ + } \ + OTAssert(OTThrown, ## __VA_ARGS__); \ + } +#define OTAssertThrowsSpecific(expression, exception, ...) \ + { \ + bool OTThrown = false; \ + @try { \ + expression; \ + } @catch (exception *e) { \ + OTThrown = true; \ + } \ + OTAssert(OTThrown, ## __VA_ARGS__); \ + } #ifdef __cplusplus extern "C" { #endif extern void OTAssertImpl(id testCase, SEL test, bool condition, OFString *check, OFString *file, size_t line, ...); #ifdef __cplusplus } #endif