Use Comparable instead of dedicated implementations
This commit deprecates ComparableComparator and NullSafeComparator in favor of the available convenient implementation in the JDK. See gh-25478
This commit is contained in:
@@ -29,34 +29,35 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @author Keith Donald
|
||||
* @author Chris Beams
|
||||
* @author Phillip Webb
|
||||
* @author Eugene Rabii
|
||||
*/
|
||||
class BooleanComparatorTests {
|
||||
|
||||
@Test
|
||||
void shouldCompareWithTrueLow() {
|
||||
Comparator<Boolean> c = new BooleanComparator(true);
|
||||
assertThat(c.compare(true, false)).isEqualTo(-1);
|
||||
assertThat(c.compare(true, false)).isLessThan(0);
|
||||
assertThat(c.compare(Boolean.TRUE, Boolean.TRUE)).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldCompareWithTrueHigh() {
|
||||
Comparator<Boolean> c = new BooleanComparator(false);
|
||||
assertThat(c.compare(true, false)).isEqualTo(1);
|
||||
assertThat(c.compare(true, false)).isGreaterThan(0);
|
||||
assertThat(c.compare(Boolean.TRUE, Boolean.TRUE)).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldCompareFromTrueLow() {
|
||||
Comparator<Boolean> c = BooleanComparator.TRUE_LOW;
|
||||
assertThat(c.compare(true, false)).isEqualTo(-1);
|
||||
assertThat(c.compare(true, false)).isLessThan(0);
|
||||
assertThat(c.compare(Boolean.TRUE, Boolean.TRUE)).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldCompareFromTrueHigh() {
|
||||
Comparator<Boolean> c = BooleanComparator.TRUE_HIGH;
|
||||
assertThat(c.compare(true, false)).isEqualTo(1);
|
||||
assertThat(c.compare(true, false)).isGreaterThan(0);
|
||||
assertThat(c.compare(Boolean.TRUE, Boolean.TRUE)).isEqualTo(0);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user