public class BigDecimalCloseTo extends TypeSafeMatcher<java.math.BigDecimal>
| Modifier and Type | Field and Description |
|---|---|
private java.math.BigDecimal |
delta |
private java.math.BigDecimal |
value |
| Constructor and Description |
|---|
BigDecimalCloseTo(java.math.BigDecimal value,
java.math.BigDecimal error) |
| Modifier and Type | Method and Description |
|---|---|
private java.math.BigDecimal |
actualDelta(java.math.BigDecimal item) |
static Matcher<java.math.BigDecimal> |
closeTo(java.math.BigDecimal operand,
java.math.BigDecimal error)
Creates a matcher of
BigDecimals that matches when an examined BigDecimal is equal
to the specified operand, within a range of +/- error. |
void |
describeMismatchSafely(java.math.BigDecimal item,
Description mismatchDescription)
Subclasses should override this.
|
void |
describeTo(Description description)
Generates a description of the object.
|
boolean |
matchesSafely(java.math.BigDecimal item)
Subclasses should implement this.
|
describeMismatch, matches_dont_implement_Matcher___instead_extend_BaseMatcher_, isNotNull, toStringprivate final java.math.BigDecimal delta
private final java.math.BigDecimal value
public BigDecimalCloseTo(java.math.BigDecimal value,
java.math.BigDecimal error)
public boolean matchesSafely(java.math.BigDecimal item)
TypeSafeMatchermatchesSafely in class TypeSafeMatcher<java.math.BigDecimal>public void describeMismatchSafely(java.math.BigDecimal item,
Description mismatchDescription)
TypeSafeMatcherdescribeMismatchSafely in class TypeSafeMatcher<java.math.BigDecimal>public void describeTo(Description description)
SelfDescribingdescription - The description to be built or appended to.private java.math.BigDecimal actualDelta(java.math.BigDecimal item)
public static Matcher<java.math.BigDecimal> closeTo(java.math.BigDecimal operand, java.math.BigDecimal error)
BigDecimals that matches when an examined BigDecimal is equal
to the specified operand, within a range of +/- error. The comparison for equality
is done by BigDecimals BigDecimal.compareTo(java.math.BigDecimal) method.
For example:
assertThat(new BigDecimal("1.03"), is(closeTo(new BigDecimal("1.0"), new BigDecimal("0.03"))))operand - the expected value of matching BigDecimalserror - the delta (+/-) within which matches will be allowed