This repository has been archived by the owner on Dec 2, 2019. It is now read-only.
forked from specta/expecta
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a toBeLessThanOrEqualTo matcher
- Loading branch information
Andrew Kitchen & Rachel Heaton
committed
Aug 24, 2011
1 parent
4a9a1d5
commit 7a7a7fa
Showing
6 changed files
with
82 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#import "Expecta.h" | ||
|
||
EXPMatcherInterface(_toBeLessThanOrEqualTo, (id expected)); | ||
EXPMatcherInterface(toBeLessThanOrEqualTo, (id expected)); | ||
|
||
#define toBeLessThanOrEqualTo(expected) _toBeLessThanOrEqualTo(EXPObjectify((expected))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#import "EXPMatchers+toBeLessThanOrEqualTo.h" | ||
#import "EXPMatcherHelpers.h" | ||
|
||
EXPMatcherImplementationBegin(_toBeLessThanOrEqualTo, (id expected)) { | ||
match(^BOOL{ | ||
if ([actual respondsToSelector:@selector(compare:)]) { | ||
return [actual compare:expected] != NSOrderedDescending; | ||
} | ||
return NO; | ||
}); | ||
|
||
failureMessageForTo(^NSString *{ | ||
return [NSString stringWithFormat:@"expected: %@ to be less than or equal to %@", EXPDescribeObject(actual), EXPDescribeObject(expected)]; | ||
}); | ||
|
||
failureMessageForNotTo(^NSString *{ | ||
return [NSString stringWithFormat:@"expected: %@ not to be less than or equal to %@", EXPDescribeObject(actual), EXPDescribeObject(expected)]; | ||
}); | ||
} | ||
EXPMatcherImplementationEnd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Expecta - EXPMatchers+toContainTest.m | ||
// Copyright (c) 2011 Peter Jihoon Kim | ||
// Licensed under the MIT License. | ||
|
||
#import "TestHelper.h" | ||
#import "NSValue+Expecta.h" | ||
|
||
@interface EXPMatchers_toBeLessThanOrEqualToTest : SenTestCase | ||
@end | ||
|
||
@implementation EXPMatchers_toBeLessThanOrEqualToTest | ||
|
||
- (void)test_toBeLessThanOrEqualTo { | ||
assertPass(test_expect(2).toBeLessThanOrEqualTo(3)); | ||
assertPass(test_expect(2).toBeLessThanOrEqualTo(2)); | ||
assertPass(test_expect(2).toBeLessThanOrEqualTo(2.1)); | ||
assertPass(test_expect(3.14).toBeLessThanOrEqualTo(3.14)); | ||
|
||
assertPass(test_expect([NSNumber numberWithInt:2]).toBeLessThanOrEqualTo([NSNumber numberWithInt:3])); | ||
assertPass(test_expect([NSNumber numberWithInt:2]).toBeLessThanOrEqualTo([NSNumber numberWithFloat:2.4f])); | ||
|
||
assertFail(test_expect(3).toBeLessThanOrEqualTo(2), @"foo.m:123 expected: 3 to be less than or equal to 2"); | ||
assertFail(test_expect(3.8).toBeLessThanOrEqualTo(3.2), @"foo.m:123 expected: 3.8 to be less than or equal to 3.2"); | ||
assertFail(test_expect([NSNumber numberWithInt:3]).toBeLessThanOrEqualTo([NSNumber numberWithInt:2]), @"foo.m:123 expected: 3 to be less than or equal to 2"); | ||
} | ||
|
||
- (void)test_Not_toBeLessThanOrEqualTo { | ||
assertPass(test_expect(3).Not.toBeLessThanOrEqualTo(2)); | ||
assertPass(test_expect(3.8).Not.toBeLessThanOrEqualTo(3.2)); | ||
assertPass(test_expect([NSNumber numberWithInt:3]).Not.toBeLessThanOrEqualTo([NSNumber numberWithInt:2])); | ||
|
||
assertFail(test_expect(2).Not.toBeLessThanOrEqualTo(3), @"foo.m:123 expected: 2 not to be less than or equal to 3"); | ||
assertFail(test_expect(3.2).Not.toBeLessThanOrEqualTo(3.8), @"foo.m:123 expected: 3.2 not to be less than or equal to 3.8"); | ||
assertFail(test_expect([NSNumber numberWithInt:2]).Not.toBeLessThanOrEqualTo([NSNumber numberWithInt:3]), @"foo.m:123 expected: 2 not to be less than or equal to 3"); | ||
} | ||
|
||
@end |