aboutsummaryrefslogtreecommitdiff
path: root/hamcrest-core/src/test/java/org/hamcrest/core/IsNotTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'hamcrest-core/src/test/java/org/hamcrest/core/IsNotTest.java')
-rw-r--r--hamcrest-core/src/test/java/org/hamcrest/core/IsNotTest.java42
1 files changed, 42 insertions, 0 deletions
diff --git a/hamcrest-core/src/test/java/org/hamcrest/core/IsNotTest.java b/hamcrest-core/src/test/java/org/hamcrest/core/IsNotTest.java
new file mode 100644
index 0000000..79f4683
--- /dev/null
+++ b/hamcrest-core/src/test/java/org/hamcrest/core/IsNotTest.java
@@ -0,0 +1,42 @@
+package org.hamcrest.core;
+
+import org.hamcrest.Matcher;
+import org.junit.Test;
+
+import static org.hamcrest.AbstractMatcherTest.*;
+import static org.hamcrest.core.IsEqual.equalTo;
+import static org.hamcrest.core.IsInstanceOf.instanceOf;
+import static org.hamcrest.core.IsNot.not;
+
+public final class IsNotTest {
+
+ @Test public void
+ copesWithNullsAndUnknownTypes() {
+ Matcher<String> matcher = not("something");
+
+ assertNullSafe(matcher);
+ assertUnknownTypeSafe(matcher);
+ }
+
+ @Test public void
+ evaluatesToTheTheLogicalNegationOfAnotherMatcher() {
+ final Matcher<String> matcher = not(equalTo("A"));
+
+ assertMatches(matcher, "B");
+ assertDoesNotMatch(matcher, "A");
+ }
+
+ @Test public void
+ providesConvenientShortcutForNotEqualTo() {
+ final Matcher<String> matcher = not("A");
+
+ assertMatches(matcher, "B");
+ assertDoesNotMatch(matcher, "A");
+ }
+
+ @Test public void
+ usesDescriptionOfNegatedMatcherWithPrefix() {
+ assertDescription("not an instance of java.lang.String", not(instanceOf(String.class)));
+ assertDescription("not \"A\"", not("A"));
+ }
+}