Skip to content

Commit

Permalink
Use <? super T> in Assert.assertThat
Browse files Browse the repository at this point in the history
As the Matcher is only a consumer, ? super T is more appropriate.  Otherwise, a Matcher<Object> cannot be used with a String actual, for example.
  • Loading branch information
fbarber committed Sep 28, 2011
1 parent 61f0654 commit 1cff207
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/java/org/junit/Assert.java
Expand Up @@ -734,7 +734,7 @@ public static void assertEquals(Object[] expecteds, Object[] actuals) {
* @see org.hamcrest.CoreMatchers * @see org.hamcrest.CoreMatchers
* @see org.junit.matchers.JUnitMatchers * @see org.junit.matchers.JUnitMatchers
*/ */
public static <T> void assertThat(T actual, Matcher<T> matcher) { public static <T> void assertThat(T actual, Matcher<? super T> matcher) {
assertThat("", actual, matcher); assertThat("", actual, matcher);
} }


Expand Down Expand Up @@ -768,7 +768,7 @@ public static <T> void assertThat(T actual, Matcher<T> matcher) {
* @see org.junit.matchers.JUnitMatchers * @see org.junit.matchers.JUnitMatchers
*/ */
public static <T> void assertThat(String reason, T actual, public static <T> void assertThat(String reason, T actual,
Matcher<T> matcher) { Matcher<? super T> matcher) {
if (!matcher.matches(actual)) { if (!matcher.matches(actual)) {
Description description= new StringDescription(); Description description= new StringDescription();
description.appendText(reason); description.appendText(reason);
Expand Down

0 comments on commit 1cff207

Please sign in to comment.