aboutsummaryrefslogtreecommitdiff
path: root/integration/src/org/hamcrest/MatcherAssert.java
blob: 3eb234a346c3f909c31d5830af27ef5480475685 (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
/*  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());
        }
    }
}