aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--tests/coord_tests.c50
-rw-r--r--tests/coord_tests.h13
-rw-r--r--tests/fst_tests.c13
-rw-r--r--tests/fst_tests.h2
-rw-r--r--tests/test.c5
5 files changed, 75 insertions, 8 deletions
diff --git a/tests/coord_tests.c b/tests/coord_tests.c
new file mode 100644
index 0000000..8d6b6d3
--- /dev/null
+++ b/tests/coord_tests.c
@@ -0,0 +1,50 @@
1#include "coord_tests.h"
2
3bool testmethod_indexes_consistent(void *);
4
5Test test_indexes_consistent = {
6 .name = "Consitency of index and anti-index",
7 .t = testmethod_indexes_consistent,
8 .cases = (void **)all_coordinates,
9};
10Test *coord_pre_init[] = {
11 &test_indexes_consistent,
12 NULL
13};
14TestSuite coord_pre_init_suite = {
15 .setup = NULL,
16 .tests = coord_pre_init,
17 .teardown = NULL,
18};
19
20TestSuite *coord_suites[] = {
21 &coord_pre_init_suite,
22 NULL
23};
24
25bool
26testmethod_indexes_consistent(void *a)
27{
28 uint64_t ui, uj;
29 Cube c;
30 Coordinate *coord;
31
32 coord = (Coordinate *)a;
33
34 if (coord->type != COMP_COORD)
35 return true; /* Not applicable */
36
37 gen_coord(coord);
38 for (ui = 0; ui < coord->max; ui++) {
39 indexers_makecube(coord->i, ui, &c);
40 uj = indexers_getind(coord->i, &c);
41 if (ui != uj) {
42 fprintf(stderr, "Error with coordinate %s: "
43 "%" PRIu64 " != %" PRIu64 "\n",
44 coord->name, uj, ui);
45 return false;
46 }
47 }
48
49 return true;
50}
diff --git a/tests/coord_tests.h b/tests/coord_tests.h
new file mode 100644
index 0000000..0cfd145
--- /dev/null
+++ b/tests/coord_tests.h
@@ -0,0 +1,13 @@
1#ifndef COORD_TESTS_H
2#define COORD_TESTS_H
3
4#include "../src/coord.h"
5#include "test_common.h"
6
7extern Test test_indexes_consistent;
8
9extern TestSuite coord_pre_init_suite;
10
11extern TestSuite *coord_suites[];
12
13#endif
diff --git a/tests/fst_tests.c b/tests/fst_tests.c
index dfaab39..1a9bedd 100644
--- a/tests/fst_tests.c
+++ b/tests/fst_tests.c
@@ -3,7 +3,8 @@
3static bool testmethod_fst_is_consistent(void *); 3static bool testmethod_fst_is_consistent(void *);
4static bool testmethod_cube_to_fst_to_cube(void *); 4static bool testmethod_cube_to_fst_to_cube(void *);
5static bool testmethod_fst_move(void *); 5static bool testmethod_fst_move(void *);
6static bool testmethod_fst_inverse(void *); static bool check_equal_and_log(Cube *, Cube *); 6static bool testmethod_fst_inverse(void *);
7static bool check_equal_and_log(Cube *, Cube *);
7static void void_to_cube(void *, Cube *); 8static void void_to_cube(void *, Cube *);
8 9
9char *algs[] = { 10char *algs[] = {
@@ -42,29 +43,29 @@ Test test_fst_inverse = {
42 .cases = (void **)algs, 43 .cases = (void **)algs,
43}; 44};
44 45
45Test *pre_init[] = { 46Test *fst_pre_init[] = {
46 &test_fst_is_consistent, 47 &test_fst_is_consistent,
47 &test_cube_to_fst_to_cube, 48 &test_cube_to_fst_to_cube,
48 NULL 49 NULL
49}; 50};
50TestSuite fst_pre_init_suite = { 51TestSuite fst_pre_init_suite = {
51 .setup = NULL, 52 .setup = NULL,
52 .tests = pre_init, 53 .tests = fst_pre_init,
53 .teardown = NULL, 54 .teardown = NULL,
54}; 55};
55 56
56Test *post_init[] = { 57Test *fst_post_init[] = {
57 &test_fst_move, 58 &test_fst_move,
58 &test_fst_inverse, 59 &test_fst_inverse,
59 NULL 60 NULL
60}; 61};
61TestSuite fst_post_init_suite = { 62TestSuite fst_post_init_suite = {
62 .setup = init_fst, 63 .setup = init_fst,
63 .tests = post_init, 64 .tests = fst_post_init,
64 .teardown = NULL, 65 .teardown = NULL,
65}; 66};
66 67
67TestSuite *fst_testsuites[] = { 68TestSuite *fst_suites[] = {
68 &fst_pre_init_suite, 69 &fst_pre_init_suite,
69 &fst_post_init_suite, 70 &fst_post_init_suite,
70 NULL 71 NULL
diff --git a/tests/fst_tests.h b/tests/fst_tests.h
index 324028e..68bbf04 100644
--- a/tests/fst_tests.h
+++ b/tests/fst_tests.h
@@ -14,6 +14,6 @@ extern Test test_fst_inverse;
14extern TestSuite fst_pre_init_suite; 14extern TestSuite fst_pre_init_suite;
15extern TestSuite fst_post_init_suite; 15extern TestSuite fst_post_init_suite;
16 16
17extern TestSuite *fst_testsuites[]; 17extern TestSuite *fst_suites[];
18 18
19#endif 19#endif
diff --git a/tests/test.c b/tests/test.c
index cc14456..a1a382c 100644
--- a/tests/test.c
+++ b/tests/test.c
@@ -1,5 +1,6 @@
1#include <stdio.h> 1#include <stdio.h>
2 2
3#include "coord_tests.h"
3#include "fst_tests.h" 4#include "fst_tests.h"
4 5
5static bool run_test(Test *); 6static bool run_test(Test *);
@@ -53,9 +54,11 @@ int main(int argc, char *argv[]) {
53 init_trans(); 54 init_trans();
54 /**************************************/ 55 /**************************************/
55 56
56 TestModule fst = { .name = "fst", .suites = fst_testsuites }; 57 TestModule fst = { .name = "fst", .suites = fst_suites };
58 TestModule coord = { .name = "coord", .suites = coord_suites };
57 TestModule *modules[999] = { 59 TestModule *modules[999] = {
58 &fst, 60 &fst,
61 &coord,
59 NULL 62 NULL
60 }; 63 };
61 64

Generated with cgit - Back to sebastiano.tronto.net