I wrote this matcher to check the contents of a double[]:
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 IsArray(matchers.toArray(new Matcher[matchers.size()]));
}The method looks fine, but it always fails:
assertThat(new double[] { .1 }, isArrayCloseTo(new double[] { .1 })); //failsI see elsewhere on the list that a matcher for double arrays has been provided, but I would like to know for future reference what is wrong with what I'm doing so that I won't repeat it again later.
Thanks for your time!
Nate