Class LongSubject
A subject for
long
values.- Author:
- David Saff, Christian Gruber (cgruber@israfil.net), Kurt Alfred Kluever
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
A partially specified check about an approximate relationship to along
value using a tolerance.Nested classes/interfaces inherited from class com.google.common.truth.Subject
Subject.Factory<SubjectT extends Subject, ActualT>
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
LongSubject
(FailureMetadata metadata, @Nullable Long actual) Constructor for use by subclasses. -
Method Summary
Modifier and TypeMethodDescriptionfinal void
isAtLeast
(int other) Checks that the actual value is greater than or equal toother
.final void
isAtMost
(int other) Checks that the actual value is less than or equal toother
.final void
Deprecated.final void
isGreaterThan
(int other) Checks that the actual value is greater thanother
.final void
isLessThan
(int other) Checks that the actual value is less thanother
.isNotWithin
(long tolerance) Prepares for a check that the actual value is a number not within the given tolerance of an expected value that will be provided in the next call in the fluent chain.isWithin
(long tolerance) Prepares for a check that the actual value is a number within the given tolerance of an expected value that will be provided in the next call in the fluent chain.Methods inherited from class com.google.common.truth.ComparableSubject
isAtLeast, isAtMost, isGreaterThan, isIn, isLessThan, isNotIn
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
-
LongSubject
Constructor for use by subclasses. If you want to create an instance of this class itself, callcheck(...)
.that(actual)
.
-
-
Method Details
-
isWithin
Prepares for a check that the actual value is a number within the given tolerance of an expected value that will be provided in the next call in the fluent chain.- Parameters:
tolerance
- an inclusive upper bound on the difference between the actual value and expected value allowed by the check, which must be a non-negative value.- Since:
- 1.2
-
isNotWithin
Prepares for a check that the actual value is a number not within the given tolerance of an expected value that will be provided in the next call in the fluent chain.- Parameters:
tolerance
- an exclusive lower bound on the difference between the actual value and expected value allowed by the check, which must be a non-negative value.- Since:
- 1.2
-
isEquivalentAccordingToCompareTo
Deprecated.UseSubject.isEqualTo(java.lang.Object)
instead. Long comparison is consistent with equality.Description copied from class:ComparableSubject
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)
.- Overrides:
isEquivalentAccordingToCompareTo
in classComparableSubject<Long>
-
isGreaterThan
public final void isGreaterThan(int other) Checks that the actual value is greater thanother
.To check that the actual value is greater than or equal to
other
, useisAtLeast(int)
. -
isLessThan
public final void isLessThan(int other) Checks that the actual value is less thanother
.To check that the actual value is less than or equal to
other
, useisAtMost(int)
. -
isAtMost
public final void isAtMost(int other) Checks that the actual value is less than or equal toother
.To check that the actual value is strictly less than
other
, useisLessThan(int)
. -
isAtLeast
public final void isAtLeast(int other) Checks that the actual value is greater than or equal toother
.To check that the actual value is strictly greater than
other
, useisGreaterThan(int)
.
-
Subject.isEqualTo(java.lang.Object)
instead.