Package org.assertj.core.api
Interface FloatingPointNumberAssert<SELF extends FloatingPointNumberAssert<SELF,ACTUAL>,ACTUAL extends java.lang.Number>
-
- Type Parameters:
SELF
- the "self" type of this assertion class. Please read "Emulating 'self types' using Java Generics to simplify fluent API implementation" for more details.ACTUAL
- the type of the "actual" value.
- All Superinterfaces:
NumberAssert<SELF,ACTUAL>
- All Known Implementing Classes:
AbstractDoubleAssert
,AbstractFloatAssert
,DoubleAssert
,FloatAssert
public interface FloatingPointNumberAssert<SELF extends FloatingPointNumberAssert<SELF,ACTUAL>,ACTUAL extends java.lang.Number> extends NumberAssert<SELF,ACTUAL>
Assertion methods applicable to floating-point
s.Number
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description SELF
isCloseTo(ACTUAL expected, Offset<ACTUAL> offset)
Verifies that the actual number is close to the given one within the given offset.
If difference is equal to offset value, assertion is considered valid.SELF
isEqualTo(ACTUAL expected, Offset<ACTUAL> offset)
Verifies that the actual value is close to the given one by less than the given offset.
If difference is equal to offset value, assertion is considered valid.SELF
isNaN()
Verifies that the actual value is equal toNaN
.SELF
isNotCloseTo(ACTUAL expected, Offset<ACTUAL> offset)
Verifies that the actual number is not close to the given one by less than the given offset.
If the difference is equal to the offset value, the assertion fails.SELF
isNotNaN()
Verifies that the actual value is not equal toNaN
.-
Methods inherited from interface org.assertj.core.api.NumberAssert
isBetween, isCloseTo, isNegative, isNotCloseTo, isNotNegative, isNotPositive, isNotZero, isOne, isPositive, isStrictlyBetween, isZero
-
-
-
-
Method Detail
-
isEqualTo
SELF isEqualTo(ACTUAL expected, Offset<ACTUAL> offset)
Verifies that the actual value is close to the given one by less than the given offset.
If difference is equal to offset value, assertion is considered valid.Example with double:
// assertion will pass: assertThat(8.1).isEqualTo(new Double(8.0), offset(0.2)); // if difference is exactly equals to the offset (0.1), it's ok assertThat(8.1).isEqualTo(new Double(8.0), offset(0.1)); // within is an alias of offset assertThat(8.1).isEqualTo(new Double(8.0), within(0.1)); // assertion will fail assertThat(8.1).isEqualTo(new Double(8.0), offset(0.01));
- Parameters:
expected
- the given value to compare the actual value to.offset
- the given positive offset.- Returns:
this
assertion object.- Throws:
java.lang.NullPointerException
- if the given offset isnull
.java.lang.NullPointerException
- if the expected number isnull
.java.lang.AssertionError
- if the actual value is not equal to the given one.
-
isCloseTo
SELF isCloseTo(ACTUAL expected, Offset<ACTUAL> offset)
Verifies that the actual number is close to the given one within the given offset.
If difference is equal to offset value, assertion is considered valid.Example with double:
// assertions will pass: assertThat(8.1).isCloseTo(new Double(8.0), within(0.2)); // you can use offset if you prefer assertThat(8.1).isCloseTo(new Double(8.0), offset(0.2)); // if difference is exactly equals to the offset (0.1), it's ok assertThat(8.1).isCloseTo(new Double(8.0), within(0.1)); // assertion will fail assertThat(8.1).isCloseTo(new Double(8.0), within(0.01));
- Specified by:
isCloseTo
in interfaceNumberAssert<SELF extends FloatingPointNumberAssert<SELF,ACTUAL>,ACTUAL extends java.lang.Number>
- Parameters:
expected
- the given number to compare the actual value to.offset
- the given positive offset.- Returns:
this
assertion object.- Throws:
java.lang.NullPointerException
- if the given offset isnull
.java.lang.NullPointerException
- if the expected number isnull
.java.lang.AssertionError
- if the actual value is not close to the given one.
-
isNotCloseTo
SELF isNotCloseTo(ACTUAL expected, Offset<ACTUAL> offset)
Verifies that the actual number is not close to the given one by less than the given offset.
If the difference is equal to the offset value, the assertion fails.Example with double:
// assertions will pass: assertThat(8.3).isNotCloseTo(new Double(8.0), byLessThan(0.2)); // you can use offset if you prefer assertThat(8.3).isNotCloseTo(new Double(8.0), offset(0.2)); // assertions will fail assertThat(8.1).isNotCloseTo(new Double(8.0), byLessThan(0.1)); assertThat(8.1).isNotCloseTo(new Double(8.0), byLessThan(0.2));
- Specified by:
isNotCloseTo
in interfaceNumberAssert<SELF extends FloatingPointNumberAssert<SELF,ACTUAL>,ACTUAL extends java.lang.Number>
- Parameters:
expected
- the given number to compare the actual value to.offset
- the given positive offset.- Returns:
this
assertion object.- Throws:
java.lang.NullPointerException
- if the given offset isnull
.java.lang.NullPointerException
- if the expected number isnull
.java.lang.AssertionError
- if the actual value is equal to the given one.- Since:
- 2.6.0 / 3.6.0
- See Also:
Assertions.byLessThan(Double)
-
isNaN
SELF isNaN()
Verifies that the actual value is equal toNaN
.Example:
// assertions will pass assertThat(Double.NaN).isNaN(); assertThat(0.0 / 0.0).isNaN(); assertThat(0.0F * Float.POSITIVE_INFINITY).isNaN(); // assertions will fail assertThat(1.0).isNaN(); assertThat(-1.0F).isNaN();
- Returns:
- this assertion object.
- Throws:
java.lang.AssertionError
- if the actual value is not equal toNaN
.
-
isNotNaN
SELF isNotNaN()
Verifies that the actual value is not equal toNaN
.Example:
// assertions will pass assertThat(1.0).isNotNaN(); assertThat(-1.0F).isNotNaN(); // assertions will fail assertThat(Double.NaN).isNotNaN(); assertThat(0.0 / 0.0).isNotNaN(); assertThat(0.0F * Float.POSITIVE_INFINITY).isNotNaN();
- Returns:
- this assertion object.
- Throws:
java.lang.AssertionError
- if the actual value is equal toNaN
.
-
-