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:
Eugene
2023-08-25 14:41:27 +02:00
committed by Stephane Nicoll
parent d0fc6dd06d
commit 33454a4007
5 changed files with 23 additions and 31 deletions
@@ -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);
}