/** * Checks that the subject is less than or equal to {@code other}. * * <p>Use {@link #isLessThan} to check that the subject is less than {@code other}. */ public final void isAtMost(T other) { if (actual().compareTo(other) > 0) { failWithActual("expected to be at most", other); } }
/** * Checks that the subject is equivalent to {@code other} according to {@link * Comparable#compareTo}, (i.e., checks that {@code a.comparesTo(b) == 0}). * * <p><b>Note:</b> Do not use this method for checking object equality. Instead, use {@link * #isEqualTo(Object)}. */ public void isEquivalentAccordingToCompareTo(T expected) { if (actual().compareTo(expected) != 0) { failWithActual("expected value that sorts equal to", expected); } }
/** * Checks that the subject is greater than or equal to {@code other}. * * <p>Use {@link #isGreaterThan} to check that the subject is greater than {@code other}. */ public final void isAtLeast(T other) { if (actual().compareTo(other) < 0) { failWithActual("expected to be at least", other); } } }
/** * Checks that the subject is greater than {@code other}. * * <p>Use {@link #isAtLeast} to check that the subject is greater than <i>or equal to</i> {@code * other}. */ public final void isGreaterThan(T other) { if (actual().compareTo(other) <= 0) { failWithActual("expected to be greater than", other); } }
/** Checks that the subject is in {@code range}. */ public final void isIn(Range<T> range) { if (!range.contains(actual())) { failWithActual("expected to be in range", range); } }
/** Checks that the subject is <i>not</i> in {@code range}. */ public final void isNotIn(Range<T> range) { if (range.contains(actual())) { failWithActual("expected not to be in range", range); } }
/** * Checks that the subject is less than {@code other}. * * <p>Use {@link #isAtMost} to check that the subject is less than <i>or equal to</i> {@code * other}. */ public final void isLessThan(T other) { if (actual().compareTo(other) >= 0) { failWithActual("expected to be less than", other); } }