aboutsummaryrefslogtreecommitdiff
path: root/tests/fst_pre_init_tests.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/fst_pre_init_tests.c')
-rw-r--r--tests/fst_pre_init_tests.c89
1 files changed, 0 insertions, 89 deletions
diff --git a/tests/fst_pre_init_tests.c b/tests/fst_pre_init_tests.c
deleted file mode 100644
index 6b7a440..0000000
--- a/tests/fst_pre_init_tests.c
+++ /dev/null
@@ -1,89 +0,0 @@
1#include "fst_test_util.h"
2
3static bool cube_to_fst_to_cube_testcase(Cube *c, Alg *a);
4static bool fst_is_consistent_testcase(Cube *c, Alg *a);
5
6static bool fst_is_consistent_test();
7static bool cube_to_fst_to_cube_test();
8
9static Tester test[] = {
10 fst_is_consistent_test,
11 cube_to_fst_to_cube_test,
12 NULL
13};
14
15static char *name[] = {
16 "Consistency of FST (converted from cube)",
17 "Cube to FST to cube",
18};
19
20static bool
21fst_is_consistent_testcase(Cube *c, Alg *a)
22{
23 FstCube fst_uf, fst_fr, fst_rd;
24 Cube c_fr, c_rd;
25 bool consistent_fr, consistent_rd;
26
27 copy_cube(c, &c_fr);
28 apply_trans(fr, &c_fr);
29
30 copy_cube(c, &c_rd);
31 apply_trans(rd, &c_rd);
32
33 fst_uf = cube_to_fst(c);
34 fst_fr = cube_to_fst(&c_fr);
35 fst_rd = cube_to_fst(&c_rd);
36
37 consistent_fr = fst_uf.fr_eofb == fst_fr.uf_eofb &&
38 fst_uf.fr_eposepe == fst_fr.uf_eposepe &&
39 fst_uf.fr_coud == fst_fr.uf_coud;
40
41 consistent_rd = fst_uf.rd_eofb == fst_rd.uf_eofb &&
42 fst_uf.rd_eposepe == fst_rd.uf_eposepe &&
43 fst_uf.rd_coud == fst_rd.uf_coud;
44
45 return consistent_fr && consistent_rd;
46}
47
48static bool
49cube_to_fst_to_cube_testcase(Cube *c, Alg *a)
50{
51 Cube d;
52 FstCube fst;
53
54 fst = cube_to_fst(c);
55 fst_to_cube(fst, &d);
56
57 return equal_and_log(c, &d);;
58}
59
60static bool
61cube_to_fst_to_cube_test()
62{
63 return try_all_str(
64 cube_to_fst_to_cube_testcase, "Cube to FST to cube failed");
65}
66
67static bool
68fst_is_consistent_test()
69{
70 return try_all_str(
71 fst_is_consistent_testcase, "FST from cube not consistent");
72}
73
74void fst_pre_init_testall() {
75 int i;
76
77 init_env();
78 init_trans();
79
80 for (i = 0; test[i] != NULL; i++) {
81 printf("Test: %s\n", name[i]);
82 if (!test[i]()) {
83 printf("Failed!\n");
84 exit(1);
85 }
86 printf("Passed.\n\n");
87 }
88 printf("All FST pre-init tests passed.\n\n");
89}

Generated with cgit - Back to sebastiano.tronto.net