public final class PrimitiveDoubleArraySubject extends AbstractArraySubject<PrimitiveDoubleArraySubject,double[]>
double[]
.
Note: this class deprecates some common methods because the operation of equality and comparison on floating point numbers requires additional specification. Alternative equality tests are provided.
Modifier and Type | Class and Description |
---|---|
static class |
PrimitiveDoubleArraySubject.TolerantPrimitiveDoubleArrayComparison
A partially specified proposition about an approximate relationship to a
double[]
subject using a tolerance. |
failureStrategy
Modifier and Type | Method and Description |
---|---|
PrimitiveDoubleArraySubject.TolerantPrimitiveDoubleArrayComparison |
hasValuesNotWithin(double tolerance)
Deprecated.
Write a for loop over the values looking for mismatches (see this implementation
for an example)
|
PrimitiveDoubleArraySubject.TolerantPrimitiveDoubleArrayComparison |
hasValuesWithin(double tolerance)
Prepares for a check that the subject and object are arrays both (a) of the same length, and
(b) where the values at all corresponding positions in each array are finite values within
tolerance of each other, that is assertThat(actual[i]).isWithin(tolerance).of(expected[i]) passes for all i (see the
isWithin assertion for doubles). |
void |
isEqualTo(Object expected)
Deprecated.
|
void |
isEqualTo(Object expected,
double tolerance)
Deprecated.
use
hasValuesWithin(double) , noting the different behaviour for non-finite
values |
void |
isNotEqualTo(Object expected)
Deprecated.
If you really want this, convert the array to a list, possibly using
Doubles.asList(double...) , and do the assertion on that, e.g. assertThat(asList(actualDoubleArray)).isNotEqualTo(asList(expectedDoubleArray)); . |
void |
isNotEqualTo(Object expectedArray,
double tolerance)
Deprecated.
Write a for loop over the values looking for mismatches (see this implementation
for an example)
|
protected List<Double> |
listRepresentation()
Returns a List representation suitable for displaying in a string.
|
protected String |
underlyingType() |
IterableSubject.UsingCorrespondence<Number,Number> |
withTolerance(double tolerance)
Starts a method chain for a test proposition in which the actual values (i.e.
|
actualCustomStringRepresentation, hasLength, isEmpty, isNotEmpty
actual, actualAsString, check, equals, fail, fail, fail, failWithBadResults, failWithCustomSubject, failWithoutActual, failWithoutSubject, failWithRawMessage, getDisplaySubject, getSubject, hashCode, internalCustomName, isAnyOf, isIn, isInstanceOf, isNoneOf, isNotIn, isNotInstanceOf, isNotNull, isNotSameAs, isNull, isSameAs, named
protected String underlyingType()
protected List<Double> listRepresentation()
AbstractArraySubject
@Deprecated public void isEqualTo(Object expected)
hasValuesWithin(double)
UnsupportedOperationException
.isEqualTo
in class Subject<PrimitiveDoubleArraySubject,double[]>
@Deprecated public void isEqualTo(Object expected, double tolerance)
hasValuesWithin(double)
, noting the different behaviour for non-finite
valuesexpected
is equal to each element in the subject,
and in the same position.
Behaviour for non-finite values (POSITIVE_INFINITY
, NEGATIVE_INFINITY
, and NaN
) is as follows: If the
subject and the object of the assertion are the same array, the test will pass. If not
(including if one is a clone of the other) then non-finite values are considered not equal so
the any non-finite value in either argument will cause the test to fail.
@Deprecated public void isNotEqualTo(Object expected)
Doubles.asList(double...)
, and do the assertion on that, e.g. assertThat(asList(actualDoubleArray)).isNotEqualTo(asList(expectedDoubleArray));
.UnsupportedOperationException
.isNotEqualTo
in class Subject<PrimitiveDoubleArraySubject,double[]>
@Deprecated public void isNotEqualTo(Object expectedArray, double tolerance)
Behaviour for non-finite values (POSITIVE_INFINITY
, NEGATIVE_INFINITY
, and NaN
) is as follows: If the
subject and the object of the assertion are the same array, the test will fail. If not
(including if one is a clone of the other) then non-finite values are considered not equal so
the any non-finite value in either argument will cause the test to pass.
public PrimitiveDoubleArraySubject.TolerantPrimitiveDoubleArrayComparison hasValuesWithin(double tolerance)
tolerance
of each other, that is assertThat(actual[i]).isWithin(tolerance).of(expected[i])
passes for all i
(see the
isWithin
assertion for doubles).
The check will fail if any value in either the subject array or the object array is Double.POSITIVE_INFINITY
, Double.NEGATIVE_INFINITY
, or Double.NaN
.
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
@Deprecated public PrimitiveDoubleArraySubject.TolerantPrimitiveDoubleArrayComparison hasValuesNotWithin(double tolerance)
tolerance
of each other, that is assertThat(actual[i]).isNotWithin(tolerance).of(expected[i])
passes for at least one i
(see the isNotWithin
assertion for doubles).
In the case (b), a pair of subject and object values will not cause the test to pass if
either of them is Double.POSITIVE_INFINITY
, Double.NEGATIVE_INFINITY
, or Double.NaN
.
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
public IterableSubject.UsingCorrespondence<Number,Number> withTolerance(double tolerance)
Correspondence
which
considers values to correspond if they are finite values within tolerance
of each
other. The proposition is actually executed by continuing the method chain. For example:
assertThat(actualDoubleArray).withTolerance(1.0e-5).contains(3.14159);
Number
instances which will
be converted to doubles, which may result in a loss of precision for some numeric types.
NullPointerException
if any
expected Number
instance is null.
tolerance
- an inclusive upper bound on the difference between the double values of the
actual and expected numbers, which must be a non-negative finite value, i.e. not Double.NaN
, Double.POSITIVE_INFINITY
, or negative, including -0.0
Copyright © 2016. All rights reserved.