aboutsummaryrefslogtreecommitdiff
path: root/test/130_appendsolution/appendsolution_tests.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/130_appendsolution/appendsolution_tests.c')
-rw-r--r--test/130_appendsolution/appendsolution_tests.c58
1 files changed, 58 insertions, 0 deletions
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/*
2Input format for appendsolution tests:
3
4moves on normal
5moves on inverse (without parentheses)
6unniss flag (0=false, 1=true)
7number of transformations
8transformations, one per line
9
10See below for the output format.
11*/
12
13#include "../test.h"
14
15uint8_t readtrans(const char [NISSY_SIZE_TRANSFORMATION]);
16int64_t readmoves(const char *, size_t n, uint8_t [n]);
17void solution_moves_reset(solution_moves_t [static 1]);
18bool solution_list_init(solution_list_t [static 1], size_t n, char [n]);
19int64_t appendsolution(const solution_moves_t [static 1],
20 const solution_settings_t [static 1], solution_list_t [static 1]);
21
22void 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}

Generated with cgit - Back to sebastiano.tronto.net