public final class DoubleSubject extends ComparableSubject<DoubleSubject,Double>
Double
subjects.Modifier and Type | Class and Description |
---|---|
static class |
DoubleSubject.TolerantDoubleComparison
A partially specified proposition about an approximate relationship to a
double subject
using a tolerance. |
failureStrategy
Modifier and Type | Method and Description |
---|---|
void |
isEqualTo(Double other)
Deprecated.
Use
isWithin(double) instead. Double comparison should always have a tolerance. |
void |
isEquivalentAccordingToCompareTo(Double other)
Deprecated.
Use
isWithin(double) instead. Double comparison should always have a tolerance. |
void |
isFinite()
Asserts that the subject is finite, i.e.
|
void |
isNaN()
Asserts that the subject is
Double.NaN . |
void |
isNegativeInfinity()
Asserts that the subject is
Double.NEGATIVE_INFINITY . |
void |
isNotEqualTo(Double other)
Deprecated.
Use
isNotWithin(double) instead. Double comparison should always have a tolerance. |
void |
isNotNaN()
Asserts that the subject is not
Double.NaN (but it may be Double.POSITIVE_INFINITY or Double.NEGATIVE_INFINITY ). |
DoubleSubject.TolerantDoubleComparison |
isNotWithin(double 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
Double.POSITIVE_INFINITY . |
DoubleSubject.TolerantDoubleComparison |
isWithin(double 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
actual, actualAsString, actualCustomStringRepresentation, check, equals, fail, fail, fail, failWithBadResults, failWithCustomSubject, failWithoutActual, failWithoutSubject, failWithRawMessage, getDisplaySubject, getSubject, hashCode, internalCustomName, isAnyOf, isEqualTo, isIn, isInstanceOf, isNoneOf, isNotEqualTo, isNotIn, isNotInstanceOf, isNotNull, isNotSameAs, isNull, isSameAs, named
public DoubleSubject.TolerantDoubleComparison isWithin(double tolerance)
You can use a tolerance of 0.0
to assert the exact equality of finite doubles. 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 Double.POSITIVE_INFINITY
,
Double.NEGATIVE_INFINITY
, or Double.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 Double.NaN
, Double.POSITIVE_INFINITY
, or negative, including -0.0
public DoubleSubject.TolerantDoubleComparison isNotWithin(double tolerance)
You can use a tolerance of 0.0
to assert the exact inequality of finite doubles.
The check will fail if either the subject or the object is Double.POSITIVE_INFINITY
,
Double.NEGATIVE_INFINITY
, or Double.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 Double.NaN
, Double.POSITIVE_INFINITY
, or negative, including -0.0
@Deprecated public final void isEqualTo(@Nullable Double other)
isWithin(double)
instead. Double comparison should always have a tolerance.@Deprecated public final void isNotEqualTo(@Nullable Double other)
isNotWithin(double)
instead. Double comparison should always have a tolerance.@Deprecated public final void isEquivalentAccordingToCompareTo(Double other)
isWithin(double)
instead. Double 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<DoubleSubject,Double>
public final void isPositiveInfinity()
Double.POSITIVE_INFINITY
.public final void isNegativeInfinity()
Double.NEGATIVE_INFINITY
.public final void isNaN()
Double.NaN
.public final void isFinite()
Double.POSITIVE_INFINITY
, Double.NEGATIVE_INFINITY
, or Double.NaN
.public final void isNotNaN()
Double.NaN
(but it may be Double.POSITIVE_INFINITY
or Double.NEGATIVE_INFINITY
).Copyright © 2016. All rights reserved.