Package org.assertj.core.data
Class Offset<T extends Number>
- java.lang.Object
-
- org.assertj.core.data.Offset<T>
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
int
hashCode()
static <T extends Number>
Offset<T>offset(T value)
static <T extends Number>
Offset<T>strictOffset(T value)
Creates a new strictOffset
that letisCloseTo
assertion pass when|actual-expected| < offset value
.String
toString()
-
-
-
Constructor Detail
-
Offset
private Offset(T value, boolean strict)
-
-
Method Detail
-
offset
public static <T extends Number> Offset<T> offset(T value)
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
public static <T extends Number> Offset<T> strictOffset(T value)
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.
-
-