From f987f5af492f2ac9d5aeebd351bcb49175556af2 Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Mon, 29 May 2023 01:06:09 +0200 Subject: Initial commit --- test/basic/all.in | 0 test/basic/all.out | 4 ++++ test/basic/basic_tests.c | 19 +++++++++++++++ test/io/00_garbage.in | 3 +++ test/io/00_garbage.out | 1 + test/io/01_solved_oneline.in | 1 + test/io/01_solved_oneline.out | 1 + test/io/02_solved_oneline_whitespace.in | 1 + test/io/02_solved_oneline_whitespace.out | 1 + test/io/03_solved_multiline.in | 9 +++++++ test/io/03_solved_multiline.out | 1 + test/io/04_inconsistent_ep.in | 1 + test/io/04_inconsistent_ep.out | 1 + test/io/05_inconsistent_eo.in | 1 + test/io/05_inconsistent_eo.out | 1 + test/io/06_inconsistent_cp.in | 1 + test/io/06_inconsistent_cp.out | 1 + test/io/07_inconsistent_co.in | 1 + test/io/07_inconsistent_co.out | 1 + test/io/08_unsolved.in | 6 +++++ test/io/08_unsolved.out | 1 + test/io/io_tests.c | 28 ++++++++++++++++++++++ test/move/000_nomove_solved.in | 2 ++ test/move/000_nomove_solved.out | 1 + test/move/001_nomove_scrambled.in | 2 ++ test/move/001_nomove_scrambled.out | 1 + test/move/010_U_solved.in | 2 ++ test/move/010_U_solved.out | 1 + test/move/011_U_scrambled.in | 2 ++ test/move/011_U_scrambled.out | 1 + test/move/012_U_inverse.in | 2 ++ test/move/012_U_inverse.out | 1 + test/move/020_U2_solved.in | 2 ++ test/move/020_U2_solved.out | 1 + test/move/021_U2_scrambled.in | 2 ++ test/move/021_U2_scrambled.out | 1 + test/move/022_U2_inverse.in | 2 ++ test/move/022_U2_inverse.out | 1 + test/move/030_U3_solved.in | 2 ++ test/move/030_U3_solved.out | 1 + test/move/031_U3_inverse.in | 2 ++ test/move/031_U3_inverse.out | 1 + test/move/032_U3_scrambled.in | 2 ++ test/move/032_U3_scrambled.out | 1 + test/move/033_U3_with_prime.in | 2 ++ test/move/033_U3_with_prime.out | 1 + test/move/040_D_solved.in | 2 ++ test/move/040_D_solved.out | 1 + test/move/050_D2_solved.in | 2 ++ test/move/050_D2_solved.out | 1 + test/move/060_D3_solved.in | 2 ++ test/move/060_D3_solved.out | 1 + test/move/070_R_solved.in | 2 ++ test/move/070_R_solved.out | 1 + test/move/071_R_scrambled.in | 2 ++ test/move/071_R_scrambled.out | 1 + test/move/080_R2_solved.in | 2 ++ test/move/080_R2_solved.out | 1 + test/move/090_R3_solved.in | 2 ++ test/move/090_R3_solved.out | 1 + test/move/100_L_solved.in | 2 ++ test/move/100_L_solved.out | 1 + test/move/110_L2_solved.in | 2 ++ test/move/110_L2_solved.out | 1 + test/move/120_L3_solved.in | 2 ++ test/move/120_L3_solved.out | 1 + test/move/130_F_solved.in | 2 ++ test/move/130_F_solved.out | 1 + test/move/132_F_scrambled.in | 2 ++ test/move/132_F_scrambled.out | 1 + test/move/133_F_scrambled_2.in | 2 ++ test/move/133_F_scrambled_2.out | 1 + test/move/140_F2_solved.in | 2 ++ test/move/140_F2_solved.out | 1 + test/move/150_F3_solved.in | 2 ++ test/move/150_F3_solved.out | 1 + test/move/160_B_solved.in | 2 ++ test/move/160_B_solved.out | 1 + test/move/170_B2_solved.in | 2 ++ test/move/170_B2_solved.out | 1 + test/move/180_B3_solved.in | 2 ++ test/move/180_B3_solved.out | 1 + test/move/200_scramble_solved.in | 2 ++ test/move/200_scramble_solved.out | 1 + test/move/201_solution_scrambled.in | 2 ++ test/move/201_solution_scrambled.out | 1 + test/move/move_tests.c | 40 ++++++++++++++++++++++++++++++++ test/test.sh | 32 +++++++++++++++++++++++++ 88 files changed, 252 insertions(+) create mode 100644 test/basic/all.in create mode 100644 test/basic/all.out create mode 100644 test/basic/basic_tests.c create mode 100644 test/io/00_garbage.in create mode 100644 test/io/00_garbage.out create mode 100644 test/io/01_solved_oneline.in create mode 100644 test/io/01_solved_oneline.out create mode 100644 test/io/02_solved_oneline_whitespace.in create mode 100644 test/io/02_solved_oneline_whitespace.out create mode 100644 test/io/03_solved_multiline.in create mode 100644 test/io/03_solved_multiline.out create mode 100644 test/io/04_inconsistent_ep.in create mode 100644 test/io/04_inconsistent_ep.out create mode 100644 test/io/05_inconsistent_eo.in create mode 100644 test/io/05_inconsistent_eo.out create mode 100644 test/io/06_inconsistent_cp.in create mode 100644 test/io/06_inconsistent_cp.out create mode 100644 test/io/07_inconsistent_co.in create mode 100644 test/io/07_inconsistent_co.out create mode 100644 test/io/08_unsolved.in create mode 100644 test/io/08_unsolved.out create mode 100644 test/io/io_tests.c create mode 100644 test/move/000_nomove_solved.in create mode 100644 test/move/000_nomove_solved.out create mode 100644 test/move/001_nomove_scrambled.in create mode 100644 test/move/001_nomove_scrambled.out create mode 100644 test/move/010_U_solved.in create mode 100644 test/move/010_U_solved.out create mode 100644 test/move/011_U_scrambled.in create mode 100644 test/move/011_U_scrambled.out create mode 100644 test/move/012_U_inverse.in create mode 100644 test/move/012_U_inverse.out create mode 100644 test/move/020_U2_solved.in create mode 100644 test/move/020_U2_solved.out create mode 100644 test/move/021_U2_scrambled.in create mode 100644 test/move/021_U2_scrambled.out create mode 100644 test/move/022_U2_inverse.in create mode 100644 test/move/022_U2_inverse.out create mode 100644 test/move/030_U3_solved.in create mode 100644 test/move/030_U3_solved.out create mode 100644 test/move/031_U3_inverse.in create mode 100644 test/move/031_U3_inverse.out create mode 100644 test/move/032_U3_scrambled.in create mode 100644 test/move/032_U3_scrambled.out create mode 100644 test/move/033_U3_with_prime.in create mode 100644 test/move/033_U3_with_prime.out create mode 100644 test/move/040_D_solved.in create mode 100644 test/move/040_D_solved.out create mode 100644 test/move/050_D2_solved.in create mode 100644 test/move/050_D2_solved.out create mode 100644 test/move/060_D3_solved.in create mode 100644 test/move/060_D3_solved.out create mode 100644 test/move/070_R_solved.in create mode 100644 test/move/070_R_solved.out create mode 100644 test/move/071_R_scrambled.in create mode 100644 test/move/071_R_scrambled.out create mode 100644 test/move/080_R2_solved.in create mode 100644 test/move/080_R2_solved.out create mode 100644 test/move/090_R3_solved.in create mode 100644 test/move/090_R3_solved.out create mode 100644 test/move/100_L_solved.in create mode 100644 test/move/100_L_solved.out create mode 100644 test/move/110_L2_solved.in create mode 100644 test/move/110_L2_solved.out create mode 100644 test/move/120_L3_solved.in create mode 100644 test/move/120_L3_solved.out create mode 100644 test/move/130_F_solved.in create mode 100644 test/move/130_F_solved.out create mode 100644 test/move/132_F_scrambled.in create mode 100644 test/move/132_F_scrambled.out create mode 100644 test/move/133_F_scrambled_2.in create mode 100644 test/move/133_F_scrambled_2.out create mode 100644 test/move/140_F2_solved.in create mode 100644 test/move/140_F2_solved.out create mode 100644 test/move/150_F3_solved.in create mode 100644 test/move/150_F3_solved.out create mode 100644 test/move/160_B_solved.in create mode 100644 test/move/160_B_solved.out create mode 100644 test/move/170_B2_solved.in create mode 100644 test/move/170_B2_solved.out create mode 100644 test/move/180_B3_solved.in create mode 100644 test/move/180_B3_solved.out create mode 100644 test/move/200_scramble_solved.in create mode 100644 test/move/200_scramble_solved.out create mode 100644 test/move/201_solution_scrambled.in create mode 100644 test/move/201_solution_scrambled.out create mode 100644 test/move/move_tests.c create mode 100755 test/test.sh (limited to 'test') diff --git a/test/basic/all.in b/test/basic/all.in new file mode 100644 index 0000000..e69de29 diff --git a/test/basic/all.out b/test/basic/all.out new file mode 100644 index 0000000..d77f7f4 --- /dev/null +++ b/test/basic/all.out @@ -0,0 +1,4 @@ +Solved is consistent +Solved is solved +Zero is NOT consistent +Zero is NOT solved diff --git a/test/basic/basic_tests.c b/test/basic/basic_tests.c new file mode 100644 index 0000000..cc2a55c --- /dev/null +++ b/test/basic/basic_tests.c @@ -0,0 +1,19 @@ +#include +#include +#include + +#include "../../src/cube.h" + +int main() { + cube_t z, s; + + s = solvedcube; + printf("Solved %s consistent\n", isconsistent(s) ? "is" : "is NOT"); + printf("Solved %s solved\n", issolved(s) ? "is" : "is NOT"); + + z = (cube_t){0}; + printf("Zero %s consistent\n", isconsistent(z) ? "is" : "is NOT"); + printf("Zero %s solved\n", issolved(z) ? "is" : "is NOT"); + + return 0; +} diff --git a/test/io/00_garbage.in b/test/io/00_garbage.in new file mode 100644 index 0000000..9ac203a --- /dev/null +++ b/test/io/00_garbage.in @@ -0,0 +1,3 @@ +FUF0 UBBBR2 k4 +hello +garbage diff --git a/test/io/00_garbage.out b/test/io/00_garbage.out new file mode 100644 index 0000000..5b9114e --- /dev/null +++ b/test/io/00_garbage.out @@ -0,0 +1 @@ +Error reading cube diff --git a/test/io/01_solved_oneline.in b/test/io/01_solved_oneline.in new file mode 100644 index 0000000..dff224d --- /dev/null +++ b/test/io/01_solved_oneline.in @@ -0,0 +1 @@ +UF0 UB0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 diff --git a/test/io/01_solved_oneline.out b/test/io/01_solved_oneline.out new file mode 100644 index 0000000..dff224d --- /dev/null +++ b/test/io/01_solved_oneline.out @@ -0,0 +1 @@ +UF0 UB0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 diff --git a/test/io/02_solved_oneline_whitespace.in b/test/io/02_solved_oneline_whitespace.in new file mode 100644 index 0000000..5d10368 --- /dev/null +++ b/test/io/02_solved_oneline_whitespace.in @@ -0,0 +1 @@ +UF0 UB0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 diff --git a/test/io/02_solved_oneline_whitespace.out b/test/io/02_solved_oneline_whitespace.out new file mode 100644 index 0000000..dff224d --- /dev/null +++ b/test/io/02_solved_oneline_whitespace.out @@ -0,0 +1 @@ +UF0 UB0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 diff --git a/test/io/03_solved_multiline.in b/test/io/03_solved_multiline.in new file mode 100644 index 0000000..9f9652b --- /dev/null +++ b/test/io/03_solved_multiline.in @@ -0,0 +1,9 @@ +UF0 UB0 +DB0 DF0 UR0 UL0 DL0 +DR0 FR0 FL0 BL0 BR0 UFR0 + +UBL0 DFL0 DBR0 + + +UFL0 UBR0 DFR0 + DBL0 diff --git a/test/io/03_solved_multiline.out b/test/io/03_solved_multiline.out new file mode 100644 index 0000000..dff224d --- /dev/null +++ b/test/io/03_solved_multiline.out @@ -0,0 +1 @@ +UF0 UB0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 diff --git a/test/io/04_inconsistent_ep.in b/test/io/04_inconsistent_ep.in new file mode 100644 index 0000000..8483962 --- /dev/null +++ b/test/io/04_inconsistent_ep.in @@ -0,0 +1 @@ +UB0 UF0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 diff --git a/test/io/04_inconsistent_ep.out b/test/io/04_inconsistent_ep.out new file mode 100644 index 0000000..cb70902 --- /dev/null +++ b/test/io/04_inconsistent_ep.out @@ -0,0 +1 @@ +Cube is inconsistent diff --git a/test/io/05_inconsistent_eo.in b/test/io/05_inconsistent_eo.in new file mode 100644 index 0000000..a92089d --- /dev/null +++ b/test/io/05_inconsistent_eo.in @@ -0,0 +1 @@ +UF1 UB0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 diff --git a/test/io/05_inconsistent_eo.out b/test/io/05_inconsistent_eo.out new file mode 100644 index 0000000..cb70902 --- /dev/null +++ b/test/io/05_inconsistent_eo.out @@ -0,0 +1 @@ +Cube is inconsistent diff --git a/test/io/06_inconsistent_cp.in b/test/io/06_inconsistent_cp.in new file mode 100644 index 0000000..2085dd5 --- /dev/null +++ b/test/io/06_inconsistent_cp.in @@ -0,0 +1 @@ +UF0 UB0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 UBL0 UFR0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 diff --git a/test/io/06_inconsistent_cp.out b/test/io/06_inconsistent_cp.out new file mode 100644 index 0000000..cb70902 --- /dev/null +++ b/test/io/06_inconsistent_cp.out @@ -0,0 +1 @@ +Cube is inconsistent diff --git a/test/io/07_inconsistent_co.in b/test/io/07_inconsistent_co.in new file mode 100644 index 0000000..abd74e2 --- /dev/null +++ b/test/io/07_inconsistent_co.in @@ -0,0 +1 @@ +UF0 UB0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 UFR1 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 diff --git a/test/io/07_inconsistent_co.out b/test/io/07_inconsistent_co.out new file mode 100644 index 0000000..cb70902 --- /dev/null +++ b/test/io/07_inconsistent_co.out @@ -0,0 +1 @@ +Cube is inconsistent diff --git a/test/io/08_unsolved.in b/test/io/08_unsolved.in new file mode 100644 index 0000000..c992ce7 --- /dev/null +++ b/test/io/08_unsolved.in @@ -0,0 +1,6 @@ +UL1 DR0 UB0 DL1 +UR0 FR1 DB0 BR0 +UF1 DF0 BL0 FL0 + +UBL0 DLF1 DBR2 UFR1 +DFR1 UBR1 UFL0 DBL0 diff --git a/test/io/08_unsolved.out b/test/io/08_unsolved.out new file mode 100644 index 0000000..8c132cf --- /dev/null +++ b/test/io/08_unsolved.out @@ -0,0 +1 @@ +UL1 DR0 UB0 DL1 UR0 FR1 DB0 BR0 UF1 DF0 BL0 FL0 UBL0 DFL1 DBR2 UFR1 DFR1 UBR1 UFL0 DBL0 diff --git a/test/io/io_tests.c b/test/io/io_tests.c new file mode 100644 index 0000000..1ef99d0 --- /dev/null +++ b/test/io/io_tests.c @@ -0,0 +1,28 @@ +#include +#include +#include + +#include "../../src/cube.h" + +#define STRLENMAX 10000 + +int main() { + char *c, str[STRLENMAX]; + cube_t cube; + + for (c = str; (*c = getchar()) != EOF; c++) ; + *c = '\0'; + + cube = readcube(str); + + if (cube.e == errorcube.e && cube.c == errorcube.c) { + printf("Error reading cube\n"); + } else if (!isconsistent(cube)) { + printf("Cube is inconsistent\n"); + } else { + writecube(cube, str); + printf("%s\n", str); + } + + return 0; +} diff --git a/test/move/000_nomove_solved.in b/test/move/000_nomove_solved.in new file mode 100644 index 0000000..07cf178 --- /dev/null +++ b/test/move/000_nomove_solved.in @@ -0,0 +1,2 @@ + +UF0 UB0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 diff --git a/test/move/000_nomove_solved.out b/test/move/000_nomove_solved.out new file mode 100644 index 0000000..dff224d --- /dev/null +++ b/test/move/000_nomove_solved.out @@ -0,0 +1 @@ +UF0 UB0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 diff --git a/test/move/001_nomove_scrambled.in b/test/move/001_nomove_scrambled.in new file mode 100644 index 0000000..fd1d23c --- /dev/null +++ b/test/move/001_nomove_scrambled.in @@ -0,0 +1,2 @@ + +BR0 DF1 DL1 FR0 UB1 DR1 UF0 UR0 UL0 FL1 BL0 DB1 UBL0 DBR1 UFL1 DFR2 UFR0 UBR1 DBL1 DFL0 diff --git a/test/move/001_nomove_scrambled.out b/test/move/001_nomove_scrambled.out new file mode 100644 index 0000000..bd2cca0 --- /dev/null +++ b/test/move/001_nomove_scrambled.out @@ -0,0 +1 @@ +BR0 DF1 DL1 FR0 UB1 DR1 UF0 UR0 UL0 FL1 BL0 DB1 UBL0 DBR1 UFL1 DFR2 UFR0 UBR1 DBL1 DFL0 diff --git a/test/move/010_U_solved.in b/test/move/010_U_solved.in new file mode 100644 index 0000000..62495cb --- /dev/null +++ b/test/move/010_U_solved.in @@ -0,0 +1,2 @@ +U +UF0 UB0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 diff --git a/test/move/010_U_solved.out b/test/move/010_U_solved.out new file mode 100644 index 0000000..b5b36ad --- /dev/null +++ b/test/move/010_U_solved.out @@ -0,0 +1 @@ +UR0 UL0 DB0 DF0 UB0 UF0 DL0 DR0 FR0 FL0 BL0 BR0 UBR0 UFL0 DFL0 DBR0 UFR0 UBL0 DFR0 DBL0 diff --git a/test/move/011_U_scrambled.in b/test/move/011_U_scrambled.in new file mode 100644 index 0000000..012faaf --- /dev/null +++ b/test/move/011_U_scrambled.in @@ -0,0 +1,2 @@ +U +BR0 DF1 DL1 FR0 UB1 DR1 UF0 UR0 UL0 FL1 BL0 DB1 UBL0 DBR1 UFL1 DFR2 UFR0 UBR1 DBL1 DFL0 diff --git a/test/move/011_U_scrambled.out b/test/move/011_U_scrambled.out new file mode 100644 index 0000000..46d2ef7 --- /dev/null +++ b/test/move/011_U_scrambled.out @@ -0,0 +1 @@ +UB1 DR1 DL1 FR0 DF1 BR0 UF0 UR0 UL0 FL1 BL0 DB1 UBR1 UFR0 UFL1 DFR2 UBL0 DBR1 DBL1 DFL0 diff --git a/test/move/012_U_inverse.in b/test/move/012_U_inverse.in new file mode 100644 index 0000000..2aa7ffa --- /dev/null +++ b/test/move/012_U_inverse.in @@ -0,0 +1,2 @@ +U +UL0 UR0 DB0 DF0 UF0 UB0 DL0 DR0 FR0 FL0 BL0 BR0 UFL0 UBR0 DFL0 DBR0 UBL0 UFR0 DFR0 DBL0 diff --git a/test/move/012_U_inverse.out b/test/move/012_U_inverse.out new file mode 100644 index 0000000..dff224d --- /dev/null +++ b/test/move/012_U_inverse.out @@ -0,0 +1 @@ +UF0 UB0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 diff --git a/test/move/020_U2_solved.in b/test/move/020_U2_solved.in new file mode 100644 index 0000000..ccc84ef --- /dev/null +++ b/test/move/020_U2_solved.in @@ -0,0 +1,2 @@ +U2 +UF0 UB0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 diff --git a/test/move/020_U2_solved.out b/test/move/020_U2_solved.out new file mode 100644 index 0000000..316ad57 --- /dev/null +++ b/test/move/020_U2_solved.out @@ -0,0 +1 @@ +UB0 UF0 DB0 DF0 UL0 UR0 DL0 DR0 FR0 FL0 BL0 BR0 UBL0 UFR0 DFL0 DBR0 UBR0 UFL0 DFR0 DBL0 diff --git a/test/move/021_U2_scrambled.in b/test/move/021_U2_scrambled.in new file mode 100644 index 0000000..bdc034e --- /dev/null +++ b/test/move/021_U2_scrambled.in @@ -0,0 +1,2 @@ +U2 +BR0 DF1 DL1 FR0 UB1 DR1 UF0 UR0 UL0 FL1 BL0 DB1 UBL0 DBR1 UFL1 DFR2 UFR0 UBR1 DBL1 DFL0 diff --git a/test/move/021_U2_scrambled.out b/test/move/021_U2_scrambled.out new file mode 100644 index 0000000..c89ca1f --- /dev/null +++ b/test/move/021_U2_scrambled.out @@ -0,0 +1 @@ +DF1 BR0 DL1 FR0 DR1 UB1 UF0 UR0 UL0 FL1 BL0 DB1 DBR1 UBL0 UFL1 DFR2 UBR1 UFR0 DBL1 DFL0 diff --git a/test/move/022_U2_inverse.in b/test/move/022_U2_inverse.in new file mode 100644 index 0000000..8ace160 --- /dev/null +++ b/test/move/022_U2_inverse.in @@ -0,0 +1,2 @@ +U2 +UB0 UF0 DB0 DF0 UL0 UR0 DL0 DR0 FR0 FL0 BL0 BR0 UBL0 UFR0 DFL0 DBR0 UBR0 UFL0 DFR0 DBL0 diff --git a/test/move/022_U2_inverse.out b/test/move/022_U2_inverse.out new file mode 100644 index 0000000..dff224d --- /dev/null +++ b/test/move/022_U2_inverse.out @@ -0,0 +1 @@ +UF0 UB0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 diff --git a/test/move/030_U3_solved.in b/test/move/030_U3_solved.in new file mode 100644 index 0000000..49a8847 --- /dev/null +++ b/test/move/030_U3_solved.in @@ -0,0 +1,2 @@ +U3 +UF0 UB0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 diff --git a/test/move/030_U3_solved.out b/test/move/030_U3_solved.out new file mode 100644 index 0000000..7721ab5 --- /dev/null +++ b/test/move/030_U3_solved.out @@ -0,0 +1 @@ +UL0 UR0 DB0 DF0 UF0 UB0 DL0 DR0 FR0 FL0 BL0 BR0 UFL0 UBR0 DFL0 DBR0 UBL0 UFR0 DFR0 DBL0 diff --git a/test/move/031_U3_inverse.in b/test/move/031_U3_inverse.in new file mode 100644 index 0000000..44b6ce3 --- /dev/null +++ b/test/move/031_U3_inverse.in @@ -0,0 +1,2 @@ +U3 +UR0 UL0 DB0 DF0 UB0 UF0 DL0 DR0 FR0 FL0 BL0 BR0 UBR0 UFL0 DFL0 DBR0 UFR0 UBL0 DFR0 DBL0 diff --git a/test/move/031_U3_inverse.out b/test/move/031_U3_inverse.out new file mode 100644 index 0000000..dff224d --- /dev/null +++ b/test/move/031_U3_inverse.out @@ -0,0 +1 @@ +UF0 UB0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 diff --git a/test/move/032_U3_scrambled.in b/test/move/032_U3_scrambled.in new file mode 100644 index 0000000..a00608c --- /dev/null +++ b/test/move/032_U3_scrambled.in @@ -0,0 +1,2 @@ +U3 +UF1 BR0 DL1 UR1 FR1 FL0 UL0 BL1 DR0 DF1 DB0 UB0 UBR2 DFL1 UFL0 DBR1 UBL2 DFR0 DBL2 UFR1 diff --git a/test/move/032_U3_scrambled.out b/test/move/032_U3_scrambled.out new file mode 100644 index 0000000..7d1e8cd --- /dev/null +++ b/test/move/032_U3_scrambled.out @@ -0,0 +1 @@ +FL0 FR1 DL1 UR1 UF1 BR0 UL0 BL1 DR0 DF1 DB0 UB0 UBL2 DFR0 UFL0 DBR1 DFL1 UBR2 DBL2 UFR1 diff --git a/test/move/033_U3_with_prime.in b/test/move/033_U3_with_prime.in new file mode 100644 index 0000000..95e5405 --- /dev/null +++ b/test/move/033_U3_with_prime.in @@ -0,0 +1,2 @@ +U' +UF0 UB0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 diff --git a/test/move/033_U3_with_prime.out b/test/move/033_U3_with_prime.out new file mode 100644 index 0000000..7721ab5 --- /dev/null +++ b/test/move/033_U3_with_prime.out @@ -0,0 +1 @@ +UL0 UR0 DB0 DF0 UF0 UB0 DL0 DR0 FR0 FL0 BL0 BR0 UFL0 UBR0 DFL0 DBR0 UBL0 UFR0 DFR0 DBL0 diff --git a/test/move/040_D_solved.in b/test/move/040_D_solved.in new file mode 100644 index 0000000..cb5edb7 --- /dev/null +++ b/test/move/040_D_solved.in @@ -0,0 +1,2 @@ +D +UF0 UB0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 diff --git a/test/move/040_D_solved.out b/test/move/040_D_solved.out new file mode 100644 index 0000000..cf4f816 --- /dev/null +++ b/test/move/040_D_solved.out @@ -0,0 +1 @@ +UF0 UB0 DR0 DL0 UR0 UL0 DB0 DF0 FR0 FL0 BL0 BR0 UFR0 UBL0 DBL0 DFR0 UFL0 UBR0 DFL0 DBR0 diff --git a/test/move/050_D2_solved.in b/test/move/050_D2_solved.in new file mode 100644 index 0000000..56f47cd --- /dev/null +++ b/test/move/050_D2_solved.in @@ -0,0 +1,2 @@ +D2 +UF0 UB0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 diff --git a/test/move/050_D2_solved.out b/test/move/050_D2_solved.out new file mode 100644 index 0000000..13b229e --- /dev/null +++ b/test/move/050_D2_solved.out @@ -0,0 +1 @@ +UF0 UB0 DF0 DB0 UR0 UL0 DR0 DL0 FR0 FL0 BL0 BR0 UFR0 UBL0 DBR0 DFL0 UFL0 UBR0 DBL0 DFR0 diff --git a/test/move/060_D3_solved.in b/test/move/060_D3_solved.in new file mode 100644 index 0000000..64d1dd8 --- /dev/null +++ b/test/move/060_D3_solved.in @@ -0,0 +1,2 @@ +D3 +UF0 UB0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 diff --git a/test/move/060_D3_solved.out b/test/move/060_D3_solved.out new file mode 100644 index 0000000..2864f5b --- /dev/null +++ b/test/move/060_D3_solved.out @@ -0,0 +1 @@ +UF0 UB0 DL0 DR0 UR0 UL0 DF0 DB0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFR0 DBL0 UFL0 UBR0 DBR0 DFL0 diff --git a/test/move/070_R_solved.in b/test/move/070_R_solved.in new file mode 100644 index 0000000..108538a --- /dev/null +++ b/test/move/070_R_solved.in @@ -0,0 +1,2 @@ +R +UF0 UB0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 diff --git a/test/move/070_R_solved.out b/test/move/070_R_solved.out new file mode 100644 index 0000000..8c8fcb3 --- /dev/null +++ b/test/move/070_R_solved.out @@ -0,0 +1 @@ +UF0 UB0 DB0 DF0 FR0 UL0 DL0 BR0 DR0 FL0 BL0 UR0 DFR2 UBL0 DFL0 UBR2 UFL0 UFR1 DBR1 DBL0 diff --git a/test/move/071_R_scrambled.in b/test/move/071_R_scrambled.in new file mode 100644 index 0000000..0c9dcaf --- /dev/null +++ b/test/move/071_R_scrambled.in @@ -0,0 +1,2 @@ +R +UF1 BR0 DL1 UR1 FR1 FL0 UL0 BL1 DR0 DF1 DB0 UB0 UBR2 DFL1 UFL0 DBR1 UBL2 DFR0 DBL2 UFR1 diff --git a/test/move/071_R_scrambled.out b/test/move/071_R_scrambled.out new file mode 100644 index 0000000..650bcc8 --- /dev/null +++ b/test/move/071_R_scrambled.out @@ -0,0 +1 @@ +UF1 BR0 DL1 UR1 DR0 FL0 UL0 UB0 BL1 DF1 DB0 FR1 DBL1 DFL1 UFL0 DFR2 UBL2 UBR0 DBR2 UFR1 diff --git a/test/move/080_R2_solved.in b/test/move/080_R2_solved.in new file mode 100644 index 0000000..554a084 --- /dev/null +++ b/test/move/080_R2_solved.in @@ -0,0 +1,2 @@ +R2 +UF0 UB0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 diff --git a/test/move/080_R2_solved.out b/test/move/080_R2_solved.out new file mode 100644 index 0000000..90765e2 --- /dev/null +++ b/test/move/080_R2_solved.out @@ -0,0 +1 @@ +UF0 UB0 DB0 DF0 DR0 UL0 DL0 UR0 BR0 FL0 BL0 FR0 DBR0 UBL0 DFL0 UFR0 UFL0 DFR0 UBR0 DBL0 diff --git a/test/move/090_R3_solved.in b/test/move/090_R3_solved.in new file mode 100644 index 0000000..ca6cfd8 --- /dev/null +++ b/test/move/090_R3_solved.in @@ -0,0 +1,2 @@ +R3 +UF0 UB0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 diff --git a/test/move/090_R3_solved.out b/test/move/090_R3_solved.out new file mode 100644 index 0000000..d4abffc --- /dev/null +++ b/test/move/090_R3_solved.out @@ -0,0 +1 @@ +UF0 UB0 DB0 DF0 BR0 UL0 DL0 FR0 UR0 FL0 BL0 DR0 UBR2 UBL0 DFL0 DFR2 UFL0 DBR1 UFR1 DBL0 diff --git a/test/move/100_L_solved.in b/test/move/100_L_solved.in new file mode 100644 index 0000000..14ebb5f --- /dev/null +++ b/test/move/100_L_solved.in @@ -0,0 +1,2 @@ +L +UF0 UB0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 diff --git a/test/move/100_L_solved.out b/test/move/100_L_solved.out new file mode 100644 index 0000000..0b0565c --- /dev/null +++ b/test/move/100_L_solved.out @@ -0,0 +1 @@ +UF0 UB0 DB0 DF0 UR0 BL0 FL0 DR0 FR0 UL0 DL0 BR0 UFR0 DBL2 UFL2 DBR0 UBL1 UBR0 DFR0 DFL1 diff --git a/test/move/110_L2_solved.in b/test/move/110_L2_solved.in new file mode 100644 index 0000000..8224bcd --- /dev/null +++ b/test/move/110_L2_solved.in @@ -0,0 +1,2 @@ +L2 +UF0 UB0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 diff --git a/test/move/110_L2_solved.out b/test/move/110_L2_solved.out new file mode 100644 index 0000000..2498c87 --- /dev/null +++ b/test/move/110_L2_solved.out @@ -0,0 +1 @@ +UF0 UB0 DB0 DF0 UR0 DL0 UL0 DR0 FR0 BL0 FL0 BR0 UFR0 DFL0 UBL0 DBR0 DBL0 UBR0 DFR0 UFL0 diff --git a/test/move/120_L3_solved.in b/test/move/120_L3_solved.in new file mode 100644 index 0000000..552d319 --- /dev/null +++ b/test/move/120_L3_solved.in @@ -0,0 +1,2 @@ +L3 +UF0 UB0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 diff --git a/test/move/120_L3_solved.out b/test/move/120_L3_solved.out new file mode 100644 index 0000000..2ac2912 --- /dev/null +++ b/test/move/120_L3_solved.out @@ -0,0 +1 @@ +UF0 UB0 DB0 DF0 UR0 FL0 BL0 DR0 FR0 DL0 UL0 BR0 UFR0 UFL2 DBL2 DBR0 DFL1 UBR0 DFR0 UBL1 diff --git a/test/move/130_F_solved.in b/test/move/130_F_solved.in new file mode 100644 index 0000000..abdbd35 --- /dev/null +++ b/test/move/130_F_solved.in @@ -0,0 +1,2 @@ +F +UF0 UB0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 diff --git a/test/move/130_F_solved.out b/test/move/130_F_solved.out new file mode 100644 index 0000000..e805af8 --- /dev/null +++ b/test/move/130_F_solved.out @@ -0,0 +1 @@ +FL1 UB0 DB0 FR1 UR0 UL0 DL0 DR0 UF1 DF1 BL0 BR0 UFL1 UBL0 DFR1 DBR0 DFL2 UBR0 UFR2 DBL0 diff --git a/test/move/132_F_scrambled.in b/test/move/132_F_scrambled.in new file mode 100644 index 0000000..8b15575 --- /dev/null +++ b/test/move/132_F_scrambled.in @@ -0,0 +1,2 @@ +F +DL1 BR0 DR0 UR1 DF0 FL1 BL0 UL0 FR0 UF0 DB1 UB0 UFR0 DBL1 DBR0 UFL1 DFR1 DFL1 UBL2 UBR0 diff --git a/test/move/132_F_scrambled.out b/test/move/132_F_scrambled.out new file mode 100644 index 0000000..3aea663 --- /dev/null +++ b/test/move/132_F_scrambled.out @@ -0,0 +1 @@ +UF1 BR0 DR0 FR1 DF0 FL1 BL0 UL0 DL0 UR0 DB1 UB0 DFR2 DBL1 UBL0 UFL1 DBR2 DFL1 UFR2 UBR0 diff --git a/test/move/133_F_scrambled_2.in b/test/move/133_F_scrambled_2.in new file mode 100644 index 0000000..fdd5139 --- /dev/null +++ b/test/move/133_F_scrambled_2.in @@ -0,0 +1,2 @@ +F +BL1 DB0 UL1 DF0 BR1 UF1 DL0 FL1 UB0 DR1 FR1 UR1 UBR2 UBL1 DFR2 DBL2 DBR0 DFL0 UFR0 UFL2 diff --git a/test/move/133_F_scrambled_2.out b/test/move/133_F_scrambled_2.out new file mode 100644 index 0000000..3546894 --- /dev/null +++ b/test/move/133_F_scrambled_2.out @@ -0,0 +1 @@ +DR0 DB0 UL1 UB1 BR1 UF1 DL0 FL1 BL0 DF1 FR1 UR1 DBR1 UBL1 UFR1 DBL2 DFR1 DFL0 UBR1 UFL2 diff --git a/test/move/140_F2_solved.in b/test/move/140_F2_solved.in new file mode 100644 index 0000000..83aab30 --- /dev/null +++ b/test/move/140_F2_solved.in @@ -0,0 +1,2 @@ +F2 +UF0 UB0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 diff --git a/test/move/140_F2_solved.out b/test/move/140_F2_solved.out new file mode 100644 index 0000000..8aa701f --- /dev/null +++ b/test/move/140_F2_solved.out @@ -0,0 +1 @@ +DF0 UB0 DB0 UF0 UR0 UL0 DL0 DR0 FL0 FR0 BL0 BR0 DFL0 UBL0 UFR0 DBR0 DFR0 UBR0 UFL0 DBL0 diff --git a/test/move/150_F3_solved.in b/test/move/150_F3_solved.in new file mode 100644 index 0000000..2c766c1 --- /dev/null +++ b/test/move/150_F3_solved.in @@ -0,0 +1,2 @@ +F3 +UF0 UB0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 diff --git a/test/move/150_F3_solved.out b/test/move/150_F3_solved.out new file mode 100644 index 0000000..40f1260 --- /dev/null +++ b/test/move/150_F3_solved.out @@ -0,0 +1 @@ +FR1 UB0 DB0 FL1 UR0 UL0 DL0 DR0 DF1 UF1 BL0 BR0 DFR1 UBL0 UFL1 DBR0 UFR2 UBR0 DFL2 DBL0 diff --git a/test/move/160_B_solved.in b/test/move/160_B_solved.in new file mode 100644 index 0000000..6062e45 --- /dev/null +++ b/test/move/160_B_solved.in @@ -0,0 +1,2 @@ +B +UF0 UB0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 diff --git a/test/move/160_B_solved.out b/test/move/160_B_solved.out new file mode 100644 index 0000000..f7fb13c --- /dev/null +++ b/test/move/160_B_solved.out @@ -0,0 +1 @@ +UF0 BR1 BL1 DF0 UR0 UL0 DL0 DR0 FR0 FL0 UB1 DB1 UFR0 UBR1 DFL0 DBL1 UFL0 DBR2 DFR0 UBL2 diff --git a/test/move/170_B2_solved.in b/test/move/170_B2_solved.in new file mode 100644 index 0000000..0ff1190 --- /dev/null +++ b/test/move/170_B2_solved.in @@ -0,0 +1,2 @@ +B2 +UF0 UB0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 diff --git a/test/move/170_B2_solved.out b/test/move/170_B2_solved.out new file mode 100644 index 0000000..9b33e35 --- /dev/null +++ b/test/move/170_B2_solved.out @@ -0,0 +1 @@ +UF0 DB0 UB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BR0 BL0 UFR0 DBR0 DFL0 UBL0 UFL0 DBL0 DFR0 UBR0 diff --git a/test/move/180_B3_solved.in b/test/move/180_B3_solved.in new file mode 100644 index 0000000..c59636f --- /dev/null +++ b/test/move/180_B3_solved.in @@ -0,0 +1,2 @@ +B3 +UF0 UB0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 diff --git a/test/move/180_B3_solved.out b/test/move/180_B3_solved.out new file mode 100644 index 0000000..1367517 --- /dev/null +++ b/test/move/180_B3_solved.out @@ -0,0 +1 @@ +UF0 BL1 BR1 DF0 UR0 UL0 DL0 DR0 FR0 FL0 DB1 UB1 UFR0 DBL1 DFL0 UBR1 UFL0 UBL2 DFR0 DBR2 diff --git a/test/move/200_scramble_solved.in b/test/move/200_scramble_solved.in new file mode 100644 index 0000000..939d876 --- /dev/null +++ b/test/move/200_scramble_solved.in @@ -0,0 +1,2 @@ +B' D' B' R2 B' R F D F2 U2 B D2 F R2 F2 L2 F L2 U2 +UF0 UB0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 diff --git a/test/move/200_scramble_solved.out b/test/move/200_scramble_solved.out new file mode 100644 index 0000000..690ff6b --- /dev/null +++ b/test/move/200_scramble_solved.out @@ -0,0 +1 @@ +BR0 DF0 FL1 UB0 BL0 FR1 UR1 UL0 DR1 DB0 UF1 DL1 DFL0 DFR0 UFL1 UBL2 DBR1 DBL0 UFR1 UBR1 diff --git a/test/move/201_solution_scrambled.in b/test/move/201_solution_scrambled.in new file mode 100644 index 0000000..a838b4c --- /dev/null +++ b/test/move/201_solution_scrambled.in @@ -0,0 +1,2 @@ +F' B' D2 U2 F2 U' L' U D B D' R2 B' L' R' D' R D L2 U' L' B L L U F U' F' U F U' F2 L' F U F U' F' U2 F2 R2 L2 B2 +BR0 DF0 FL1 UB0 BL0 FR1 UR1 UL0 DR1 DB0 UF1 DL1 DFL0 DFR0 UFL1 UBL2 DBR1 DBL0 UFR1 UBR1 diff --git a/test/move/201_solution_scrambled.out b/test/move/201_solution_scrambled.out new file mode 100644 index 0000000..dff224d --- /dev/null +++ b/test/move/201_solution_scrambled.out @@ -0,0 +1 @@ +UF0 UB0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 diff --git a/test/move/move_tests.c b/test/move/move_tests.c new file mode 100644 index 0000000..23fc45e --- /dev/null +++ b/test/move/move_tests.c @@ -0,0 +1,40 @@ +#include +#include +#include + +#include "../../src/cube.h" + +#define STRLENMAX 10000 +#define MOVESMAX 1000 + +int main() { + char str[STRLENMAX]; + int i, n; + move_t moves[MOVESMAX]; + cube_t cube; + + fgets(str, STRLENMAX, stdin); + n = readmoves(str, moves); + + if (n == -1) { + printf("Error reading moves\n"); + return 1; + } + + fgets(str, STRLENMAX, stdin); + cube = readcube(str); + + for (i = 0; i < n; i++) + cube = move(cube, moves[i]); + + if (cube.e == errorcube.e && cube.c == errorcube.c) { + printf("Error moving cube\n"); + } else if (!isconsistent(cube)) { + printf("Moved cube is inconsistent\n"); + } else { + writecube(cube, str); + printf("%s\n", str); + } + + return 0; +} diff --git a/test/test.sh b/test/test.sh new file mode 100755 index 0000000..d59270b --- /dev/null +++ b/test/test.sh @@ -0,0 +1,32 @@ +#!/bin/sh + +CC="cc -DDEBUG -std=c99 -pthread -pedantic -Wall -Wextra \ + -Wno-unused-parameter -Wno-unused-function -g3" +if [ $(uname) != "OpenBSD" ]; then + CC="$CC -fsanitize=address -fsanitize=undefined" +fi +SRC="src/cube.c" +TESTBIN="test/run" +TESTOUT="test/last.out" +TESTERR="test/last.err" + +for t in test/*; do + if [ ! -d $t ]; then continue; fi + $CC -o $TESTBIN $t/*.c $SRC || exit 1; + for cin in $t/*.in; do + c=$(echo "$cin" | sed 's/\.in//') + cout=$c.out + printf "$c: " + $TESTBIN < "$cin" > $TESTOUT 2> $TESTERR + if diff $cout $TESTOUT; then + printf "OK\n" + else + printf "Test failed! stderr:\n" + cat $TESTERR + exit 1 + fi + done +done + +echo "All tests passed!" +rm -rf $TESTBIN $TESTOUT $TESTERR -- cgit v1.3