Author: sebb
Date: Sat Jan 22 01:43:22 2011
New Revision: 1062088
URL: http://svn.apache.org/viewvc?rev=1062088&view=rev
Log:
MATH-494 Allow for sufficiently close numbers but still detect +/- 0 difference
Modified:
commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/util/FastMathTest.java
Modified:
commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/util/FastMathTest.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/util/FastMathTest.java?rev=1062088&r1=1062087&r2=1062088&view=diff
==============================================================================
---
commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/util/FastMathTest.java
(original)
+++
commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/util/FastMathTest.java
Sat Jan 22 01:43:22 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("(");