Class FloatSubject
- java.lang.Object
- 
- com.google.common.truth.Subject
- 
- com.google.common.truth.ComparableSubject<Float>
- 
- com.google.common.truth.FloatSubject
 
 
 
- 
 public final class FloatSubject extends ComparableSubject<Float> A subject forFloatvalues.
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classFloatSubject.TolerantFloatComparisonA partially specified check about an approximate relationship to afloatvalue using a tolerance.- 
Nested classes/interfaces inherited from class com.google.common.truth.SubjectSubject.Factory<SubjectT extends Subject,ActualT>
 
- 
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidisAtLeast(int other)Checks that the actual value is greater than or equal toother.voidisAtMost(int other)Checks that the actual value is less than or equal toother.voidisEqualTo(@Nullable Object expected)Asserts that the actual value is exactly equal to the given value, with equality defined as byFloat.equals(java.lang.Object).voidisEquivalentAccordingToCompareTo(@Nullable Float expected)Deprecated.UseisWithin(float)orisEqualTo(java.lang.Object)instead (see documentation for advice).voidisFinite()Asserts that the actual value is finite, i.e. notFloat.POSITIVE_INFINITY,Float.NEGATIVE_INFINITY, orFloat.NaN.voidisGreaterThan(int other)Checks that the actual value is greater thanother.voidisLessThan(int other)Checks that the actual value is less thanother.voidisNaN()Asserts that the actual value isFloat.NaN.voidisNegativeInfinity()Asserts that the actual value isFloat.NEGATIVE_INFINITY.voidisNonZero()Asserts that the actual value is a non-null value other than zero (i.e. it is not0.0f,-0.0fornull).voidisNotEqualTo(@Nullable Object other)Asserts that the actual value is not exactly equal to the given value, with equality defined as byFloat.equals(java.lang.Object).voidisNotNaN()Asserts that the actual value is a non-null value other thanFloat.NaN(but it may beFloat.POSITIVE_INFINITYorFloat.NEGATIVE_INFINITY).FloatSubject.TolerantFloatComparisonisNotWithin(float tolerance)Prepares for a check that the actual value is a finite number not within the given tolerance of an expected value that will be provided in the next call in the fluent chain.voidisPositiveInfinity()Asserts that the actual value isFloat.POSITIVE_INFINITY.FloatSubject.TolerantFloatComparisonisWithin(float tolerance)Prepares for a check that the actual value is a finite number within the given tolerance of an expected value that will be provided in the next call in the fluent chain.voidisZero()Asserts that the actual value is zero (i.e. it is either0.0for-0.0f).- 
Methods inherited from class com.google.common.truth.ComparableSubjectisAtLeast, isAtMost, isGreaterThan, isIn, isLessThan, isNotIn
 - 
Methods inherited from class com.google.common.truth.SubjectactualCustomStringRepresentation, check, equals, failWithActual, failWithActual, failWithoutActual, hashCode, ignoreCheck, isAnyOf, isIn, isInstanceOf, isNoneOf, isNotIn, isNotInstanceOf, isNotNull, isNotSameInstanceAs, isNull, isSameInstanceAs, toString
 
- 
 
- 
- 
- 
Method Detail- 
isWithinpublic FloatSubject.TolerantFloatComparison isWithin(float tolerance) Prepares for a check that the actual value is a finite number within the given tolerance of an expected value that will be provided in the next call in the fluent chain.The check will fail if either the actual value or the expected value is Float.POSITIVE_INFINITY,Float.NEGATIVE_INFINITY, orFloat.NaN. To check for those values, useisPositiveInfinity(),isNegativeInfinity(),isNaN(), or (with more generality)isEqualTo(java.lang.Object).The check will pass if both values are zero, even if one is 0.0fand the other is-0.0f. UseisEqualTo(java.lang.Object)to assert that a value is exactly0.0for that it is exactly-0.0f.You can use a tolerance of 0.0fto assert the exact equality of finite floats, but oftenisEqualTo(java.lang.Object)is preferable (note the different behaviours around non-finite values and-0.0f). See the documentation onisEqualTo(java.lang.Object)for advice on when exact equality assertions are appropriate.- 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 finite value, i.e. not- Float.NaN,- Float.POSITIVE_INFINITY, or negative, including- -0.0f
 
 - 
