annotate data/model/test/Compares.h @ 1189:63b73a21bccd spectrogram-minor-refactor

Small fix to compiler warning
author Chris Cannam
date Thu, 23 Jun 2016 08:45:52 +0100
parents 9f4505ac9072
children 48e9f538e6e9
rev   line source
Chris@1086 1
Chris@1086 2 #ifndef TEST_COMPARES_H
Chris@1086 3 #define TEST_COMPARES_H
Chris@1086 4
Chris@1086 5 // These macros are used for comparing generated results, and they
Chris@1086 6 // aren't always going to be exact. Adding 0.1 to each value gives
Chris@1086 7 // us a little more fuzz in qFuzzyCompare (which ultimately does
Chris@1086 8 // the comparison).
Chris@1086 9
Chris@1086 10 #define COMPARE_ZERO(a) \
Chris@1086 11 QCOMPARE(a + 0.1, 0.1)
Chris@1086 12
Chris@1086 13 #define COMPARE_ZERO_F(a) \
Chris@1086 14 QCOMPARE(a + 0.1f, 0.1f)
Chris@1086 15
Chris@1086 16 #define COMPARE_FUZZIER(a, b) \
Chris@1086 17 QCOMPARE(a + 0.1, b + 0.1)
Chris@1086 18
Chris@1086 19 #define COMPARE_FUZZIER_F(a, b) \
Chris@1086 20 QCOMPARE(a + 0.1f, b + 0.1f)
Chris@1086 21
Chris@1086 22 #define COMPARE_ALL_TO(a, n) \
Chris@1086 23 for (int cmp_i = 0; cmp_i < (int)(sizeof(a)/sizeof(a[0])); ++cmp_i) { \
Chris@1086 24 COMPARE_FUZZIER(a[cmp_i], n); \
Chris@1086 25 }
Chris@1086 26
Chris@1086 27 #define COMPARE_ALL(a, b) \
Chris@1086 28 for (int cmp_i = 0; cmp_i < (int)(sizeof(a)/sizeof(a[0])); ++cmp_i) { \
Chris@1086 29 COMPARE_FUZZIER(a[cmp_i], b[cmp_i]); \
Chris@1086 30 }
Chris@1086 31
Chris@1086 32 #define COMPARE_SCALED(a, b, s) \
Chris@1086 33 for (int cmp_i = 0; cmp_i < (int)(sizeof(a)/sizeof(a[0])); ++cmp_i) { \
Chris@1086 34 COMPARE_FUZZIER(a[cmp_i] / s, b[cmp_i]); \
Chris@1086 35 }
Chris@1086 36
Chris@1086 37 #define COMPARE_ALL_TO_F(a, n) \
Chris@1086 38 for (int cmp_i = 0; cmp_i < (int)(sizeof(a)/sizeof(a[0])); ++cmp_i) { \
Chris@1086 39 COMPARE_FUZZIER_F(a[cmp_i], n); \
Chris@1086 40 }
Chris@1086 41
Chris@1086 42 #define COMPARE_ALL_F(a, b) \
Chris@1086 43 for (int cmp_i = 0; cmp_i < (int)(sizeof(a)/sizeof(a[0])); ++cmp_i) { \
Chris@1086 44 COMPARE_FUZZIER_F(a[cmp_i], b[cmp_i]); \
Chris@1086 45 }
Chris@1086 46
Chris@1086 47 #define COMPARE_SCALED_F(a, b, s) \
Chris@1086 48 for (int cmp_i = 0; cmp_i < (int)(sizeof(a)/sizeof(a[0])); ++cmp_i) { \
Chris@1086 49 COMPARE_FUZZIER_F(a[cmp_i] / s, b[cmp_i]); \
Chris@1086 50 }
Chris@1086 51
Chris@1086 52 #endif