Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 102 lines (78 sloc) 4.02 kB
4f0c627 @allending First release.
authored
1 //
2 // Licensed under the terms in License.txt
3 //
4 // Copyright 2010 Allen Ding. All rights reserved.
5 //
6
7 #import "Kiwi.h"
8 #import "KiwiTestConfiguration.h"
9 #import "TestClasses.h"
10
11 #if KW_TESTS_ENABLED
12
13 @interface KWInequalityMatcherTest : SenTestCase
14
15 @end
16
17 @implementation KWInequalityMatcherTest
18
19 - (void)testItShouldHaveTheRightMatcherStrings {
20 NSArray *matcherStrings = [KWInequalityMatcher matcherStrings];
e48c398 @stepanhruda Updated code to modern Objective-C syntax (literals)
stepanhruda authored
21 NSArray *expectedStrings = @[@"beLessThan:",
4f0c627 @allending First release.
authored
22 @"beLessThanOrEqualTo:",
23 @"beGreaterThan:",
e48c398 @stepanhruda Updated code to modern Objective-C syntax (literals)
stepanhruda authored
24 @"beGreaterThanOrEqualTo:"];
4f0c627 @allending First release.
authored
25 STAssertEqualObjects([matcherStrings sortedArrayUsingSelector:@selector(compare:)],
26 [expectedStrings sortedArrayUsingSelector:@selector(compare:)],
27 @"expected specific matcher strings");
28 }
29
30 - (void)testItShouldMatchGreaterValuesForGreaterThan {
31 id subject = [KWValue valueWithInt:42];
32 id matcher = [KWInequalityMatcher matcherWithSubject:subject];
33 [matcher beGreaterThan:[KWValue valueWithInt:40]];
34 STAssertTrue([matcher evaluate], @"expected positive match");
b940a6e @mattdipasquale Convert \t to 4 spaces. Rm trailing whitespace.
mattdipasquale authored
35
4f0c627 @allending First release.
authored
36 matcher = [KWInequalityMatcher matcherWithSubject:subject];
37 [matcher beGreaterThanOrEqualTo:[KWValue valueWithInt:40]];
38 STAssertTrue([matcher evaluate], @"expected positive match");
39
40 matcher = [KWInequalityMatcher matcherWithSubject:subject];
41 [matcher beGreaterThanOrEqualTo:[KWValue valueWithInt:42]];
42 STAssertTrue([matcher evaluate], @"expected positive match");
43 }
44
45 - (void)testItShouldNotMatchNonGreaterValuesForGreaterThan {
46 id subject = [KWValue valueWithInt:42];
47 id matcher = [KWInequalityMatcher matcherWithSubject:subject];
48 [matcher beGreaterThan:[KWValue valueWithInt:43]];
49 STAssertFalse([matcher evaluate], @"expected negative match");
50
51 matcher = [KWInequalityMatcher matcherWithSubject:subject];
52 [matcher beGreaterThanOrEqualTo:[KWValue valueWithInt:43]];
53 STAssertFalse([matcher evaluate], @"expected negative match");
54 }
55
56 - (void)testItShouldMatchLesserValuesForLessThan {
57 id subject = [KWValue valueWithInt:42];
58 id matcher = [KWInequalityMatcher matcherWithSubject:subject];
59 [matcher beLessThan:[KWValue valueWithInt:43]];
60 STAssertTrue([matcher evaluate], @"expected positive match");
61
62 matcher = [KWInequalityMatcher matcherWithSubject:subject];
63 [matcher beLessThanOrEqualTo:[KWValue valueWithInt:43]];
64 STAssertTrue([matcher evaluate], @"expected positive match");
65
66 matcher = [KWInequalityMatcher matcherWithSubject:subject];
67 [matcher beLessThanOrEqualTo:[KWValue valueWithInt:42]];
68 STAssertTrue([matcher evaluate], @"expected positive match");
69 }
70
71 - (void)testItShouldNotMatchNonLesserValuesForLessThan {
72 id subject = [KWValue valueWithInt:42];
73 id matcher = [KWInequalityMatcher matcherWithSubject:subject];
74 [matcher beLessThan:[KWValue valueWithInt:41]];
75 STAssertFalse([matcher evaluate], @"expected negative match");
76
77 matcher = [KWInequalityMatcher matcherWithSubject:subject];
78 [matcher beLessThanOrEqualTo:[KWValue valueWithInt:41]];
79 STAssertFalse([matcher evaluate], @"expected negative match");
80 }
81
24de39e @lukeredpath Add descriptions to matchers so we can generate nice names for anonym…
lukeredpath authored
82 - (void)testItShouldHaveHumanReadableDescription
83 {
84 id matcher = [KWInequalityMatcher matcherWithSubject:theValue(123)];
85
86 [matcher beLessThan:[KWValue valueWithInt:10]];
87 STAssertEqualObjects(@"be < 10", [matcher description], @"description should match");
b940a6e @mattdipasquale Convert \t to 4 spaces. Rm trailing whitespace.
mattdipasquale authored
88
24de39e @lukeredpath Add descriptions to matchers so we can generate nice names for anonym…
lukeredpath authored
89 [matcher beLessThanOrEqualTo:[KWValue valueWithInt:10]];
90 STAssertEqualObjects(@"be <= 10", [matcher description], @"description should match");
b940a6e @mattdipasquale Convert \t to 4 spaces. Rm trailing whitespace.
mattdipasquale authored
91
24de39e @lukeredpath Add descriptions to matchers so we can generate nice names for anonym…
lukeredpath authored
92 [matcher beGreaterThan:[KWValue valueWithInt:10]];
93 STAssertEqualObjects(@"be > 10", [matcher description], @"description should match");
b940a6e @mattdipasquale Convert \t to 4 spaces. Rm trailing whitespace.
mattdipasquale authored
94
24de39e @lukeredpath Add descriptions to matchers so we can generate nice names for anonym…
lukeredpath authored
95 [matcher beGreaterThanOrEqualTo:[KWValue valueWithInt:10]];
96 STAssertEqualObjects(@"be >= 10", [matcher description], @"description should match");
97 }
98
4f0c627 @allending First release.
authored
99 @end
100
101 #endif // #if KW_TESTS_ENABLED
Something went wrong with that request. Please try again.