Issue
How do I assert that two arrays of double
s contain the same elements. There are methods to assert that arrays of integers and other primitive types contain the same elements but not for double
s.
Solution
If you are not using a version of JUnit that supports double array comparison then the simplest solution would be to use Arrays.equals
:
assertTrue(Arrays.equals(array1, array2));
However this won't cope with rounding errors in the way the Junit double asserts do.
Answered By - sprinter
Answer Checked By - Pedro (JavaFixing Volunteer)