comparison data/model/test/Compares.h @ 1086:9f4505ac9072

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