Package com.google.common.truth
Class ComparableSubject<T extends java.lang.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
public abstract class ComparableSubject<T extends java.lang.Comparable> extends Subject
Propositions forComparable
typed subjects.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.google.common.truth.Subject
Subject.EqualityCheck, Subject.Factory<SubjectT extends Subject,ActualT>
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ComparableSubject(FailureMetadata metadata, T actual)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
isAtLeast(T other)
Checks that the subject is greater than or equal toother
.void
isAtMost(T other)
Checks that the subject is less than or equal toother
.void
isEquivalentAccordingToCompareTo(T expected)
Checks that the subject is equivalent toother
according toComparable.compareTo(T)
, (i.e., checks thata.comparesTo(b) == 0
).void
isGreaterThan(T other)
Checks that the subject is greater thanother
.void
isIn(com.google.common.collect.Range<T> range)
Checks that the subject is inrange
.void
isLessThan(T other)
Checks that the subject is less thanother
.void
isNotIn(com.google.common.collect.Range<T> range)
Checks that the subject is not inrange
.-
Methods inherited from class com.google.common.truth.Subject
actual, actualCustomStringRepresentation, actualCustomStringRepresentationForPackageMembersToCall, butWas, check, check, checkNoNeedToDisplayBothValues, equals, fail, fail, fail, failEqualityCheckForEqualsWithoutDescription, failWithActual, failWithActual, failWithActual, failWithActual, failWithBadResults, failWithCustomSubject, failWithoutActual, failWithoutActual, failWithoutActual, failWithoutActual, failWithoutSubject, hashCode, ignoreCheck, isAnyOf, isEqualTo, isIn, isInstanceOf, isNoneOf, isNotEqualTo, isNotIn, isNotInstanceOf, isNotNull, isNotSameInstanceAs, isNull, isSameInstanceAs, toString, typeDescription
-
-
-
-
Field Detail
-
actual
private final T extends java.lang.Comparable actual
Constructor for use by subclasses. If you want to create an instance of this class itself, callcheck(...)
.that(actual)
.
-
-
Constructor Detail
-
ComparableSubject
protected ComparableSubject(FailureMetadata metadata, T actual)
-
-
Method Detail
-
isIn
public final void isIn(com.google.common.collect.Range<T> range)
Checks that the subject is inrange
.
-
isNotIn
public final void isNotIn(com.google.common.collect.Range<T> range)
Checks that the subject is not inrange
.
-
isEquivalentAccordingToCompareTo
public void isEquivalentAccordingToCompareTo(T expected)
Checks that the subject 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
public final void isGreaterThan(T other)
Checks that the subject is greater thanother
.To check that the subject is greater than or equal to
other
, useisAtLeast(T)
.
-
isLessThan
public final void isLessThan(T other)
Checks that the subject is less thanother
.To check that the subject is less than or equal to
other
, useisAtMost(T)
.
-
isAtMost
public final void isAtMost(T other)
Checks that the subject is less than or equal toother
.To check that the subject is strictly less than
other
, useisLessThan(T)
.
-
isAtLeast
public final void isAtLeast(T other)
Checks that the subject is greater than or equal toother
.To check that the subject is strictly greater than
other
, useisGreaterThan(T)
.
-
-