Package org.assertj.core.data
Class Offset<T extends Number>
java.lang.Object
org.assertj.core.data.Offset<T>
- Type Parameters:
T
- the type of the offset value.
A positive offset.
- Author:
- Alex Ruiz, Yvonne Wang
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
int
hashCode()
offset
(T value) strictOffset
(T value) Creates a new strictOffset
that letisCloseTo
assertion pass when|actual-expected| < offset value
.toString()
-
Field Details
-
value
-
strict
public final boolean strictWhen |actual-expected|=offset and strict is true the assertThat(actual).isCloseTo(expected, offset); assertion will fail.
-
-
Method Details
-
offset
Creates a newOffset
that letisCloseTo
assertions pass when|actual-expected| <= offset value
.Example:
// assertions succeed assertThat(8.1).isCloseTo(8.0, offset(0.2)); assertThat(8.1).isCloseTo(8.0, offset(0.1)); // assertion fails assertThat(8.1).isCloseTo(8.0, offset(0.01));
- Type Parameters:
T
- the type of value of theOffset
.- Parameters:
value
- the value of the offset.- Returns:
- the created
Offset
. - Throws:
NullPointerException
- if the given value isnull
.IllegalArgumentException
- if the given value is negative.
-
strictOffset
Creates a new strictOffset
that letisCloseTo
assertion pass when|actual-expected| < offset value
.Examples:
// assertion succeeds assertThat(8.1).isCloseTo(8.0, offset(0.2)); // assertions fail assertThat(8.1).isCloseTo(8.0, offset(0.1)); assertThat(8.1).isCloseTo(8.0, offset(0.01));
- Type Parameters:
T
- the type of value of theOffset
.- Parameters:
value
- the value of the offset.- Returns:
- the created
Offset
. - Throws:
NullPointerException
- if the given value isnull
.IllegalArgumentException
- if the given value is negative.
-
equals
-
hashCode
public int hashCode() -
toString
-