Package com.google.common.truth
Class IntegerSubject
- java.lang.Object
-
- com.google.common.truth.Subject
-
- com.google.common.truth.ComparableSubject<Integer>
-
- com.google.common.truth.IntegerSubject
-
public class IntegerSubject extends ComparableSubject<Integer>
A subject forIntegervalues.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classIntegerSubject.TolerantIntegerComparisonA partially specified check about an approximate relationship to aintactual value using a tolerance.-
Nested classes/interfaces inherited from class com.google.common.truth.Subject
Subject.Factory<SubjectT extends Subject,ActualT>
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedIntegerSubject(FailureMetadata metadata, @Nullable Integer actual)The constructor is for use by subclasses only.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidisEquivalentAccordingToCompareTo(@Nullable Integer expected)Deprecated.UseSubject.isEqualTo(java.lang.Object)instead.IntegerSubject.TolerantIntegerComparisonisNotWithin(int 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.IntegerSubject.TolerantIntegerComparisonisWithin(int 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 Detail
-
IntegerSubject
protected IntegerSubject(FailureMetadata metadata, @Nullable Integer actual)
The constructor is for use by subclasses only. If you want to create an instance of this class itself, callcheck(...).that(actual).
-
-
Method Detail
-
isWithin
public IntegerSubject.TolerantIntegerComparison isWithin(int 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.- 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
public IntegerSubject.TolerantIntegerComparison isNotWithin(int 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.- 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 public final void isEquivalentAccordingToCompareTo(@Nullable Integer expected)
Deprecated.UseSubject.isEqualTo(java.lang.Object)instead. Integer comparison is consistent with equality.Description copied from class:ComparableSubjectChecks 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).- Overrides:
isEquivalentAccordingToCompareToin classComparableSubject<Integer>
-
-