I'm currently writing a Junit test where I use assertEquals()
to compare the value of two ArrayList<Double>
.
@Test
public void test(){
QuadraticFormula one = new QuadraticFormula(3, 4, -4);
List<Double> results = new ArrayList<>();
results.add(0.66666);
results.add(-2.0);
assertEquals(results, one.getRoots());
}
However, Junit prints out the following failure message:
expected:<[0.66666, -2.0]> but was:<[0.6666666666666666, -2.0]>
junit.framework.AssertionFailedError
Is there anyway I can specify how many decimal places I want the test to compare? I know how to test equality of two double values to certain accuracy, but is there anyway that this can be achieved when comparing two ArrayList of doubles?