public class BigDecimalCloseTo extends TypeSafeMatcher<BigDecimal>
Constructor and Description |
---|
BigDecimalCloseTo(BigDecimal value,
BigDecimal error) |
Modifier and Type | Method and Description |
---|---|
static Matcher<BigDecimal> |
closeTo(BigDecimal operand,
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(BigDecimal item,
Description mismatchDescription)
Subclasses should override this.
|
void |
describeTo(Description description)
Generates a description of the object.
|
boolean |
matchesSafely(BigDecimal item)
Subclasses should implement this.
|
describeMismatch, matches
_dont_implement_Matcher___instead_extend_BaseMatcher_, isNotNull, toString
public BigDecimalCloseTo(BigDecimal value, BigDecimal error)
public boolean matchesSafely(BigDecimal item)
TypeSafeMatcher
matchesSafely
in class TypeSafeMatcher<BigDecimal>
public void describeMismatchSafely(BigDecimal item, Description mismatchDescription)
TypeSafeMatcher
describeMismatchSafely
in class TypeSafeMatcher<BigDecimal>
public void describeTo(Description description)
SelfDescribing
description
- The description to be built or appended to.public static Matcher<BigDecimal> closeTo(BigDecimal operand, 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 allowedCopyright © 2020. All rights reserved.