diff base/test/TestPitch.h @ 1366:bbc4e4ee15d5

Fix spurious test failure in 32-bit build
author Chris Cannam
date Fri, 13 Jan 2017 13:12:37 +0000
parents 88b54a185a0a
children 48e9f538e6e9
line wrap: on
line diff
--- a/base/test/TestPitch.h	Fri Jan 13 10:29:44 2017 +0000
+++ b/base/test/TestPitch.h	Fri Jan 13 13:12:37 2017 +0000
@@ -86,22 +86,22 @@
     {
 	double centsOffset = 0.0;
 	QCOMPARE(Pitch::getPitchForFrequency(MIDDLE_C, &centsOffset), 60);
-	QCOMPARE(centsOffset, 0.0);
+	QCOMPARE(centsOffset + 1.0, 1.0); // avoid ineffective fuzzy-compare to 0
 	QCOMPARE(Pitch::getPitchForFrequency(261.0, &centsOffset), 60);
 	QCOMPARE(int(centsOffset), -4);
 	QCOMPARE(Pitch::getPitchForFrequency(440.0, &centsOffset), 69);
-	QCOMPARE(centsOffset, 0.0);
+	QCOMPARE(centsOffset + 1.0, 1.0);
     }
 
     void pitchForFrequencyF()
     {
 	float centsOffset = 0.f;
 	QCOMPARE(Pitch::getPitchForFrequency(MIDDLE_C, &centsOffset), 60);
-	QCOMPARE(centsOffset, 0.f);
+	QCOMPARE(centsOffset + 1.f, 1.f); // avoid ineffective fuzzy-compare to 0
 	QCOMPARE(Pitch::getPitchForFrequency(261.0, &centsOffset), 60);
 	QCOMPARE(int(centsOffset), -4);
 	QCOMPARE(Pitch::getPitchForFrequency(440.0, &centsOffset), 69);
-	QCOMPARE(centsOffset, 0.f);
+	QCOMPARE(centsOffset + 1.f, 1.f);
     }
 };