1 package org.hamcrest; 2 3 4 public class MatcherAssert { assertThat(T actual, Matcher<? super T> matcher)5 public static <T> void assertThat(T actual, Matcher<? super T> matcher) { 6 assertThat("", actual, matcher); 7 } 8 assertThat(String reason, T actual, Matcher<? super T> matcher)9 public static <T> void assertThat(String reason, T actual, Matcher<? super T> matcher) { 10 if (!matcher.matches(actual)) { 11 Description description = new StringDescription(); 12 description.appendText(reason) 13 .appendText("\nExpected: ") 14 .appendDescriptionOf(matcher) 15 .appendText("\n but: "); 16 matcher.describeMismatch(actual, description); 17 18 throw new AssertionError(description.toString()); 19 } 20 } 21 assertThat(String reason, boolean assertion)22 public static void assertThat(String reason, boolean assertion) { 23 if (!assertion) { 24 throw new AssertionError(reason); 25 } 26 } 27 } 28