diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2023-05-29 01:06:09 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2023-05-29 01:06:09 +0200 |
| commit | f987f5af492f2ac9d5aeebd351bcb49175556af2 (patch) | |
| tree | e4a6a242996f83c2110dcf46dc2b7a3f271f2b44 /test | |
| download | nissy-core-f987f5af492f2ac9d5aeebd351bcb49175556af2.tar.gz nissy-core-f987f5af492f2ac9d5aeebd351bcb49175556af2.zip | |
Initial commit
Diffstat (limited to 'test')
88 files changed, 252 insertions, 0 deletions
diff --git a/test/basic/all.in b/test/basic/all.in new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test/basic/all.in | |||
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 @@ | |||
| 1 | Solved is consistent | ||
| 2 | Solved is solved | ||
| 3 | Zero is NOT consistent | ||
| 4 | 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 @@ | |||
| 1 | #include <stdbool.h> | ||
| 2 | #include <stdint.h> | ||
| 3 | #include <stdio.h> | ||
| 4 | |||
| 5 | #include "../../src/cube.h" | ||
| 6 | |||
| 7 | int main() { | ||
| 8 | cube_t z, s; | ||
| 9 | |||
| 10 | s = solvedcube; | ||
| 11 | printf("Solved %s consistent\n", isconsistent(s) ? "is" : "is NOT"); | ||
| 12 | printf("Solved %s solved\n", issolved(s) ? "is" : "is NOT"); | ||
| 13 | |||
| 14 | z = (cube_t){0}; | ||
| 15 | printf("Zero %s consistent\n", isconsistent(z) ? "is" : "is NOT"); | ||
| 16 | printf("Zero %s solved\n", issolved(z) ? "is" : "is NOT"); | ||
| 17 | |||
| 18 | return 0; | ||
| 19 | } | ||
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 @@ | |||
| 1 | FUF0 UBBBR2 k4 | ||
| 2 | hello | ||
| 3 | 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 @@ | |||
| 1 | UF0 UB0 | ||
| 2 | DB0 DF0 UR0 UL0 DL0 | ||
| 3 | DR0 FR0 FL0 BL0 BR0 UFR0 | ||
| 4 | |||
| 5 | UBL0 DFL0 DBR0 | ||
| 6 | |||
| 7 | |||
| 8 | UFL0 UBR0 DFR0 | ||
| 9 | 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 @@ | |||
| 1 | UL1 DR0 UB0 DL1 | ||
| 2 | UR0 FR1 DB0 BR0 | ||
| 3 | UF1 DF0 BL0 FL0 | ||
| 4 | |||
| 5 | UBL0 DLF1 DBR2 UFR1 | ||
| 6 | 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 @@ | |||
| 1 | #include <stdbool.h> | ||
| 2 | #include <stdint.h> | ||
| 3 | #include <stdio.h> | ||
| 4 | |||
| 5 | #include "../../src/cube.h" | ||
| 6 | |||
| 7 | #define STRLENMAX 10000 | ||
| 8 | |||
| 9 | int main() { | ||
| 10 | char *c, str[STRLENMAX]; | ||
| 11 | cube_t cube; | ||
| 12 | |||
| 13 | for (c = str; (*c = getchar()) != EOF; c++) ; | ||
| 14 | *c = '\0'; | ||
| 15 | |||
| 16 | cube = readcube(str); | ||
| 17 | |||
| 18 | if (cube.e == errorcube.e && cube.c == errorcube.c) { | ||
| 19 | printf("Error reading cube\n"); | ||
| 20 | } else if (!isconsistent(cube)) { | ||
| 21 | printf("Cube is inconsistent\n"); | ||
| 22 | } else { | ||
| 23 | writecube(cube, str); | ||
| 24 | printf("%s\n", str); | ||
| 25 | } | ||
| 26 | |||
| 27 | return 0; | ||
| 28 | } | ||
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 @@ | |||
| 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 @@ | |||
| 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 @@ | |||
| 1 | U | ||
| 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/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 @@ | |||
| 1 | U | ||
| 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/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 @@ | |||
| 1 | U | ||
| 2 | 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 @@ | |||
| 1 | U2 | ||
| 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/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 @@ | |||
| 1 | U2 | ||
| 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/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 @@ | |||
| 1 | U2 | ||
| 2 | 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 @@ | |||
| 1 | U3 | ||
| 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/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 @@ | |||
| 1 | U3 | ||
| 2 | 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 @@ | |||
| 1 | U3 | ||
| 2 | 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 @@ | |||
| 1 | U' | ||
| 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/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 @@ | |||
| 1 | D | ||
| 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/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 @@ | |||
| 1 | D2 | ||
| 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/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 @@ | |||
| 1 | D3 | ||
| 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/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 @@ | |||
| 1 | R | ||
| 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/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 @@ | |||
| 1 | R | ||
| 2 | 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 @@ | |||
| 1 | R2 | ||
| 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/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 @@ | |||
| 1 | R3 | ||
| 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/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 @@ | |||
| 1 | L | ||
| 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/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 @@ | |||
| 1 | L2 | ||
| 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/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 @@ | |||
| 1 | L3 | ||
| 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/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 @@ | |||
| 1 | F | ||
| 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/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 @@ | |||
| 1 | F | ||
| 2 | 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 @@ | |||
| 1 | F | ||
| 2 | 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 @@ | |||
| 1 | F2 | ||
| 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/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 @@ | |||
| 1 | F3 | ||
| 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/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 @@ | |||
| 1 | B | ||
| 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/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 @@ | |||
| 1 | B2 | ||
| 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/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 @@ | |||
| 1 | B3 | ||
| 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/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 @@ | |||
| 1 | B' D' B' R2 B' R F D F2 U2 B D2 F R2 F2 L2 F L2 U2 | ||
| 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/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 @@ | |||
| 1 | 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 | ||
| 2 | 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 @@ | |||
| 1 | #include <stdbool.h> | ||
| 2 | #include <stdint.h> | ||
| 3 | #include <stdio.h> | ||
| 4 | |||
| 5 | #include "../../src/cube.h" | ||
| 6 | |||
| 7 | #define STRLENMAX 10000 | ||
| 8 | #define MOVESMAX 1000 | ||
| 9 | |||
| 10 | int main() { | ||
| 11 | char str[STRLENMAX]; | ||
| 12 | int i, n; | ||
| 13 | move_t moves[MOVESMAX]; | ||
| 14 | cube_t cube; | ||
| 15 | |||
| 16 | fgets(str, STRLENMAX, stdin); | ||
| 17 | n = readmoves(str, moves); | ||
| 18 | |||
| 19 | if (n == -1) { | ||
| 20 | printf("Error reading moves\n"); | ||
| 21 | return 1; | ||
| 22 | } | ||
| 23 | |||
| 24 | fgets(str, STRLENMAX, stdin); | ||
| 25 | cube = readcube(str); | ||
| 26 | |||
| 27 | for (i = 0; i < n; i++) | ||
| 28 | cube = move(cube, moves[i]); | ||
| 29 | |||
| 30 | if (cube.e == errorcube.e && cube.c == errorcube.c) { | ||
| 31 | printf("Error moving cube\n"); | ||
| 32 | } else if (!isconsistent(cube)) { | ||
| 33 | printf("Moved cube is inconsistent\n"); | ||
| 34 | } else { | ||
| 35 | writecube(cube, str); | ||
| 36 | printf("%s\n", str); | ||
| 37 | } | ||
| 38 | |||
| 39 | return 0; | ||
| 40 | } | ||
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 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | CC="cc -DDEBUG -std=c99 -pthread -pedantic -Wall -Wextra \ | ||
| 4 | -Wno-unused-parameter -Wno-unused-function -g3" | ||
| 5 | if [ $(uname) != "OpenBSD" ]; then | ||
| 6 | CC="$CC -fsanitize=address -fsanitize=undefined" | ||
| 7 | fi | ||
| 8 | SRC="src/cube.c" | ||
| 9 | TESTBIN="test/run" | ||
| 10 | TESTOUT="test/last.out" | ||
| 11 | TESTERR="test/last.err" | ||
| 12 | |||
| 13 | for t in test/*; do | ||
| 14 | if [ ! -d $t ]; then continue; fi | ||
| 15 | $CC -o $TESTBIN $t/*.c $SRC || exit 1; | ||
| 16 | for cin in $t/*.in; do | ||
| 17 | c=$(echo "$cin" | sed 's/\.in//') | ||
| 18 | cout=$c.out | ||
| 19 | printf "$c: " | ||
| 20 | $TESTBIN < "$cin" > $TESTOUT 2> $TESTERR | ||
| 21 | if diff $cout $TESTOUT; then | ||
| 22 | printf "OK\n" | ||
| 23 | else | ||
| 24 | printf "Test failed! stderr:\n" | ||
| 25 | cat $TESTERR | ||
| 26 | exit 1 | ||
| 27 | fi | ||
| 28 | done | ||
| 29 | done | ||
| 30 | |||
| 31 | echo "All tests passed!" | ||
| 32 | rm -rf $TESTBIN $TESTOUT $TESTERR | ||
