1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
#include "coord_tests.h"
bool testmethod_indexes_consistent(void *);
Test test_indexes_consistent = {
.name = "Consitency of index and anti-index",
.t = testmethod_indexes_consistent,
.cases = (void **)all_coordinates,
};
Test *coord_pre_init[] = {
&test_indexes_consistent,
NULL
};
TestSuite coord_pre_init_suite = {
.setup = NULL,
.tests = coord_pre_init,
.teardown = NULL,
};
TestSuite *coord_suites[] = {
&coord_pre_init_suite,
NULL
};
bool
testmethod_indexes_consistent(void *a)
{
uint64_t ui, uj;
Cube c;
Coordinate *coord;
coord = (Coordinate *)a;
if (coord->type != COMP_COORD)
return true; /* Not applicable */
gen_coord(coord);
for (ui = 0; ui < coord->max; ui++) {
indexers_makecube(coord->i, ui, &c);
uj = indexers_getind(coord->i, &c);
if (ui != uj) {
fprintf(stderr, "Error with coordinate %s: "
"%" PRIu64 " != %" PRIu64 "\n",
coord->name, uj, ui);
return false;
}
}
return true;
}
|