|
2 | 2 | */ |
3 | 3 | package org.hamcrest.core; |
4 | 4 |
|
| 5 | +import static org.hamcrest.AbstractMatcherTest.assertDescription; |
| 6 | +import static org.hamcrest.AbstractMatcherTest.assertDoesNotMatch; |
| 7 | +import static org.hamcrest.AbstractMatcherTest.assertMatches; |
| 8 | +import static org.hamcrest.AbstractMatcherTest.assertNullSafe; |
| 9 | +import static org.hamcrest.AbstractMatcherTest.assertUnknownTypeSafe; |
5 | 10 | import static org.hamcrest.core.IsEqual.equalTo; |
6 | 11 | import static org.hamcrest.core.IsInstanceOf.instanceOf; |
7 | 12 | import static org.hamcrest.core.IsNot.not; |
8 | 13 |
|
9 | | -import org.hamcrest.AbstractMatcherTest; |
10 | 14 | import org.hamcrest.Matcher; |
| 15 | +import org.junit.Test; |
11 | 16 |
|
12 | | -public class IsNotTest extends AbstractMatcherTest { |
13 | | - @Override |
14 | | - protected Matcher<?> createMatcher() { |
15 | | - return not("something"); |
16 | | - } |
17 | | - |
18 | | - public void testEvaluatesToTheTheLogicalNegationOfAnotherMatcher() { |
19 | | - assertMatches("should match", not(equalTo("A")), "B"); |
20 | | - assertDoesNotMatch("should not match", not(equalTo("B")), "B"); |
21 | | - } |
22 | | - |
23 | | - public void testProvidesConvenientShortcutForNotEqualTo() { |
24 | | - assertMatches("should match", not("A"), "B"); |
25 | | - assertMatches("should match", not("B"), "A"); |
26 | | - assertDoesNotMatch("should not match", not("A"), "A"); |
27 | | - assertDoesNotMatch("should not match", not("B"), "B"); |
28 | | - } |
29 | | - |
30 | | - public void testUsesDescriptionOfNegatedMatcherWithPrefix() { |
31 | | - assertDescription("not an instance of java.lang.String", not(instanceOf(String.class))); |
32 | | - assertDescription("not \"A\"", not("A")); |
33 | | - } |
34 | | - } |
| 17 | +public final class IsNotTest { |
| 18 | + |
| 19 | + @Test public void |
| 20 | + copesWithNullsAndUnknownTypes() { |
| 21 | + Matcher<String> matcher = not("something"); |
| 22 | + |
| 23 | + assertNullSafe(matcher); |
| 24 | + assertUnknownTypeSafe(matcher); |
| 25 | + } |
| 26 | + |
| 27 | + @Test public void |
| 28 | + evaluatesToTheTheLogicalNegationOfAnotherMatcher() { |
| 29 | + final Matcher<String> matcher = not(equalTo("A")); |
| 30 | + |
| 31 | + assertMatches("didn't match", matcher, "B"); |
| 32 | + assertDoesNotMatch("matched unexpectedly", matcher, "A"); |
| 33 | + } |
| 34 | + |
| 35 | + @Test public void |
| 36 | + providesConvenientShortcutForNotEqualTo() { |
| 37 | + final Matcher<String> matcher = not("A"); |
| 38 | + |
| 39 | + assertMatches("didn't match", matcher, "B"); |
| 40 | + assertDoesNotMatch("matched unexpectedly", matcher, "A"); |
| 41 | + } |
| 42 | + |
| 43 | + @Test public void |
| 44 | + usesDescriptionOfNegatedMatcherWithPrefix() { |
| 45 | + assertDescription("not an instance of java.lang.String", not(instanceOf(String.class))); |
| 46 | + assertDescription("not \"A\"", not("A")); |
| 47 | + } |
| 48 | +} |
0 commit comments