summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes 'josch' Schauer <josch@debian.org>2019-02-03 10:33:22 +0100
committerJohannes Schauer Marin Rodrigues <josch@debian.org>2022-09-12 10:23:13 +0200
commit3469db81f07262d2d78bbbc28ea57f80eadb329d (patch)
tree8874b8ce53261288270b2467ef90dbda982b2962
parent3d89c86891bd8986b09bdc4d2ad8def9bd9801bf (diff)
when testing large float numbers for equality, use a larger epsilon
Gbp-Pq: Name when-testing-large-float-numbers-for-equ.patch
-rw-r--r--fuzzylite/test/BenchmarkTest.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/fuzzylite/test/BenchmarkTest.cpp b/fuzzylite/test/BenchmarkTest.cpp
index 5514398..2652ecf 100644
--- a/fuzzylite/test/BenchmarkTest.cpp
+++ b/fuzzylite/test/BenchmarkTest.cpp
@@ -96,7 +96,17 @@ namespace fl {
CHECK(Op::isEq(1.0, Benchmark::convert(1000.0, Benchmark::MilliSeconds, Benchmark::Seconds)));
FL_LOG(Benchmark::convert(1000.0, Benchmark::MilliSeconds, Benchmark::Seconds));
- CHECK(Op::isEq(35e9, Benchmark::convert(35, Benchmark::Seconds, Benchmark::NanoSeconds)));
+ scalar eps =
+#ifndef __i386__
+ fuzzylite::macheps();
+#else
+ // on i386, due to the 80bit x87 register, double floating point
+ // numbers are handled differently and thus the difference between
+ // 35e9 and the result of Benchmark::convert() will be 2.179e-6,
+ // which is greater than the default epsilon of 1e-6.
+ 1e-5;
+#endif
+ CHECK(Op::isEq(35e9, Benchmark::convert(35, Benchmark::Seconds, Benchmark::NanoSeconds), eps));
CHECK(Op::isEq(35, Benchmark::convert(35e9, Benchmark::NanoSeconds, Benchmark::Seconds)));
}