summaryrefslogtreecommitdiff
path: root/libs/evoral
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2015-09-13 20:23:12 +0200
committerRobin Gareus <robin@gareus.org>2015-09-13 20:23:12 +0200
commitd83889079bc5ad1c5c42a0b7284d6e8ef0dd141e (patch)
tree7ce2fda5cab1c8987133e2a5f508fdfa6f446846 /libs/evoral
parente45db26d9792f499bb5649a3d7afa8a360b59cdf (diff)
hack around a bug in cppunit/mingw/windows.
Diffstat (limited to 'libs/evoral')
-rw-r--r--libs/evoral/test/CurveTest.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/libs/evoral/test/CurveTest.cpp b/libs/evoral/test/CurveTest.cpp
index 3f30062941..0cf51ec8ff 100644
--- a/libs/evoral/test/CurveTest.cpp
+++ b/libs/evoral/test/CurveTest.cpp
@@ -5,6 +5,23 @@
CPPUNIT_TEST_SUITE_REGISTRATION (CurveTest);
+#if defined(PLATFORM_WINDOWS) && defined(COMPILER_MINGW)
+/* cppunit-1.13.2 uses assertion_traits<double>
+ * sprintf( , "%.*g", precision, x)
+ * to format a double. The actual comparison is performed on a string.
+ * This is problematic with mingw/windows|wine, "%.*g" formatting fails.
+ *
+ * This quick hack compares float, however float compatisons are at most Y.MMMM+eXX,
+ * the max precision needs to be limited. to the last mantissa digit.
+ *
+ * Anyway, actual maths is verified with Linux and OSX unit-tests,
+ * and this needs to go to https://sourceforge.net/p/cppunit/bugs/
+ */
+#define MAXPREC(P) ((P) < .0005 ? .0005 : (P))
+#define CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE(M,A,B,P) CPPUNIT_ASSERT_EQUAL_MESSAGE(M, (float)rint ((A) / MAXPREC(P)),(float)rint ((B) / MAXPREC(P)))
+#define CPPUNIT_ASSERT_DOUBLES_EQUAL(A,B,P) CPPUNIT_ASSERT_EQUAL((float)rint ((A) / MAXPREC(P)),(float)rint ((B) / MAXPREC(P)))
+#endif
+
using namespace Evoral;
// linear y = Y0 + YS * x ; with x = i * (X1 - X0) + X0; and i = [0..1023]