commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From celes...@apache.org
Subject svn commit: r1347393 - /commons/proper/math/trunk/src/test/java/org/apache/commons/math3/TestUtils.java
Date Thu, 07 Jun 2012 05:12:46 GMT
Author: celestin
Date: Thu Jun  7 05:12:46 2012
New Revision: 1347393

URL: http://svn.apache.org/viewvc?rev=1347393&view=rev
Log:
In TestUtils, improved handling of error messages for
  - assertEquals(String, double[], RealVector, double),
  - assertEquals(String, RealVector, RealVector, double).

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=1347393&r1=1347392&r2=1347393&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:12:46 2012
@@ -253,10 +253,11 @@ public class TestUtils {
      */
     public static void assertEquals(final String message,
         final double[] expected, final RealVector actual, final double delta) {
-        Assert.assertEquals(message + ", dimension", expected.length,
+        final String msgAndSep = message.equals("") ? "" : message + ", ";
+        Assert.assertEquals(msgAndSep + "dimension", expected.length,
             actual.getDimension());
         for (int i = 0; i < expected.length; i++) {
-            Assert.assertEquals(message + ", entry #" + i, expected[i],
+            Assert.assertEquals(msgAndSep + "entry #" + i, expected[i],
                 actual.getEntry(i), delta);
         }
     }
@@ -274,11 +275,12 @@ public class TestUtils {
      */
     public static void assertEquals(final String message,
         final RealVector expected, final RealVector actual, final double delta) {
-        Assert.assertEquals(message + ", dimension", expected.getDimension(),
+        final String msgAndSep = message.equals("") ? "" : message + ", ";
+        Assert.assertEquals(msgAndSep + "dimension", expected.getDimension(),
             actual.getDimension());
         final int dim = expected.getDimension();
         for (int i = 0; i < dim; i++) {
-            Assert.assertEquals(message + ", entry #" + i,
+            Assert.assertEquals(msgAndSep + "entry #" + i,
                 expected.getEntry(i), actual.getEntry(i), delta);
         }
     }



Mime
View raw message