diff options
| -rw-r--r-- | tests/fst_post_init_tests.c | 81 | ||||
| -rw-r--r-- | tests/fst_pre_init_tests.c | 89 | ||||
| -rw-r--r-- | tests/fst_test_util.c | 64 | ||||
| -rw-r--r-- | tests/fst_test_util.h | 7 | ||||
| -rw-r--r-- | tests/nissy_tests.c | 12 |
5 files changed, 0 insertions, 253 deletions
diff --git a/tests/fst_post_init_tests.c b/tests/fst_post_init_tests.c deleted file mode 100644 index 9d8d554..0000000 --- a/tests/fst_post_init_tests.c +++ /dev/null | |||
| @@ -1,81 +0,0 @@ | |||
| 1 | #include "fst_test_util.h" | ||
| 2 | |||
| 3 | static bool fst_move_testcase(Cube *c, Alg *a); | ||
| 4 | static bool fst_inverse_testcase(Cube *c, Alg *a); | ||
| 5 | |||
| 6 | static bool fst_move_test(); | ||
| 7 | static bool fst_inverse_test(); | ||
| 8 | |||
| 9 | static Tester test[] = { | ||
| 10 | fst_move_test, | ||
| 11 | fst_inverse_test, | ||
| 12 | NULL | ||
| 13 | }; | ||
| 14 | |||
| 15 | static char *name[] = { | ||
| 16 | "FST move", | ||
| 17 | "FST inverse", | ||
| 18 | }; | ||
| 19 | |||
| 20 | static bool | ||
| 21 | fst_move_testcase(Cube *c, Alg *a) | ||
| 22 | { | ||
| 23 | int i; | ||
| 24 | Cube d; | ||
| 25 | FstCube fst; | ||
| 26 | |||
| 27 | make_solved(&d); | ||
| 28 | fst = cube_to_fst(&d); | ||
| 29 | |||
| 30 | for (i = 0; i < a->len; i++) { | ||
| 31 | if (a->inv[i] || a->move[i] > B3) { | ||
| 32 | printf("Cannot apply the following alg to FST: "); | ||
| 33 | print_alg(a, false); | ||
| 34 | return false; | ||
| 35 | } | ||
| 36 | fst = fst_move(a->move[i], fst); | ||
| 37 | } | ||
| 38 | |||
| 39 | fst_to_cube(fst, &d); | ||
| 40 | |||
| 41 | return equal_and_log(c, &d); | ||
| 42 | } | ||
| 43 | |||
| 44 | static bool | ||
| 45 | fst_inverse_testcase(Cube *c, Alg *a) | ||
| 46 | { | ||
| 47 | Cube d; | ||
| 48 | |||
| 49 | fst_to_cube(fst_inverse(cube_to_fst(c)), &d); | ||
| 50 | invert_cube(c); | ||
| 51 | |||
| 52 | return equal_and_log(c, &d); | ||
| 53 | } | ||
| 54 | |||
| 55 | static bool | ||
| 56 | fst_move_test() | ||
| 57 | { | ||
| 58 | return try_all_str(fst_move_testcase, "FST move incorrect"); | ||
| 59 | } | ||
| 60 | |||
| 61 | static bool | ||
| 62 | fst_inverse_test() | ||
| 63 | { | ||
| 64 | return try_all_str(fst_inverse_testcase, "FST test incorrect"); | ||
| 65 | } | ||
| 66 | |||
| 67 | void fst_post_init_testall() { | ||
| 68 | int i; | ||
| 69 | |||
| 70 | init_fst(); | ||
| 71 | |||
| 72 | for (i = 0; test[i] != NULL; i++) { | ||
| 73 | printf("Test: %s\n", name[i]); | ||
| 74 | if (!test[i]()) { | ||
| 75 | printf("Failed!\n"); | ||
| 76 | exit(1); | ||
| 77 | } | ||
| 78 | printf("Passed.\n\n"); | ||
| 79 | } | ||
| 80 | printf("All FST post-init tests passed.\n\n"); | ||
| 81 | } | ||
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 | |||
| 3 | static bool cube_to_fst_to_cube_testcase(Cube *c, Alg *a); | ||
| 4 | static bool fst_is_consistent_testcase(Cube *c, Alg *a); | ||
| 5 | |||
| 6 | static bool fst_is_consistent_test(); | ||
| 7 | static bool cube_to_fst_to_cube_test(); | ||
| 8 | |||
| 9 | static Tester test[] = { | ||
| 10 | fst_is_consistent_test, | ||
| 11 | cube_to_fst_to_cube_test, | ||
| 12 | NULL | ||
| 13 | }; | ||
| 14 | |||
| 15 | static char *name[] = { | ||
| 16 | "Consistency of FST (converted from cube)", | ||
| 17 | "Cube to FST to cube", | ||
| 18 | }; | ||
| 19 | |||
| 20 | static bool | ||
| 21 | fst_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 | |||
| 48 | static bool | ||
| 49 | cube_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 | |||
| 60 | static bool | ||
| 61 | cube_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 | |||
| 67 | static bool | ||
| 68 | fst_is_consistent_test() | ||
| 69 | { | ||
| 70 | return try_all_str( | ||
| 71 | fst_is_consistent_testcase, "FST from cube not consistent"); | ||
| 72 | } | ||
| 73 | |||
| 74 | void 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 | } | ||
diff --git a/tests/fst_test_util.c b/tests/fst_test_util.c deleted file mode 100644 index 35c1e9f..0000000 --- a/tests/fst_test_util.c +++ /dev/null | |||
| @@ -1,64 +0,0 @@ | |||
| 1 | #include "fst_test_util.h" | ||
| 2 | |||
| 3 | char *algs[] = { | ||
| 4 | "", | ||
| 5 | "U", "U2", "U'", "D", "D2", "D'", "R", "R2", "R'", | ||
| 6 | "L", "L2", "L'", "F", "F2", "F'", "B", "B2", "B'", | ||
| 7 | "U2 R2 U2 R2 U2", | ||
| 8 | "U2 F2 R2 B2 U2 D2 F2 L2 B2", | ||
| 9 | "RUR'URU2R'", | ||
| 10 | "L2 D R U2 B2 L", | ||
| 11 | "R'U'F", | ||
| 12 | "F2 U' R2 D' B2 D2 R2 D2 R2 U' F L' U' R B F2 R B' D2", | ||
| 13 | "D L2 F2 R2 D R2 U L2 U' B2 D L' F2 U2 B' L D' U' R' B2 F2", | ||
| 14 | "F' L2 F' D' R F2 L U L' D2 R2 F2 D2 R2 B' L2 B2 U2 F D2 B", | ||
| 15 | NULL, | ||
| 16 | }; | ||
| 17 | |||
| 18 | bool | ||
| 19 | equal_and_log(Cube *c, Cube *d) | ||
| 20 | { | ||
| 21 | bool ret = equal(c, d); | ||
| 22 | |||
| 23 | if (!ret) { | ||
| 24 | printf("These cubes should be equal, but are not:\n\n"); | ||
| 25 | print_cube(c); | ||
| 26 | printf("\n"); | ||
| 27 | print_cube(d); | ||
| 28 | printf("\n"); | ||
| 29 | } | ||
| 30 | |||
| 31 | return ret; | ||
| 32 | } | ||
| 33 | |||
| 34 | bool | ||
| 35 | try_str(CubeTester f, char *algstr, char *msg) | ||
| 36 | { | ||
| 37 | bool b; | ||
| 38 | Alg *a; | ||
| 39 | Cube c; | ||
| 40 | |||
| 41 | a = new_alg(algstr); | ||
| 42 | make_solved(&c); | ||
| 43 | apply_alg(a, &c); | ||
| 44 | |||
| 45 | if (!(b = f(&c, a))) | ||
| 46 | printf("%s with alg %s\n", msg, algstr); | ||
| 47 | |||
| 48 | free_alg(a); | ||
| 49 | |||
| 50 | return b; | ||
| 51 | } | ||
| 52 | |||
| 53 | bool | ||
| 54 | try_all_str(CubeTester f, char *msg) | ||
| 55 | { | ||
| 56 | bool b; | ||
| 57 | int i; | ||
| 58 | |||
| 59 | b = true; | ||
| 60 | for (i = 0; algs[i] != NULL; i++) | ||
| 61 | b = b && try_str(f, algs[i], msg); | ||
| 62 | |||
| 63 | return b; | ||
| 64 | } | ||
diff --git a/tests/fst_test_util.h b/tests/fst_test_util.h deleted file mode 100644 index b67b945..0000000 --- a/tests/fst_test_util.h +++ /dev/null | |||
| @@ -1,7 +0,0 @@ | |||
| 1 | #include "../src/fst.h" | ||
| 2 | |||
| 3 | extern char *algs[]; | ||
| 4 | |||
| 5 | bool equal_and_log(Cube *c, Cube *d); | ||
| 6 | bool try_str(CubeTester f, char *algstr, char *msg); | ||
| 7 | bool try_all_str(CubeTester f, char *msg); | ||
diff --git a/tests/nissy_tests.c b/tests/nissy_tests.c deleted file mode 100644 index d959423..0000000 --- a/tests/nissy_tests.c +++ /dev/null | |||
| @@ -1,12 +0,0 @@ | |||
| 1 | #include <stdio.h> | ||
| 2 | |||
| 3 | void fst_pre_init_testall(); | ||
| 4 | void fst_post_init_testall(); | ||
| 5 | |||
| 6 | int main() { | ||
| 7 | fst_pre_init_testall(); | ||
| 8 | fst_post_init_testall(); | ||
| 9 | |||
| 10 | printf("All tests passed.\n"); | ||
| 11 | return 0; | ||
| 12 | } | ||
