public class BigDecimalCloseTo extends TypeSafeMatcher<java.math.BigDecimal>
Constructor and Description |
---|
BigDecimalCloseTo(java.math.BigDecimal value,
java.math.BigDecimal error) |
Modifier and Type | Method and Description |
---|---|
static Matcher<java.math.BigDecimal> |
closeTo(java.math.BigDecimal operand,
java.math.BigDecimal error)
Creates a matcher of
BigDecimal s 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_, toString
public BigDecimalCloseTo(java.math.BigDecimal value, java.math.BigDecimal error)
public boolean matchesSafely(java.math.BigDecimal item)
TypeSafeMatcher
matchesSafely
in class TypeSafeMatcher<java.math.BigDecimal>
public void describeMismatchSafely(java.math.BigDecimal item, Description mismatchDescription)
TypeSafeMatcher
describeMismatchSafely
in class TypeSafeMatcher<java.math.BigDecimal>
public void describeTo(Description description)
SelfDescribing
description
- The description to be built or appended to.public static Matcher<java.math.BigDecimal> closeTo(java.math.BigDecimal operand, java.math.BigDecimal error)
BigDecimal
s 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