001/*  Copyright (c) 2000-2006 hamcrest.org
002 */
003package org.hamcrest;
004
005
006public class MatcherAssert {
007    public static <T> void assertThat(T actual, Matcher<? super T> matcher) {
008        assertThat("", actual, matcher);
009    }
010    
011    public static <T> void assertThat(String reason, T actual, Matcher<? super T> matcher) {
012        if (!matcher.matches(actual)) {
013            Description description = new StringDescription();
014            description.appendText(reason)
015                       .appendText("\nExpected: ")
016                       .appendDescriptionOf(matcher)
017                       .appendText("\n     but: ");
018            matcher.describeMismatch(actual, description);
019            
020            throw new AssertionError(description.toString());
021        }
022    }
023    
024    public static void assertThat(String reason, boolean assertion) {
025        if (!assertion) {
026            throw new AssertionError(reason);
027        }
028    }
029}