diff options
Diffstat (limited to 'test/130_appendsolution')
19 files changed, 143 insertions, 0 deletions
diff --git a/test/130_appendsolution/00_empty.in b/test/130_appendsolution/00_empty.in new file mode 100644 index 0000000..c4cad6e --- /dev/null +++ b/test/130_appendsolution/00_empty.in | |||
| @@ -0,0 +1,5 @@ | |||
| 1 | |||
| 2 | |||
| 3 | 0 | ||
| 4 | 1 | ||
| 5 | rotation UF | ||
diff --git a/test/130_appendsolution/00_empty.out b/test/130_appendsolution/00_empty.out new file mode 100644 index 0000000..8581416 --- /dev/null +++ b/test/130_appendsolution/00_empty.out | |||
| @@ -0,0 +1,4 @@ | |||
| 1 | |||
| 2 | Number of solutions: 1 | ||
| 3 | Shortest solution length: 0 | ||
| 4 | Used bytes: 1 | ||
diff --git a/test/130_appendsolution/01_simple_onlynormal_nounniss.in b/test/130_appendsolution/01_simple_onlynormal_nounniss.in new file mode 100644 index 0000000..37b6f3d --- /dev/null +++ b/test/130_appendsolution/01_simple_onlynormal_nounniss.in | |||
| @@ -0,0 +1,5 @@ | |||
| 1 | U F R D2 B' | ||
| 2 | |||
| 3 | 0 | ||
| 4 | 1 | ||
| 5 | rotation UF | ||
diff --git a/test/130_appendsolution/01_simple_onlynormal_nounniss.out b/test/130_appendsolution/01_simple_onlynormal_nounniss.out new file mode 100644 index 0000000..b577962 --- /dev/null +++ b/test/130_appendsolution/01_simple_onlynormal_nounniss.out | |||
| @@ -0,0 +1,4 @@ | |||
| 1 | U F R D2 B' | ||
| 2 | Number of solutions: 1 | ||
| 3 | Shortest solution length: 5 | ||
| 4 | Used bytes: 12 | ||
diff --git a/test/130_appendsolution/02_simple_onlynormal_nounnis_multitrans.in b/test/130_appendsolution/02_simple_onlynormal_nounnis_multitrans.in new file mode 100644 index 0000000..c4ff41a --- /dev/null +++ b/test/130_appendsolution/02_simple_onlynormal_nounnis_multitrans.in | |||
| @@ -0,0 +1,8 @@ | |||
| 1 | U F R | ||
| 2 | |||
| 3 | 0 | ||
| 4 | 4 | ||
| 5 | rotation UF | ||
| 6 | mirrored UR | ||
| 7 | rotation BD | ||
| 8 | mirrored LB | ||
diff --git a/test/130_appendsolution/02_simple_onlynormal_nounnis_multitrans.out b/test/130_appendsolution/02_simple_onlynormal_nounnis_multitrans.out new file mode 100644 index 0000000..e1b5631 --- /dev/null +++ b/test/130_appendsolution/02_simple_onlynormal_nounnis_multitrans.out | |||
| @@ -0,0 +1,7 @@ | |||
| 1 | U F R | ||
| 2 | B D L | ||
| 3 | U' L' B' | ||
| 4 | R' B' D' | ||
| 5 | Number of solutions: 4 | ||
| 6 | Shortest solution length: 3 | ||
| 7 | Used bytes: 30 | ||
diff --git a/test/130_appendsolution/03_simple_unniss.in b/test/130_appendsolution/03_simple_unniss.in new file mode 100644 index 0000000..231f60c --- /dev/null +++ b/test/130_appendsolution/03_simple_unniss.in | |||
| @@ -0,0 +1,5 @@ | |||
| 1 | U F B2 | ||
| 2 | R' F D | ||
| 3 | 1 | ||
| 4 | 1 | ||
| 5 | rotation UF | ||
diff --git a/test/130_appendsolution/03_simple_unniss.out b/test/130_appendsolution/03_simple_unniss.out new file mode 100644 index 0000000..3ca210e --- /dev/null +++ b/test/130_appendsolution/03_simple_unniss.out | |||
| @@ -0,0 +1,4 @@ | |||
| 1 | U F B2 D' F' R | ||
| 2 | Number of solutions: 1 | ||
| 3 | Shortest solution length: 6 | ||
| 4 | Used bytes: 15 | ||
diff --git a/test/130_appendsolution/04_niss_nounniss.in b/test/130_appendsolution/04_niss_nounniss.in new file mode 100644 index 0000000..39c6518 --- /dev/null +++ b/test/130_appendsolution/04_niss_nounniss.in | |||
| @@ -0,0 +1,5 @@ | |||
| 1 | U F B2 | ||
| 2 | R' F D | ||
| 3 | 0 | ||
| 4 | 1 | ||
| 5 | rotation UF | ||
diff --git a/test/130_appendsolution/04_niss_nounniss.out b/test/130_appendsolution/04_niss_nounniss.out new file mode 100644 index 0000000..a616b4c --- /dev/null +++ b/test/130_appendsolution/04_niss_nounniss.out | |||
| @@ -0,0 +1,4 @@ | |||
| 1 | U F B2 (R' F D) | ||
| 2 | Number of solutions: 1 | ||
| 3 | Shortest solution length: 6 | ||
| 4 | Used bytes: 16 | ||
diff --git a/test/130_appendsolution/05_sort_parallel.in b/test/130_appendsolution/05_sort_parallel.in new file mode 100644 index 0000000..7c8c4f5 --- /dev/null +++ b/test/130_appendsolution/05_sort_parallel.in | |||
| @@ -0,0 +1,5 @@ | |||
| 1 | L R' B2 F | ||
| 2 | |||
| 3 | 0 | ||
| 4 | 1 | ||
| 5 | rotation UF | ||
diff --git a/test/130_appendsolution/05_sort_parallel.out b/test/130_appendsolution/05_sort_parallel.out new file mode 100644 index 0000000..fc09830 --- /dev/null +++ b/test/130_appendsolution/05_sort_parallel.out | |||
| @@ -0,0 +1,4 @@ | |||
| 1 | R' L F B2 | ||
| 2 | Number of solutions: 1 | ||
| 3 | Shortest solution length: 4 | ||
| 4 | Used bytes: 10 | ||
diff --git a/test/130_appendsolution/06_unniss_trans_sort.in b/test/130_appendsolution/06_unniss_trans_sort.in new file mode 100644 index 0000000..9be03a6 --- /dev/null +++ b/test/130_appendsolution/06_unniss_trans_sort.in | |||
| @@ -0,0 +1,5 @@ | |||
| 1 | B | ||
| 2 | R2 F2 | ||
| 3 | 1 | ||
| 4 | 1 | ||
| 5 | rotation UR | ||
diff --git a/test/130_appendsolution/06_unniss_trans_sort.out b/test/130_appendsolution/06_unniss_trans_sort.out new file mode 100644 index 0000000..28d7827 --- /dev/null +++ b/test/130_appendsolution/06_unniss_trans_sort.out | |||
| @@ -0,0 +1,4 @@ | |||
| 1 | R2 L B2 | ||
| 2 | Number of solutions: 1 | ||
| 3 | Shortest solution length: 3 | ||
| 4 | Used bytes: 8 | ||
diff --git a/test/130_appendsolution/07_unniss_cancel_nosol.in b/test/130_appendsolution/07_unniss_cancel_nosol.in new file mode 100644 index 0000000..561c909 --- /dev/null +++ b/test/130_appendsolution/07_unniss_cancel_nosol.in | |||
| @@ -0,0 +1,5 @@ | |||
| 1 | B' F | ||
| 2 | R2 B2 | ||
| 3 | 1 | ||
| 4 | 1 | ||
| 5 | rotation UF | ||
diff --git a/test/130_appendsolution/07_unniss_cancel_nosol.out b/test/130_appendsolution/07_unniss_cancel_nosol.out new file mode 100644 index 0000000..ed5ea65 --- /dev/null +++ b/test/130_appendsolution/07_unniss_cancel_nosol.out | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | Number of solutions: 0 | ||
| 2 | Shortest solution length: 21 | ||
| 3 | Used bytes: 0 | ||
diff --git a/test/130_appendsolution/08_unniss_cancel_nosol_v2.in b/test/130_appendsolution/08_unniss_cancel_nosol_v2.in new file mode 100644 index 0000000..e707537 --- /dev/null +++ b/test/130_appendsolution/08_unniss_cancel_nosol_v2.in | |||
| @@ -0,0 +1,5 @@ | |||
| 1 | F' B | ||
| 2 | R2 F2 | ||
| 3 | 1 | ||
| 4 | 1 | ||
| 5 | rotation UF | ||
diff --git a/test/130_appendsolution/08_unniss_cancel_nosol_v2.out b/test/130_appendsolution/08_unniss_cancel_nosol_v2.out new file mode 100644 index 0000000..ed5ea65 --- /dev/null +++ b/test/130_appendsolution/08_unniss_cancel_nosol_v2.out | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | Number of solutions: 0 | ||
| 2 | Shortest solution length: 21 | ||
| 3 | Used bytes: 0 | ||
diff --git a/test/130_appendsolution/appendsolution_tests.c b/test/130_appendsolution/appendsolution_tests.c new file mode 100644 index 0000000..066c305 --- /dev/null +++ b/test/130_appendsolution/appendsolution_tests.c | |||
| @@ -0,0 +1,58 @@ | |||
| 1 | /* | ||
| 2 | Input format for appendsolution tests: | ||
| 3 | |||
| 4 | moves on normal | ||
| 5 | moves on inverse (without parentheses) | ||
| 6 | unniss flag (0=false, 1=true) | ||
| 7 | number of transformations | ||
| 8 | transformations, one per line | ||
| 9 | |||
| 10 | See below for the output format. | ||
| 11 | */ | ||
| 12 | |||
| 13 | #include "../test.h" | ||
| 14 | |||
| 15 | uint8_t readtrans(const char [NISSY_SIZE_TRANSFORMATION]); | ||
| 16 | int64_t readmoves(const char *, size_t n, uint8_t [n]); | ||
| 17 | void solution_moves_reset(solution_moves_t [static 1]); | ||
| 18 | bool solution_list_init(solution_list_t [static 1], size_t n, char [n]); | ||
| 19 | int64_t appendsolution(const solution_moves_t [static 1], | ||
| 20 | const solution_settings_t [static 1], solution_list_t [static 1]); | ||
| 21 | |||
| 22 | void run(void) { | ||
| 23 | int i, ntrans; | ||
| 24 | char str[STRLENMAX], buf[STRLENMAX]; | ||
| 25 | solution_moves_t moves; | ||
| 26 | solution_settings_t settings; | ||
| 27 | solution_list_t list; | ||
| 28 | |||
| 29 | solution_moves_reset(&moves); | ||
| 30 | solution_list_init(&list, STRLENMAX, buf); | ||
| 31 | settings = (solution_settings_t) { | ||
| 32 | .tmask = UINT64_C(0), | ||
| 33 | .unniss = false, | ||
| 34 | .maxmoves = 20, | ||
| 35 | .maxsolutions = 100, | ||
| 36 | .optimal = -1, | ||
| 37 | }; | ||
| 38 | |||
| 39 | fgets(str, STRLENMAX, stdin); | ||
| 40 | moves.nmoves = (uint8_t)readmoves(str, 20, moves.moves); | ||
| 41 | fgets(str, STRLENMAX, stdin); | ||
| 42 | moves.npremoves = (uint8_t)readmoves(str, 20, moves.premoves); | ||
| 43 | fgets(str, STRLENMAX, stdin); | ||
| 44 | settings.unniss = (bool)atoi(str); | ||
| 45 | fgets(str, STRLENMAX, stdin); | ||
| 46 | ntrans = atoi(str); | ||
| 47 | for (i = 0; i < ntrans; i++) { | ||
| 48 | fgets(str, STRLENMAX, stdin); | ||
| 49 | settings.tmask |= UINT64_C(1) << (uint64_t)readtrans(str); | ||
| 50 | } | ||
| 51 | |||
| 52 | appendsolution(&moves, &settings, &list); | ||
| 53 | |||
| 54 | printf("%s", list.buf); | ||
| 55 | printf("Number of solutions: %" PRIu64 "\n", list.nsols); | ||
| 56 | printf("Shortest solution length: %" PRIu8 "\n", list.shortest_sol); | ||
| 57 | printf("Used bytes: %zu\n", list.used); | ||
| 58 | } | ||
