org.hamcrest.number
Class IsCloseTo
java.lang.Object
org.hamcrest.BaseMatcher<T>
org.hamcrest.TypeSafeMatcher<Double>
org.hamcrest.number.IsCloseTo
- All Implemented Interfaces:
- Matcher<Double>, SelfDescribing
public class IsCloseTo
- extends TypeSafeMatcher<Double>
Is the value a number equal to a value within some range of
acceptable error?
|
Constructor Summary |
IsCloseTo(double value,
double error)
|
IsCloseTo
public IsCloseTo(double value,
double error)
matchesSafely
public boolean matchesSafely(Double item)
- Specified by:
matchesSafely in class TypeSafeMatcher<Double>
describeMismatchSafely
public void describeMismatchSafely(Double item,
Description mismatchDescription)
- Overrides:
describeMismatchSafely in class TypeSafeMatcher<Double>
describeTo
public void describeTo(Description description)
closeTo
public static Matcher<Double> closeTo(double operand,
double error)
- Creates a matcher of
Doubles that matches when an examined double is equal
to the specified operand, within a range of +/- error.
For example:
assertThat(1.03, is(closeTo(1.0, 0.03)))
- Parameters:
operand - the expected value of matching doubleserror - the delta (+/-) within which matches will be allowed
Copyright © 2014. All rights reserved.