You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ce...@apache.org on 2012/06/07 07:05:33 UTC
svn commit: r1347392 -
/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/TestUtils.java
Author: celestin
Date: Thu Jun 7 05:05:33 2012
New Revision: 1347392
URL: http://svn.apache.org/viewvc?rev=1347392&view=rev
Log:
Utility method for testing for equality of expected double[] with RealVector.
Modified:
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/TestUtils.java
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math3/TestUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/TestUtils.java?rev=1347392&r1=1347391&r2=1347392&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math3/TestUtils.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math3/TestUtils.java Thu Jun 7 05:05:33 2012
@@ -252,6 +252,27 @@ public class TestUtils {
* and actual vectors for which both entries are still considered equal
*/
public static void assertEquals(final String message,
+ final double[] expected, final RealVector actual, final double delta) {
+ Assert.assertEquals(message + ", dimension", expected.length,
+ actual.getDimension());
+ for (int i = 0; i < expected.length; i++) {
+ Assert.assertEquals(message + ", entry #" + i, expected[i],
+ actual.getEntry(i), delta);
+ }
+ }
+
+ /**
+ * Asserts that all entries of the specified vectors are equal to within a
+ * positive {@code delta}.
+ *
+ * @param message the identifying message for the assertion error (can be
+ * {@code null})
+ * @param expected expected value
+ * @param actual actual value
+ * @param delta the maximum difference between the entries of the expected
+ * and actual vectors for which both entries are still considered equal
+ */
+ public static void assertEquals(final String message,
final RealVector expected, final RealVector actual, final double delta) {
Assert.assertEquals(message + ", dimension", expected.getDimension(),
actual.getDimension());