blob: 2c867126c067a3fa15730439d4bf8114a7dbc2bc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
package org.hamcrest;
import org.junit.Test;
import static org.hamcrest.AbstractMatcherTest.*;
public final class CustomTypeSafeMatcherTest {
private static final String STATIC_DESCRIPTION = "I match non empty strings";
private final Matcher<String> customMatcher = new CustomTypeSafeMatcher<String>(STATIC_DESCRIPTION) {
@Override
public boolean matchesSafely(String item) {
return false;
}
@Override
public void describeMismatchSafely(String item, Description mismatchDescription) {
mismatchDescription.appendText("an " + item);
}
};
@Test public void
usesStaticDescription() throws Exception {
assertDescription(STATIC_DESCRIPTION, customMatcher);
}
@Test public void
reportsMismatch() {
assertMismatchDescription("an item", customMatcher, "item");
}
@Test public void
isNullSafe() {
assertNullSafe(customMatcher);
}
@Test public void
copesWithUnknownTypes() {
assertUnknownTypeSafe(customMatcher);
}
}
|