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
Fields -
Method Summary
Modifier and TypeMethodDescriptionbooleaninthashCode()offset(T value) strictOffset(T value) Creates a new strictOffsetthat letisCloseToassertion 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 newOffsetthat letisCloseToassertions 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 strictOffsetthat letisCloseToassertion 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
-