1 package org.hamcrest.core; 2 3 import org.hamcrest.Matcher; 4 import org.junit.Test; 5 6 import static org.hamcrest.AbstractMatcherTest.assertDescription; 7 import static org.hamcrest.AbstractMatcherTest.assertMatches; 8 import static org.hamcrest.core.IsAnything.anything; 9 10 public final class IsAnythingTest { 11 12 private final Matcher<Object> matcher = anything(); 13 14 private static class CustomThing { } 15 16 @Test public void 17 alwaysEvaluatesToTrue() { 18 assertMatches("didn't match null", matcher, null); 19 assertMatches("didn't match Object", matcher, new Object()); 20 assertMatches("didn't match custom object", matcher, new CustomThing()); 21 assertMatches("didn't match String", matcher, "hi"); 22 } 23 24 @Test public void 25 hasUsefulDefaultDescription() { 26 assertDescription("ANYTHING", matcher); 27 } 28 29 @Test public void 30 canOverrideDescription() { 31 String description = "description"; 32 assertDescription(description, anything(description)); 33 } 34 35 } 36