Package org.hamcrest.number
Class BigDecimalCloseTo
- All Implemented Interfaces:
Matcher<BigDecimal>
,SelfDescribing
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate BigDecimal
actualDelta
(BigDecimal item) static Matcher
<BigDecimal> closeTo
(BigDecimal operand, BigDecimal error) Creates a matcher ofBigDecimal
s that matches when an examined BigDecimal is equal to the specifiedoperand
, 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.Methods inherited from class org.hamcrest.TypeSafeMatcher
describeMismatch, matches
Methods inherited from class org.hamcrest.BaseMatcher
_dont_implement_Matcher___instead_extend_BaseMatcher_, isNotNull, toString
-
Field Details
-
delta
-
value
-
-
Constructor Details
-
BigDecimalCloseTo
-
-
Method Details
-
matchesSafely
Description copied from class:TypeSafeMatcher
Subclasses should implement this. The item will already have been checked for the specific type and will never be null.- Specified by:
matchesSafely
in classTypeSafeMatcher<BigDecimal>
-
describeMismatchSafely
Description copied from class:TypeSafeMatcher
Subclasses should override this. The item will already have been checked for the specific type and will never be null.- Overrides:
describeMismatchSafely
in classTypeSafeMatcher<BigDecimal>
-
describeTo
Description copied from interface:SelfDescribing
Generates a description of the object. The description may be part of a a description of a larger object of which this is just a component, so it should be worded appropriately.- Parameters:
description
- The description to be built or appended to.
-
actualDelta
-
closeTo
Creates a matcher ofBigDecimal
s that matches when an examined BigDecimal is equal to the specifiedoperand
, within a range of +/-error
. The comparison for equality is done by BigDecimalsBigDecimal.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
-