Class ComparableSubject<T extends Comparable>

java.lang.Object
com.google.common.truth.Subject
com.google.common.truth.ComparableSubject<T>
Type Parameters:
T - the type of the object being tested by this ComparableSubject
Direct Known Subclasses:
BigDecimalSubject, DoubleSubject, FloatSubject, IntegerSubject, LongSubject, StringSubject

public abstract class ComparableSubject<T extends Comparable> extends Subject
Propositions for Comparable typed subjects.
  • Field Details

    • actual

      private final T extends Comparable actual
      Constructor for use by subclasses. If you want to create an instance of this class itself, call check(...).that(actual).
  • Constructor Details

    • ComparableSubject

      protected ComparableSubject(FailureMetadata metadata, T actual)
  • Method Details

    • isIn

      public final void isIn(com.google.common.collect.Range<T> range)
      Checks that the subject is in range.
    • isNotIn

      public final void isNotIn(com.google.common.collect.Range<T> range)
      Checks that the subject is not in range.
    • isEquivalentAccordingToCompareTo

      public void isEquivalentAccordingToCompareTo(T expected)
      Checks that the subject is equivalent to other according to Comparable.compareTo(T), (i.e., checks that a.comparesTo(b) == 0).

      Note: Do not use this method for checking object equality. Instead, use Subject.isEqualTo(Object).

    • isGreaterThan

      public final void isGreaterThan(T other)
      Checks that the subject is greater than other.

      To check that the subject is greater than or equal to other, use isAtLeast(T).

    • isLessThan

      public final void isLessThan(T other)
      Checks that the subject is less than other.

      To check that the subject is less than or equal to other, use isAtMost(T).

    • isAtMost

      public final void isAtMost(T other)
      Checks that the subject is less than or equal to other.

      To check that the subject is strictly less than other, use isLessThan(T).

    • isAtLeast

      public final void isAtLeast(T other)
      Checks that the subject is greater than or equal to other.

      To check that the subject is strictly greater than other, use isGreaterThan(T).