Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why does junit4 not have Assert.assertArrayEquals() for double[]s?

There appear to be Assert.assertArrayEquals() methods in Junit4 for all primitives other than double, e.g.

Assert.assertArrayEquals(int[] expected, int[] actual)

and

Assert.assertArrayEquals(char[] expected, char[] actual)

but not

Assert.assertArrayEquals(double[] expected, double[] actual, double eps)

or

Assert.assertArrayEquals(double[] expected, double[] actual, double[] eps)

(the latter to account for variable ranges of doubles). Is there a fundamental reason why I should not write such a function?

like image 944
peter.murray.rust Avatar asked Oct 19 '09 22:10

peter.murray.rust


People also ask

How do you use assertArrayEquals in JUnit?

JUnit 5 TutorialThe assertArrayEquals() method asserts that two object arrays are equal. If they are not, an AssertionError is thrown. If expected and actual are null, they are considered equal. Let's first create Book, BookService classes, and then we will write JUnit test cases to use the assertArrayEquals() method.

What is the purpose of assert array equals?

assertArrayEquals. Asserts that two object arrays are equal. If they are not, an AssertionError is thrown with the given message. If expecteds and actuals are null , they are considered equal.


1 Answers

The method seem to have been added in JUnit 4.6, but is for some reason missing in 4.5 and previous versions. I wouldn't expect any problems upgrading to a newer JUnit version.

like image 180
jarnbjo Avatar answered Nov 15 '22 12:11

jarnbjo