From 891d2a28c10cbb50dbf0ed95159cbdde61b2874f Mon Sep 17 00:00:00 2001 From: Seth Buntin Date: Sun, 18 Oct 2009 19:10:27 -0500 Subject: [PATCH] implement CPException tests --- Tests/Foundation/CPExceptionTest.j | 49 ++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 Tests/Foundation/CPExceptionTest.j diff --git a/Tests/Foundation/CPExceptionTest.j b/Tests/Foundation/CPExceptionTest.j new file mode 100644 index 000000000..6451e32b5 --- /dev/null +++ b/Tests/Foundation/CPExceptionTest.j @@ -0,0 +1,49 @@ +@import + +@implementation CPExceptionTest : OJTestCase +{ +} + +- (void)setUp +{ + exception = [CPException exceptionWithName:@"CPGenericException" + reason:@"Margins must be positive" + userInfo:nil]; +} + +- (void)testInitWithNameReasonUserInfo +{ + var exception = [[CPException alloc] initWithName:@"CPUnsupportedMethodException" + reason:@"setHeaderCell: is not supported. -setHeaderCell:aView instead." + userInfo:nil]; + [self assert:[exception name] equals:"CPUnsupportedMethodException"]; + [self assert:[exception reason] equals:"setHeaderCell: is not supported. -setHeaderCell:aView instead."]; + [self assertThrows:function(){[exception raise]}]; +} + +- (void)testRaiseReason +{ + [self assertThrows:function(){[CPException raise:@"CPGenericException" reason:@"Margins must be positive"];}]; +} + +- (void)testName +{ + [self assert:[exception name] equals:@"CPGenericException"]; +} + +- (void)testReason +{ + [self assert:[exception reason] equals:@"Margins must be positive"]; +} + +- (void)testUserInfo +{ + [self assert:[exception userInfo] equals:null]; +} + +- (void)testRaise +{ + [self assertThrows:function(){[exception raise];}]; +} + +@end