本文整理了Java中org.hamcrest.number.IsCloseTo.<init>()
方法的一些代码示例,展示了IsCloseTo.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IsCloseTo.<init>()
方法的具体详情如下:
包路径:org.hamcrest.number.IsCloseTo
类名称:IsCloseTo
方法名:<init>
暂无
代码示例来源:origin: hamcrest/JavaHamcrest
/**
* Creates a matcher of {@link Double}s that matches when an examined double is equal
* to the specified <code>operand</code>, within a range of +/- <code>error</code>.
* For example:
* <pre>assertThat(1.03, is(closeTo(1.0, 0.03)))</pre>
*
* @param operand
* the expected value of matching doubles
* @param error
* the delta (+/-) within which matches will be allowed
*/
public static Matcher<Double> closeTo(double operand, double error) {
return new IsCloseTo(operand, error);
}
}
代码示例来源:origin: org.hamcrest/hamcrest-all
/**
* Creates a matcher of {@link Double}s that matches when an examined double is equal
* to the specified <code>operand</code>, within a range of +/- <code>error</code>.
* <p/>
* For example:
* <pre>assertThat(1.03, is(closeTo(1.0, 0.03)))</pre>
*
* @param operand
* the expected value of matching doubles
* @param error
* the delta (+/-) within which matches will be allowed
*/
@Factory
public static Matcher<Double> closeTo(double operand, double error) {
return new IsCloseTo(operand, error);
}
}
代码示例来源:origin: org.hamcrest/java-hamcrest
/**
* Creates a matcher of {@link Double}s that matches when an examined double is equal
* to the specified <code>operand</code>, within a range of +/- <code>error</code>.
* For example:
* <pre>assertThat(1.03, is(closeTo(1.0, 0.03)))</pre>
*
* @param operand
* the expected value of matching doubles
* @param error
* the delta (+/-) within which matches will be allowed
*/
public static Matcher<Double> closeTo(double operand, double error) {
return new IsCloseTo(operand, error);
}
}
代码示例来源:origin: org.hamcrest/hamcrest
/**
* Creates a matcher of {@link Double}s that matches when an examined double is equal
* to the specified <code>operand</code>, within a range of +/- <code>error</code>.
* For example:
* <pre>assertThat(1.03, is(closeTo(1.0, 0.03)))</pre>
*
* @param operand
* the expected value of matching doubles
* @param error
* the delta (+/-) within which matches will be allowed
*/
public static Matcher<Double> closeTo(double operand, double error) {
return new IsCloseTo(operand, error);
}
}
代码示例来源:origin: org.hamcrest/com.springsource.org.hamcrest
@Factory
public static Matcher<Double> closeTo(double operand, double error) {
return new IsCloseTo(operand, error);
}
代码示例来源:origin: stackoverflow.com
@SuppressWarnings({"rawtypes", "unchecked"})
public static Matcher<double[]> isArrayCloseTo(double[] expected) {
final double DELTA = 1e-10;
List<Matcher<Double>> matchers = new ArrayList<>();
for (double d : expected)
matchers.add(new IsCloseTo(d, DELTA));
return new CustomTypeSafeMatcher<double[]>("array that is close to" + Arrays.toString(expected)) {
@Override
protected boolean matchesSafely(double[] actual) {
return new IsArray<Double>(matchers.toArray(new Matcher[matchers.size()]))
.matchesSafely(Arrays.stream(actual).boxed().toArray(Double[]::new));
}
};
}
内容来源于网络,如有侵权,请联系作者删除!