aboutsummaryrefslogtreecommitdiff
path: root/hamcrest-core/src/main/java/org/hamcrest/MatcherAssert.java
diff options
context:
space:
mode:
Diffstat (limited to 'hamcrest-core/src/main/java/org/hamcrest/MatcherAssert.java')
-rw-r--r--hamcrest-core/src/main/java/org/hamcrest/MatcherAssert.java51
1 files changed, 27 insertions, 24 deletions
diff --git a/hamcrest-core/src/main/java/org/hamcrest/MatcherAssert.java b/hamcrest-core/src/main/java/org/hamcrest/MatcherAssert.java
index 3eb234a..049e1df 100644
--- a/hamcrest-core/src/main/java/org/hamcrest/MatcherAssert.java
+++ b/hamcrest-core/src/main/java/org/hamcrest/MatcherAssert.java
@@ -1,24 +1,27 @@
-/* Copyright (c) 2000-2006 hamcrest.org
- */
-package org.hamcrest;
-
-
-public class MatcherAssert {
- public static <T> void assertThat(T actual, Matcher<T> matcher) {
- assertThat("", actual, matcher);
- }
-
- public static <T> void assertThat(String reason, T actual, Matcher<T> matcher) {
- if (!matcher.matches(actual)) {
- Description description = new StringDescription();
- description.appendText(reason)
- .appendText("\nExpected: ")
- .appendDescriptionOf(matcher)
- .appendText("\n got: ")
- .appendValue(actual)
- .appendText("\n");
-
- throw new java.lang.AssertionError(description.toString());
- }
- }
-}
+package org.hamcrest;
+
+
+public class MatcherAssert {
+ public static <T> void assertThat(T actual, Matcher<? super T> matcher) {
+ assertThat("", actual, matcher);
+ }
+
+ public static <T> void assertThat(String reason, T actual, Matcher<? super T> matcher) {
+ if (!matcher.matches(actual)) {
+ Description description = new StringDescription();
+ description.appendText(reason)
+ .appendText("\nExpected: ")
+ .appendDescriptionOf(matcher)
+ .appendText("\n but: ");
+ matcher.describeMismatch(actual, description);
+
+ throw new AssertionError(description.toString());
+ }
+ }
+
+ public static void assertThat(String reason, boolean assertion) {
+ if (!assertion) {
+ throw new AssertionError(reason);
+ }
+ }
+}