@CheckReturnValue public final class FloatSubject extends ComparableSubject<FloatSubject,Float>
Float
subjects.Modifier and Type | Class and Description |
---|---|
class |
FloatSubject.TolerantFloatComparison
A partially specified proposition about an approximate relationship to a
float
subject using a tolerance. |
failureStrategy
Modifier and Type | Method and Description |
---|---|
void |
isEqualTo(Float other)
Deprecated.
Use
isWithin(float) instead. Float comparison should always have a tolerance. |
void |
isEquivalentAccordingToCompareTo(Float other)
Deprecated.
Use
isWithin(float) instead. Float comparison should always have a tolerance. |
void |
isFinite()
Asserts that the subject is finite, i.e.
|
void |
isNaN()
Asserts that the subject is
Float.NaN . |
void |
isNegativeInfinity()
Asserts that the subject is
Float.NEGATIVE_INFINITY . |
void |
isNotEqualTo(Float other)
Deprecated.
Use
isNotWithin(float) instead. Float comparison should always have a tolerance. |
void |
isNotNaN()
Asserts that the subject is not
Float.NaN (but it may be
Float.POSITIVE_INFINITY or Float.NEGATIVE_INFINITY ). |
FloatSubject.TolerantFloatComparison |
isNotWithin(float tolerance)
Prepares for a check that the subject 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.
|
void |
isPositiveInfinity()
Asserts that the subject is
Float.POSITIVE_INFINITY . |
FloatSubject.TolerantFloatComparison |
isWithin(float tolerance)
Prepares for a check that the subject is a finite number within the given tolerance of an
expected value that will be provided in the next call in the fluent chain.
|
comparesEqualTo, isAtLeast, isAtMost, isGreaterThan, isIn, isLessThan, isNotIn
check, equals, fail, fail, fail, failWithBadResults, failWithCustomSubject, failWithoutSubject, failWithRawMessage, getDisplaySubject, getSubject, hashCode, internalCustomName, isAnyOf, isEqualTo, isIn, isInstanceOf, isNoneOf, isNotEqualTo, isNotIn, isNotInstanceOf, isNotNull, isNotSameAs, isNull, isSameAs, named
public FloatSubject.TolerantFloatComparison isWithin(float tolerance)
You can use a tolerance of 0.0f
to assert the exact equality of finite floats. This
is appropriate when the contract of the code under test guarantees this, e.g. by specifying
that a return value is copied unchanged from the input, by specifying an exact constant value
to be returned, or by specifying an exact sequence of arithmetic operations to be followed.
The check will fail if either the subject or the object is
Float.POSITIVE_INFINITY
, Float.NEGATIVE_INFINITY
, or Float.NaN
. To
check for those values, use isPositiveInfinity()
, isNegativeInfinity
, or
isNaN
.
tolerance
- an inclusive upper bound on the difference between the subject and object
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
public FloatSubject.TolerantFloatComparison isNotWithin(float tolerance)
You can use a tolerance of 0.0f
to assert the exact inequality of finite floats.
The check will fail if either the subject or the object is
Float.POSITIVE_INFINITY
, Float.NEGATIVE_INFINITY
, or Float.NaN
.
See isFinite()
and isNotNaN()
, or use ComparableSubject.isIn(com.google.common.collect.Range<T>)
with a suitable
Range
.
tolerance
- an exclusive lower bound on the difference between the subject and object
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
@Deprecated public final void isEqualTo(@Nullable Float other)
isWithin(float)
instead. Float comparison should always have a tolerance.@Deprecated public final void isNotEqualTo(@Nullable Float other)
isNotWithin(float)
instead. Float comparison should always have a tolerance.@Deprecated public final void isEquivalentAccordingToCompareTo(Float other)
isWithin(float)
instead. Float comparison should always have a tolerance.ComparableSubject
Comparable.compareTo(T)
, (i.e., fails if a.comparesTo(b) != 0
).
Note: Do not use this method for checking object equality. Instead, use
Subject.isEqualTo(Object)
.
isEquivalentAccordingToCompareTo
in class ComparableSubject<FloatSubject,Float>
public final void isPositiveInfinity()
Float.POSITIVE_INFINITY
.public final void isNegativeInfinity()
Float.NEGATIVE_INFINITY
.public final void isNaN()
Float.NaN
.public final void isFinite()
Float.POSITIVE_INFINITY
,
Float.NEGATIVE_INFINITY
, or Float.NaN
.public final void isNotNaN()
Float.NaN
(but it may be
Float.POSITIVE_INFINITY
or Float.NEGATIVE_INFINITY
).Copyright © 2015. All Rights Reserved.