org.hamcrest.number
Class BigDecimalCloseTo
java.lang.Object
org.hamcrest.BaseMatcher<T>
org.hamcrest.TypeSafeMatcher<BigDecimal>
org.hamcrest.number.BigDecimalCloseTo
- All Implemented Interfaces:
- Matcher<BigDecimal>, SelfDescribing
public class BigDecimalCloseTo
- extends TypeSafeMatcher<BigDecimal>
BigDecimalCloseTo
public BigDecimalCloseTo(BigDecimal value,
BigDecimal error)
matchesSafely
public boolean matchesSafely(BigDecimal item)
- Specified by:
matchesSafely in class TypeSafeMatcher<BigDecimal>
describeMismatchSafely
public void describeMismatchSafely(BigDecimal item,
Description mismatchDescription)
- Overrides:
describeMismatchSafely in class TypeSafeMatcher<BigDecimal>
describeTo
public void describeTo(Description description)
closeTo
public static Matcher<BigDecimal> closeTo(BigDecimal operand,
BigDecimal error)
- Creates a matcher of
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"))))
- Parameters:
operand - the expected value of matching BigDecimalserror - the delta (+/-) within which matches will be allowed
Copyright © 2014. All rights reserved.