isNotWithinpublic FloatSubject.TolerantFloatComparison isNotWithin(float tolerance) Prepares for a check that the actual value is a finite number not within the given tolerance of an expected value that will be provided in the next call in the fluent chain.The check will fail if either the actual value or the expected value is Float.POSITIVE_INFINITY,Float.NEGATIVE_INFINITY, orFloat.NaN. SeeisFinite(),isNotNaN(), orisNotEqualTo(java.lang.Object)for checks with other behaviours.The check will fail if both values are zero, even if one is 0.0fand the other is-0.0f. UseisNotEqualTo(java.lang.Object)for a test which fails for a value of exactly zero with one sign but passes for zero with the opposite sign.You can use a tolerance of 0.0fto assert the exact non-equality of finite floats, but sometimesisNotEqualTo(java.lang.Object)is preferable (note the different behaviours around non-finite values and-0.0f).- 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 finite value, i.e. not- Float.NaN,- Float.POSITIVE_INFINITY, or negative, including- -0.0f
 
 - 
isEqualTopublic void isEqualTo(@Nullable Object expected) Asserts that the actual value is exactly equal to the given value, with equality defined as byFloat.equals(java.lang.Object). This method is not recommended when the code under test is doing any kind of arithmetic: useisWithin(float)with a suitable tolerance in that case. (Remember that the exact result of floating point arithmetic is sensitive to apparently trivial changes such as replacing(a + b) + cwitha + (b + c).) This method is recommended when the code under test is specified as either copying a value without modification from its input or returning a well-defined literal or constant value.Note: The assertion isEqualTo(0.0f)fails for an input of-0.0f, and vice versa. For an assertion that passes for either0.0for-0.0f, useisZero().
 - 
isNotEqualTopublic void isNotEqualTo(@Nullable Object other) Asserts that the actual value is not exactly equal to the given value, with equality defined as byFloat.equals(java.lang.Object). SeeisEqualTo(java.lang.Object)for advice on when exact equality is recommended. UseisNotWithin(float)for an assertion with a tolerance.Note: The assertion isNotEqualTo(0.0f)passes for-0.0f, and vice versa. For an assertion that fails for either0.0for-0.0f, useisNonZero().- Overrides:
- isNotEqualToin class- Subject
 
 - 
isEquivalentAccordingToCompareTo@Deprecated public void isEquivalentAccordingToCompareTo(@Nullable Float expected) Deprecated.UseisWithin(float)orisEqualTo(java.lang.Object)instead (see documentation for advice).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 class- ComparableSubject<Float>
 
 - 
isZeropublic void isZero() Asserts that the actual value is zero (i.e. it is either0.0for-0.0f).
 - 
isNonZeropublic void isNonZero() Asserts that the actual value is a non-null value other than zero (i.e. it is not0.0f,-0.0fornull).
 - 
isPositiveInfinitypublic void isPositiveInfinity() Asserts that the actual value isFloat.POSITIVE_INFINITY.
 - 
isNegativeInfinitypublic void isNegativeInfinity() Asserts that the actual value isFloat.NEGATIVE_INFINITY.
 - 
isNaNpublic void isNaN() Asserts that the actual value isFloat.NaN.
 - 
isFinitepublic void isFinite() Asserts that the actual value is finite, i.e. notFloat.POSITIVE_INFINITY,Float.NEGATIVE_INFINITY, orFloat.NaN.
 - 
isNotNaNpublic void isNotNaN() Asserts that the actual value is a non-null value other thanFloat.NaN(but it may beFloat.POSITIVE_INFINITYorFloat.NEGATIVE_INFINITY).
 - 
isGreaterThanpublic 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).
 - 
isLessThanpublic 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).
 - 
isAtMostpublic 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).
 - 
isAtLeastpublic 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).
 
- 
 
-