Java – JUnit asserts double arrays
•
Java
How do I assert that two double arrays contain the same elements There are some ways to assert that integer arrays and other basic types contain the same elements, but do not contain doubles
Solution
If you are not using a version of JUnit that supports double array comparison, the simplest solution is to use arrays equals:
assertTrue(Arrays.equals(array1,array2));
However, this cannot deal with the rounding error made by JUnit's double assertion
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码