Skip to content

Commit cce6e4b

Browse files
committed
convert to JUnit4
1 parent 4ed7934 commit cce6e4b

1 file changed

Lines changed: 27 additions & 19 deletions

File tree

‎hamcrest-core/src/test/java/org/hamcrest/core/IsNullTest.java‎

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,47 @@
22
*/
33
package org.hamcrest.core;
44

5-
import static org.hamcrest.MatcherAssert.assertThat;
6-
import static org.hamcrest.core.IsNot.not;
5+
import static org.hamcrest.AbstractMatcherTest.assertDoesNotMatch;
6+
import static org.hamcrest.AbstractMatcherTest.assertMatches;
7+
import static org.hamcrest.AbstractMatcherTest.assertNullSafe;
8+
import static org.hamcrest.AbstractMatcherTest.assertUnknownTypeSafe;
79
import static org.hamcrest.core.IsNull.notNullValue;
810
import static org.hamcrest.core.IsNull.nullValue;
911

10-
import java.math.BigDecimal;
11-
12-
import org.hamcrest.AbstractMatcherTest;
1312
import org.hamcrest.Matcher;
13+
import org.junit.Test;
1414

1515

16-
public class IsNullTest extends AbstractMatcherTest {
17-
private static final BigDecimal ANY_NON_NULL_ARGUMENT = new BigDecimal(66);
18-
19-
@Override
20-
protected Matcher<?> createMatcher() {
21-
return nullValue();
22-
}
16+
public final class IsNullTest {
2317

24-
public void testEvaluatesToTrueIfArgumentIsNull() {
25-
assertThat(null, nullValue());
26-
assertThat(ANY_NON_NULL_ARGUMENT, not(nullValue()));
18+
private final Matcher<Object> nullMatcher = nullValue();
19+
private final Matcher<Object> notNullMatcher = notNullValue();
2720

28-
assertThat(ANY_NON_NULL_ARGUMENT, notNullValue());
29-
assertThat(null, not(notNullValue()));
21+
@Test public void
22+
copesWithNullsAndUnknownTypes() {
23+
assertNullSafe(nullMatcher);
24+
assertUnknownTypeSafe(nullMatcher);
25+
26+
assertNullSafe(notNullMatcher);
27+
assertUnknownTypeSafe(notNullMatcher);
3028
}
3129

32-
public void testSupportsStaticTyping() {
30+
@Test public void
31+
evaluatesToTrueIfArgumentIsNull() {
32+
assertMatches("didn't match", nullMatcher, null);
33+
assertDoesNotMatch("matched unexpectedly", nullMatcher, new Object());
34+
35+
assertMatches("didn't match", notNullMatcher, new Object());
36+
assertDoesNotMatch("matched unexpectedly", notNullMatcher, null);
37+
}
38+
39+
@Test public void
40+
supportsStaticTyping() {
3341
requiresStringMatcher(nullValue(String.class));
3442
requiresStringMatcher(notNullValue(String.class));
3543
}
3644

3745
private void requiresStringMatcher(@SuppressWarnings("unused") Matcher<String> arg) {
3846
// no-op
39-
}
47+
}
4048
}

0 commit comments

Comments
 (0)