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 thisComparableSubject
- Direct Known Subclasses:
BigDecimalSubject, DoubleSubject, FloatSubject, IntegerSubject, LongSubject, StringSubject
A subject for
Comparable values.-
Nested Class Summary
Nested classes/interfaces inherited from class Subject
Subject.Factory<SubjectT,ActualT> -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedComparableSubject(FailureMetadata metadata, @Nullable T actual) The constructor is for use by subclasses only. -
Method Summary
Modifier and TypeMethodDescriptionfinal voidChecks that the actual value is greater than or equal toother.final voidChecks that the actual value is less than or equal toother.voidisEquivalentAccordingToCompareTo(@Nullable T expected) Checks that the actual value is equivalent tootheraccording toComparable.compareTo(T), (i.e., checks thata.comparesTo(b) == 0).final voidisGreaterThan(@Nullable T other) Checks that the actual value is greater thanother.final voidChecks that the actual value is inrange.final voidisLessThan(@Nullable T other) Checks that the actual value is less thanother.final voidChecks that the actual value is not inrange.Methods inherited from class Subject
actualCustomStringRepresentation, check, equals, failWithActual, failWithActual, failWithoutActual, hashCode, ignoreCheck, isAnyOf, isEqualTo, isIn, isInstanceOf, isNoneOf, isNotEqualTo, isNotIn, isNotInstanceOf, isNotNull, isNotSameInstanceAs, isNull, isSameInstanceAs, toStringModifier and TypeMethodDescriptionprotected StringReturns a string representation of the actual value for inclusion in failure messages.protected final StandardSubjectBuilderReturns a builder for creating a derived subject.final booleanDeprecated.protected final voidfailWithActual(Fact first, Fact... rest) Fails, reporting a message with the given facts, followed by an automatically added fact of the form: but was: actual value.protected final voidfailWithActual(String key, @Nullable Object value) Fails, reporting a message with two "facts": key: value but was: actual value.protected final voidfailWithoutActual(Fact first, Fact... rest) Fails, reporting a message with the given facts, without automatically adding the actual value.final inthashCode()Deprecated.Object.hashCode()is not supported on Truth subjects.protected final StandardSubjectBuilderBegins a new call chain that ignores any failures.voidChecks that the value under test is equal to any of the given elements.voidChecks that the value under test is equal to the given object.voidChecks that the value under test is equal to any element in the given iterable.voidisInstanceOf(@Nullable Class<?> clazz) Checks that the value under test is an instance of the given class.voidChecks that the value under test is not equal to any of the given elements.voidisNotEqualTo(@Nullable Object other) Checks that the value under test is not equal to the given object.voidChecks that the value under test is not equal to any element in the given iterable.voidisNotInstanceOf(@Nullable Class<?> clazz) Checks that the value under test is not an instance of the given class.voidChecks that the value under test is not null.final voidisNotSameInstanceAs(@Nullable Object other) Checks that the value under test is not the same instance as the given object.voidisNull()Checks that the value under test is null.final voidisSameInstanceAs(@Nullable Object expected) Checks that the value under test is the same instance as the given object.toString()Deprecated.Object.toString()is not supported on Truth subjects.
-
Constructor Details
-
ComparableSubject
The constructor is for use by subclasses only. If you want to create an instance of this class itself, callcheck(...).that(actual).
-
-
Method Details
-
isIn
-
isNotIn
-
isEquivalentAccordingToCompareTo
Checks that the actual value is equivalent tootheraccording toComparable.compareTo(T), (i.e., checks thata.comparesTo(b) == 0).Note: Do not use this method for checking object equality. Instead, use
Subject.isEqualTo(Object). -
isGreaterThan
Checks that the actual value is greater thanother.To check that the actual value is greater than or equal to
other, useisAtLeast(T). -
isLessThan
Checks that the actual value is less thanother.To check that the actual value is less than or equal to
other, useisAtMost(T). -
isAtMost
Checks that the actual value is less than or equal toother.To check that the actual value is strictly less than
other, useisLessThan(T). -
isAtLeast
Checks that the actual value is greater than or equal toother.To check that the actual value is strictly greater than
other, useisGreaterThan(T).
-
Object.equals(Object)is not supported on Truth subjects.