summaryrefslogtreecommitdiff
path: root/qadevOOo
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2015-11-04 21:42:51 +0100
committerStephan Bergmann <sbergman@redhat.com>2015-11-04 21:42:51 +0100
commit177183f692f42f6a0cf5ee66f1b7e1c31a616140 (patch)
treea53ffc782063b39e5f4d6c77944c70a172fb228f /qadevOOo
parent5a29db7a9945c4cd095799451a6c563d5aeeed57 (diff)
Proper fix for coverity#1326893
FindBugs' FE.FE_FLOATING_POINT_EQUALITY is about double value inaccuracies, not about NaN or negative zero (which is the topic of java.lang.Double.equals vs. ==). Reuse existing qa.TestCaseOldAPI.approxEqual method, moved to util.utils. Change-Id: I65f7bb1faf921e1c4035bb96aeff1eaf2cfb3153
Diffstat (limited to 'qadevOOo')
-rw-r--r--qadevOOo/runner/util/utils.java10
-rw-r--r--qadevOOo/tests/java/ifc/table/_XCell.java3
2 files changed, 12 insertions, 1 deletions
diff --git a/qadevOOo/runner/util/utils.java b/qadevOOo/runner/util/utils.java
index dc1b63c9c9bf..dc019a4fcbfb 100644
--- a/qadevOOo/runner/util/utils.java
+++ b/qadevOOo/runner/util/utils.java
@@ -874,4 +874,14 @@ public class utils {
* Default short wait time for the Office
*/
public static final int DEFAULT_SHORT_WAIT_MS = 500;
+
+ /// see rtl/math.hxx
+ public static boolean approxEqual( double a, double b )
+ {
+ if( a == b )
+ return true;
+ double x = a - b;
+ return (x < 0.0 ? -x : x)
+ < ((a < 0.0 ? -a : a) * (1.0 / (16777216.0 * 16777216.0)));
+ }
}
diff --git a/qadevOOo/tests/java/ifc/table/_XCell.java b/qadevOOo/tests/java/ifc/table/_XCell.java
index 353e8d6b3dca..e81776c974db 100644
--- a/qadevOOo/tests/java/ifc/table/_XCell.java
+++ b/qadevOOo/tests/java/ifc/table/_XCell.java
@@ -19,6 +19,7 @@
package ifc.table;
import lib.MultiMethodTest;
+import util.utils;
import com.sun.star.table.CellContentType;
import com.sun.star.table.XCell;
@@ -149,7 +150,7 @@ public class _XCell extends MultiMethodTest {
oObj.setValue(inValue) ;
double cellValue = oObj.getValue() ;
- boolean result = Double.valueOf(cellValue).equals(inValue);
+ boolean result = utils.approxEqual(cellValue, inValue);
tRes.tested("setValue()", result);
} // end setValue()
}