You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
session-ios/Signal/test/util/ExceptionsTest.m

41 lines
1.0 KiB
Matlab

11 years ago
#import "ExceptionsTest.h"
#import "Constraints.h"
#import "TestUtil.h"
@implementation ExceptionsTest
-(void) testContracts {
require(1 + 1 == 2);
@try {
require(1 + 1 == 3);
XCTFail(@"");
11 years ago
} @catch (BadArgument* ex) {
test([[ex reason] hasPrefix:@"require 1 + 1 == 3"]);
}
requireState(1 + 1 == 2);
@try {
requireState(1 + 1 == 3);
XCTFail(@"");
11 years ago
} @catch (BadState* ex) {
test([[ex reason] hasPrefix:@"required state: 1 + 1 == 3"]);
}
checkOperationDescribe(1 + 1 == 2, @"addition.");
@try {
checkOperationDescribe(1 + 1 == 3, @"addition.");
XCTFail(@"");
11 years ago
} @catch (OperationFailed* ex) {
test([[ex reason] hasPrefix:@"Operation failed: addition. Expected: 1 + 1 == 3"]);
}
checkOperation(1 + 1 == 2);
@try {
checkOperation(1 + 1 == 3);
XCTFail(@"");
11 years ago
} @catch (OperationFailed* ex) {
test([[ex reason] hasPrefix:@"Operation failed. Expected: 1 + 1 == 3"]);
}
}
@end