You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2011/01/22 02:44:58 UTC

svn commit: r1062089 - /commons/proper/math/trunk/src/test/java/org/apache/commons/math/util/FastMathTest.java

Author: sebb
Date: Sat Jan 22 01:44:57 2011
New Revision: 1062089

URL: http://svn.apache.org/viewvc?rev=1062089&view=rev
Log:
MATH-494 Allow for sufficiently close numbers but still detect +/- 0 difference

Modified:
    commons/proper/math/trunk/src/test/java/org/apache/commons/math/util/FastMathTest.java

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/util/FastMathTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/util/FastMathTest.java?rev=1062089&r1=1062088&r2=1062089&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/util/FastMathTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/util/FastMathTest.java Sat Jan 22 01:44:57 2011
@@ -987,6 +987,19 @@ public class FastMathTest {
     
     private static void check(Method mathMethod, Object[] params, Object expected, Object actual, int[] entries){
         if (!expected.equals(actual)){
+            if (expected instanceof Double) {
+                double exp = (Double) expected;
+                // Need to discount 0 otherwise +0.0 == -0.0
+                if (exp != 0 && MathUtils.equals(exp, (Double) actual, 1)) {
+                    return;
+                }
+            } else {
+                float exp = (Float) expected;
+                // Need to discount 0 otherwise +0.0 == -0.0
+                if (exp != 0 && MathUtils.equals(exp, ((Float) actual), 1)) {
+                    return;
+                }
+            }
             StringBuilder sb = new StringBuilder();
             sb.append(mathMethod.getName());
             sb.append("(");