Skip to content

Commit

Permalink
Add test for type variance in hasEntry (hamcrest#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
tumbarumba committed Sep 22, 2024
1 parent 804b583 commit 73d0617
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.util.Map;
import java.util.TreeMap;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.collection.IsMapContaining.hasEntry;
import static org.hamcrest.core.IsAnything.anything;
import static org.hamcrest.core.IsEqual.equalTo;
Expand Down Expand Up @@ -47,4 +48,11 @@ public void testHasReadableDescription() {
assertDescription("map containing [\"a\"-><2>]", hasEntry(equalTo("a"), (equalTo(2))));
}

public void testTypeVariance() {
Map<String, Number> m = new HashMap<>();
Integer foo = 6;
m.put("foo", foo);
assertThat(m, hasEntry("foo", foo));
}

}

0 comments on commit 73d0617

Please sign in to comment.