aboutsummaryrefslogtreecommitdiff
path: root/test/082_allowednext_h48/allowednext_h48_tests.c
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2024-08-30 17:52:55 +0200
committerGitHub <noreply@github.com>2024-08-30 17:52:55 +0200
commitff4bde84872ec0b93f0f097f5a56bd5e7cbb0311 (patch)
tree2c5faddf404ebd92bd1b1039dd0c8a779de4fc58 /test/082_allowednext_h48/allowednext_h48_tests.c
parenteb20084ec94e9043e55a98717128a4ba1e6215cb (diff)
parent4abb800c4b4f3a509c07821ade8d34e3699bdf10 (diff)
downloadnissy-core-ff4bde84872ec0b93f0f097f5a56bd5e7cbb0311.tar.gz
nissy-core-ff4bde84872ec0b93f0f097f5a56bd5e7cbb0311.zip
Merge pull request #2 from enricotenuti/master
nissbranch ver1
Diffstat (limited to 'test/082_allowednext_h48/allowednext_h48_tests.c')
-rw-r--r--test/082_allowednext_h48/allowednext_h48_tests.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/082_allowednext_h48/allowednext_h48_tests.c b/test/082_allowednext_h48/allowednext_h48_tests.c
new file mode 100644
index 0000000..4cee695
--- /dev/null
+++ b/test/082_allowednext_h48/allowednext_h48_tests.c
@@ -0,0 +1,38 @@
1#include "../test.h"
2
3uint32_t allowednextmoveH48(uint8_t *, uint8_t, uint32_t);
4
5static char *moves[] = {
6 "U", "U2", "U'",
7 "D", "D2", "D'",
8 "R", "R2", "R'",
9 "L", "L2", "L'",
10 "F", "F2", "F'",
11 "B", "B2", "B'",
12};
13
14void run(void) {
15 char movestr[STRLENMAX];
16 uint8_t m[100];
17 int n, i, j, bound;
18
19 fgets(movestr, STRLENMAX, stdin);
20 bound = atoi(movestr);
21
22 fgets(movestr, STRLENMAX, stdin);
23 n = atoi(movestr);
24
25 for (i = 0; i < n; i++) {
26 fgets(movestr, STRLENMAX, stdin);
27 movestr[strcspn(movestr, "\n")] = 0;
28 for (j = 0; j < 18; j++)
29 if (!strcmp(movestr, moves[j]))
30 m[i] = j;
31 }
32
33 fprintf(stderr, "Last two: %s, %s\n",
34 n > 1 ? moves[m[n-2]] : "-",
35 n > 0 ? moves[m[n-1]] : "-");
36 uint32_t allowed = allowednextmoveH48(m, n, bound);
37 printf("0x%05X\n", allowed);
38}

Generated with cgit - Back to sebastiano.tronto.net