nissy

Where is nissy?
git clone https://git.tronto.net/nissy
Download | Log | Files | Refs | README

commit 76e04a75b16a452c5021d6d1e499a15b44fc586d
parent aaeb153ce869567f4f88f083dba28445216714f6
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date:   Sun, 22 Jan 2023 00:25:47 +0100

Removed old test files

Diffstat:
Dtests/fst_post_init_tests.c | 81-------------------------------------------------------------------------------
Dtests/fst_pre_init_tests.c | 89-------------------------------------------------------------------------------
Dtests/fst_test_util.c | 64----------------------------------------------------------------
Dtests/fst_test_util.h | 7-------
Dtests/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 @@ -1,81 +0,0 @@ -#include "fst_test_util.h" - -static bool fst_move_testcase(Cube *c, Alg *a); -static bool fst_inverse_testcase(Cube *c, Alg *a); - -static bool fst_move_test(); -static bool fst_inverse_test(); - -static Tester test[] = { - fst_move_test, - fst_inverse_test, - NULL -}; - -static char *name[] = { - "FST move", - "FST inverse", -}; - -static bool -fst_move_testcase(Cube *c, Alg *a) -{ - int i; - Cube d; - FstCube fst; - - make_solved(&d); - fst = cube_to_fst(&d); - - for (i = 0; i < a->len; i++) { - if (a->inv[i] || a->move[i] > B3) { - printf("Cannot apply the following alg to FST: "); - print_alg(a, false); - return false; - } - fst = fst_move(a->move[i], fst); - } - - fst_to_cube(fst, &d); - - return equal_and_log(c, &d); -} - -static bool -fst_inverse_testcase(Cube *c, Alg *a) -{ - Cube d; - - fst_to_cube(fst_inverse(cube_to_fst(c)), &d); - invert_cube(c); - - return equal_and_log(c, &d); -} - -static bool -fst_move_test() -{ - return try_all_str(fst_move_testcase, "FST move incorrect"); -} - -static bool -fst_inverse_test() -{ - return try_all_str(fst_inverse_testcase, "FST test incorrect"); -} - -void fst_post_init_testall() { - int i; - - init_fst(); - - for (i = 0; test[i] != NULL; i++) { - printf("Test: %s\n", name[i]); - if (!test[i]()) { - printf("Failed!\n"); - exit(1); - } - printf("Passed.\n\n"); - } - printf("All FST post-init tests passed.\n\n"); -} diff --git a/tests/fst_pre_init_tests.c b/tests/fst_pre_init_tests.c @@ -1,89 +0,0 @@ -#include "fst_test_util.h" - -static bool cube_to_fst_to_cube_testcase(Cube *c, Alg *a); -static bool fst_is_consistent_testcase(Cube *c, Alg *a); - -static bool fst_is_consistent_test(); -static bool cube_to_fst_to_cube_test(); - -static Tester test[] = { - fst_is_consistent_test, - cube_to_fst_to_cube_test, - NULL -}; - -static char *name[] = { - "Consistency of FST (converted from cube)", - "Cube to FST to cube", -}; - -static bool -fst_is_consistent_testcase(Cube *c, Alg *a) -{ - FstCube fst_uf, fst_fr, fst_rd; - Cube c_fr, c_rd; - bool consistent_fr, consistent_rd; - - copy_cube(c, &c_fr); - apply_trans(fr, &c_fr); - - copy_cube(c, &c_rd); - apply_trans(rd, &c_rd); - - fst_uf = cube_to_fst(c); - fst_fr = cube_to_fst(&c_fr); - fst_rd = cube_to_fst(&c_rd); - - consistent_fr = fst_uf.fr_eofb == fst_fr.uf_eofb && - fst_uf.fr_eposepe == fst_fr.uf_eposepe && - fst_uf.fr_coud == fst_fr.uf_coud; - - consistent_rd = fst_uf.rd_eofb == fst_rd.uf_eofb && - fst_uf.rd_eposepe == fst_rd.uf_eposepe && - fst_uf.rd_coud == fst_rd.uf_coud; - - return consistent_fr && consistent_rd; -} - -static bool -cube_to_fst_to_cube_testcase(Cube *c, Alg *a) -{ - Cube d; - FstCube fst; - - fst = cube_to_fst(c); - fst_to_cube(fst, &d); - - return equal_and_log(c, &d);; -} - -static bool -cube_to_fst_to_cube_test() -{ - return try_all_str( - cube_to_fst_to_cube_testcase, "Cube to FST to cube failed"); -} - -static bool -fst_is_consistent_test() -{ - return try_all_str( - fst_is_consistent_testcase, "FST from cube not consistent"); -} - -void fst_pre_init_testall() { - int i; - - init_env(); - init_trans(); - - for (i = 0; test[i] != NULL; i++) { - printf("Test: %s\n", name[i]); - if (!test[i]()) { - printf("Failed!\n"); - exit(1); - } - printf("Passed.\n\n"); - } - printf("All FST pre-init tests passed.\n\n"); -} diff --git a/tests/fst_test_util.c b/tests/fst_test_util.c @@ -1,64 +0,0 @@ -#include "fst_test_util.h" - -char *algs[] = { - "", - "U", "U2", "U'", "D", "D2", "D'", "R", "R2", "R'", - "L", "L2", "L'", "F", "F2", "F'", "B", "B2", "B'", - "U2 R2 U2 R2 U2", - "U2 F2 R2 B2 U2 D2 F2 L2 B2", - "RUR'URU2R'", - "L2 D R U2 B2 L", - "R'U'F", - "F2 U' R2 D' B2 D2 R2 D2 R2 U' F L' U' R B F2 R B' D2", - "D L2 F2 R2 D R2 U L2 U' B2 D L' F2 U2 B' L D' U' R' B2 F2", - "F' L2 F' D' R F2 L U L' D2 R2 F2 D2 R2 B' L2 B2 U2 F D2 B", - NULL, -}; - -bool -equal_and_log(Cube *c, Cube *d) -{ - bool ret = equal(c, d); - - if (!ret) { - printf("These cubes should be equal, but are not:\n\n"); - print_cube(c); - printf("\n"); - print_cube(d); - printf("\n"); - } - - return ret; -} - -bool -try_str(CubeTester f, char *algstr, char *msg) -{ - bool b; - Alg *a; - Cube c; - - a = new_alg(algstr); - make_solved(&c); - apply_alg(a, &c); - - if (!(b = f(&c, a))) - printf("%s with alg %s\n", msg, algstr); - - free_alg(a); - - return b; -} - -bool -try_all_str(CubeTester f, char *msg) -{ - bool b; - int i; - - b = true; - for (i = 0; algs[i] != NULL; i++) - b = b && try_str(f, algs[i], msg); - - return b; -} diff --git a/tests/fst_test_util.h b/tests/fst_test_util.h @@ -1,7 +0,0 @@ -#include "../src/fst.h" - -extern char *algs[]; - -bool equal_and_log(Cube *c, Cube *d); -bool try_str(CubeTester f, char *algstr, char *msg); -bool try_all_str(CubeTester f, char *msg); diff --git a/tests/nissy_tests.c b/tests/nissy_tests.c @@ -1,12 +0,0 @@ -#include <stdio.h> - -void fst_pre_init_testall(); -void fst_post_init_testall(); - -int main() { - fst_pre_init_testall(); - fst_post_init_testall(); - - printf("All tests passed.\n"); - return 0; -}