Skip to content

Commit 9e3875c

Browse files
committed
Merge PR hamcrest#43 (Change generic signature of OrderingComparison to accept Comparable<? super T>) and re-implement for new OrderingComparison/ComparatorMatcherBuilder mechanism.
2 parents 42ea059 + fbaa7c8 commit 9e3875c

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

hamcrest-library/src/test/java/org/hamcrest/number/OrderingComparisonTest.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,12 @@ public void testComparesBigDecimalsWithDifferentScalesCorrectlyForIssue20() {
6868
public void testComparesCustomTypesWhoseCompareToReturnsValuesGreaterThatOne() {
6969
assertThat(new CustomInt(5), lessThan(new CustomInt(10)));
7070
}
71+
72+
public void testComparesCustomTypesWhichExtendComparableClasses() {
73+
assertThat(new CustomExtendedInt(5), lessThan(new CustomExtendedInt(10)));
74+
}
7175

72-
private static final class CustomInt implements Comparable<CustomInt> {
76+
private static class CustomInt implements Comparable<CustomInt> {
7377
private final int value;
7478
public CustomInt(int value) {
7579
this.value = value;
@@ -79,4 +83,10 @@ public int compareTo(CustomInt other) {
7983
return value - other.value;
8084
}
8185
}
86+
87+
private static class CustomExtendedInt extends CustomInt {
88+
public CustomExtendedInt(int value) {
89+
super(value);
90+
}
91+
}
8292
}

0 commit comments

Comments
 (0)