aboutsummaryrefslogtreecommitdiff
path: root/test/140_appendsolution/appendsolution_tests.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/140_appendsolution/appendsolution_tests.c')
-rw-r--r--test/140_appendsolution/appendsolution_tests.c68
1 files changed, 68 insertions, 0 deletions
diff --git a/test/140_appendsolution/appendsolution_tests.c b/test/140_appendsolution/appendsolution_tests.c
new file mode 100644
index 0000000..e1b7e98
--- /dev/null
+++ b/test/140_appendsolution/appendsolution_tests.c
@@ -0,0 +1,68 @@
1/*
2Input format for appendsolution tests:
3
4moves on normal (with NISS notation)
5unniss flag (0=false, 1=true)
6number of transformations
7transformations, one per line
8the orientation of the cube, as a number from 0 to 23
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, size_t m,
17 uint64_t *, uint64_t *, uint8_t [n], uint8_t [m]);
18void solution_moves_reset(solution_moves_t [static 1]);
19bool solution_list_init(solution_list_t [static 1], size_t n, char [n]);
20int64_t appendsolution(const solution_moves_t [static 1],
21 const solution_settings_t [static 1], solution_list_t [static 1], bool,
22 const char *);
23
24void run(void) {
25 int i, ntrans;
26 int64_t tot;
27 uint64_t nm, np;
28 char str[STRLENMAX], buf[STRLENMAX];
29 solution_moves_t moves;
30 solution_settings_t settings;
31 solution_list_t list;
32
33 solution_moves_reset(&moves);
34 solution_list_init(&list, STRLENMAX, buf);
35 settings = (solution_settings_t) {
36 .tmask = UINT64_C(0),
37 .unniss = false,
38 .maxmoves = 20,
39 .maxsolutions = 100,
40 .optimal = -1,
41 };
42
43 fgets(str, STRLENMAX, stdin);
44 tot = readmoves(str, 20, 20, &nm, &np, moves.moves, moves.premoves);
45 if (tot < 0) {
46 printf("Test error reading moves\n");
47 return;
48 }
49 moves.nmoves = nm;
50 moves.npremoves = np;
51 fgets(str, STRLENMAX, stdin);
52 settings.unniss = (bool)atoi(str);
53 fgets(str, STRLENMAX, stdin);
54 ntrans = atoi(str);
55 for (i = 0; i < ntrans; i++) {
56 fgets(str, STRLENMAX, stdin);
57 settings.tmask |= UINT64_C(1) << (uint64_t)readtrans(str);
58 }
59 fgets(str, STRLENMAX, stdin);
60 settings.orientation = atoi(str);
61
62 appendsolution(&moves, &settings, &list, false, "Test");
63
64 printf("%s", list.buf);
65 printf("Number of solutions: %" PRIu64 "\n", list.nsols);
66 printf("Shortest solution length: %" PRIu8 "\n", list.shortest_sol);
67 printf("Used bytes: %zu\n", list.used);
68}

Generated with cgit - Back to sebastiano.tronto.net