comparison 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
comparison
equal deleted inserted replaced
1365:3382d914e110 1366:bbc4e4ee15d5
84 84
85 void pitchForFrequency() 85 void pitchForFrequency()
86 { 86 {
87 double centsOffset = 0.0; 87 double centsOffset = 0.0;
88 QCOMPARE(Pitch::getPitchForFrequency(MIDDLE_C, &centsOffset), 60); 88 QCOMPARE(Pitch::getPitchForFrequency(MIDDLE_C, &centsOffset), 60);
89 QCOMPARE(centsOffset, 0.0); 89 QCOMPARE(centsOffset + 1.0, 1.0); // avoid ineffective fuzzy-compare to 0
90 QCOMPARE(Pitch::getPitchForFrequency(261.0, &centsOffset), 60); 90 QCOMPARE(Pitch::getPitchForFrequency(261.0, &centsOffset), 60);
91 QCOMPARE(int(centsOffset), -4); 91 QCOMPARE(int(centsOffset), -4);
92 QCOMPARE(Pitch::getPitchForFrequency(440.0, &centsOffset), 69); 92 QCOMPARE(Pitch::getPitchForFrequency(440.0, &centsOffset), 69);
93 QCOMPARE(centsOffset, 0.0); 93 QCOMPARE(centsOffset + 1.0, 1.0);
94 } 94 }
95 95
96 void pitchForFrequencyF() 96 void pitchForFrequencyF()
97 { 97 {
98 float centsOffset = 0.f; 98 float centsOffset = 0.f;
99 QCOMPARE(Pitch::getPitchForFrequency(MIDDLE_C, &centsOffset), 60); 99 QCOMPARE(Pitch::getPitchForFrequency(MIDDLE_C, &centsOffset), 60);
100 QCOMPARE(centsOffset, 0.f); 100 QCOMPARE(centsOffset + 1.f, 1.f); // avoid ineffective fuzzy-compare to 0
101 QCOMPARE(Pitch::getPitchForFrequency(261.0, &centsOffset), 60); 101 QCOMPARE(Pitch::getPitchForFrequency(261.0, &centsOffset), 60);
102 QCOMPARE(int(centsOffset), -4); 102 QCOMPARE(int(centsOffset), -4);
103 QCOMPARE(Pitch::getPitchForFrequency(440.0, &centsOffset), 69); 103 QCOMPARE(Pitch::getPitchForFrequency(440.0, &centsOffset), 69);
104 QCOMPARE(centsOffset, 0.f); 104 QCOMPARE(centsOffset + 1.f, 1.f);
105 } 105 }
106 }; 106 };
107 107
108 #endif 108 #endif