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.- Author:
- Kurt Alfred Kluever
-
Nested Class Summary
Nested classes/interfaces inherited from class com.google.common.truth.Subject
Subject.Factory<SubjectT extends Subject, ActualT>
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
ComparableSubject
(FailureMetadata metadata, @Nullable T actual) Constructor for use by subclasses. -
Method Summary
Modifier and TypeMethodDescriptionfinal void
Checks that the actual value is greater than or equal toother
.final void
Checks that the actual value is less than or equal toother
.void
isEquivalentAccordingToCompareTo
(@Nullable T expected) Checks that the actual value is equivalent toother
according toComparable.compareTo(T)
, (i.e., checks thata.comparesTo(b) == 0
).final void
isGreaterThan
(@Nullable T other) Checks that the actual value is greater thanother
.final void
Checks that the actual value is inrange
.final void
isLessThan
(@Nullable T other) Checks that the actual value is less thanother
.final void
Checks that the actual value is not inrange
.Methods inherited from class com.google.common.truth.Subject
actualCustomStringRepresentation, check, equals, failWithActual, failWithActual, failWithoutActual, hashCode, ignoreCheck, isAnyOf, isEqualTo, isIn, isInstanceOf, isNoneOf, isNotEqualTo, isNotIn, isNotInstanceOf, isNotNull, isNotSameInstanceAs, isNull, isSameInstanceAs, toString
-
Constructor Details
-
ComparableSubject
Constructor for use by subclasses. 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 toother
according 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)
.
-