mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
3c3f782e7d
// FREEBIE
43 lines
1.1 KiB
Objective-C
43 lines
1.1 KiB
Objective-C
//
|
|
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
|
//
|
|
|
|
#import "ExceptionsTest.h"
|
|
#import "TestUtil.h"
|
|
|
|
@implementation ExceptionsTest
|
|
- (void)testContracts {
|
|
ows_require(1 + 1 == 2);
|
|
@try {
|
|
ows_require(1 + 1 == 3);
|
|
XCTFail(@"");
|
|
} @catch (BadArgument *ex) {
|
|
test([[ex reason] hasPrefix:@"require 1 + 1 == 3"]);
|
|
}
|
|
|
|
requireState(1 + 1 == 2);
|
|
@try {
|
|
requireState(1 + 1 == 3);
|
|
XCTFail(@"");
|
|
} @catch (BadState *ex) {
|
|
test([[ex reason] hasPrefix:@"required state: 1 + 1 == 3"]);
|
|
}
|
|
|
|
checkOperationDescribe(1 + 1 == 2, @"addition.");
|
|
@try {
|
|
checkOperationDescribe(1 + 1 == 3, @"addition.");
|
|
XCTFail(@"");
|
|
} @catch (OperationFailed *ex) {
|
|
test([[ex reason] hasPrefix:@"Operation failed: addition. Expected: 1 + 1 == 3"]);
|
|
}
|
|
|
|
checkOperation(1 + 1 == 2);
|
|
@try {
|
|
checkOperation(1 + 1 == 3);
|
|
XCTFail(@"");
|
|
} @catch (OperationFailed *ex) {
|
|
test([[ex reason] hasPrefix:@"Operation failed. Expected: 1 + 1 == 3"]);
|
|
}
|
|
}
|
|
|
|
@end
|