|
3 | 3 | package org.hamcrest.text; |
4 | 4 |
|
5 | 5 | import org.hamcrest.AbstractMatcherTest; |
6 | | -import org.hamcrest.Matcher; |
| 6 | +import static org.hamcrest.MatcherAssert.assertThat; |
| 7 | +import static org.hamcrest.core.IsNot.not; |
| 8 | +import static org.hamcrest.text.IsEqualIgnoringCase.eqIgnoringCase; |
7 | 9 |
|
8 | 10 | public class IsEqualIgnoringCaseTest extends AbstractMatcherTest { |
9 | 11 |
|
10 | | - private final Matcher matcher = new IsEqualIgnoringCase("heLLo"); |
11 | | - |
12 | 12 | public void testIgnoresCaseOfCharsInString() { |
13 | | - assertTrue(matcher.match("HELLO")); |
14 | | - assertTrue(matcher.match("hello")); |
15 | | - assertTrue(matcher.match("HelLo")); |
| 13 | + assertThat("HELLO", eqIgnoringCase("heLLo")); |
| 14 | + assertThat("hello", eqIgnoringCase("heLLo")); |
| 15 | + assertThat("HelLo", eqIgnoringCase("heLLo")); |
16 | 16 |
|
17 | | - assertFalse(matcher.match("abcde")); |
| 17 | + assertThat("bye", not(eqIgnoringCase("heLLo"))); |
18 | 18 | } |
19 | 19 |
|
20 | 20 | public void testFailsIfAdditionalWhitespaceIsPresent() { |
21 | | - assertFalse(matcher.match(" heLLo")); |
22 | | - assertFalse(matcher.match("heLLo ")); |
23 | | - } |
24 | | - |
25 | | - public void testFailsIfNotMatchingAgainstString() { |
26 | | - assertFalse(matcher.match(new Object())); |
| 21 | + assertThat("heLLo ", not(eqIgnoringCase("heLLo"))); |
| 22 | + assertThat(" heLLo", not(eqIgnoringCase("heLLo"))); |
27 | 23 | } |
28 | 24 |
|
29 | 25 | public void testFailsIfMatchingAgainstNull() { |
30 | | - assertFalse(matcher.match(null)); |
| 26 | + assertThat(null, not(eqIgnoringCase("heLLo"))); |
31 | 27 | } |
32 | 28 |
|
33 | 29 | public void testRequiresNonNullStringToBeConstructed() { |
34 | 30 | try { |
35 | | - new IsEqualIgnoringCase(null); |
| 31 | + eqIgnoringCase(null); |
36 | 32 | fail("Expected exception"); |
37 | 33 | } catch (IllegalArgumentException goodException) { |
38 | 34 | // expected! |
39 | 35 | } |
40 | 36 | } |
41 | 37 |
|
42 | 38 | public void testDescribesItselfAsCaseInsensitive() { |
43 | | - assertDescription("eqIgnoringCase(\"heLLo\")", matcher); |
| 39 | + assertDescription("eqIgnoringCase(\"heLLo\")", eqIgnoringCase("heLLo")); |
44 | 40 | } |
45 | 41 | } |
0 commit comments