diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2023-11-14 22:42:08 +0100 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2023-11-14 22:42:08 +0100 |
| commit | d5e7698d0c7ecb61fe49263982f750c053147089 (patch) | |
| tree | 5a6c16f28bbec007665f4b85e5c96344dd4ed617 /test/080_allowednext/allowednext_tests.c | |
| parent | e0f38c7e42d9e48ac654f9dcedf8722ff1136106 (diff) | |
| download | nissy-core-d5e7698d0c7ecb61fe49263982f750c053147089.tar.gz nissy-core-d5e7698d0c7ecb61fe49263982f750c053147089.zip | |
Added tests allowednext
Diffstat (limited to 'test/080_allowednext/allowednext_tests.c')
| -rw-r--r-- | test/080_allowednext/allowednext_tests.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/test/080_allowednext/allowednext_tests.c b/test/080_allowednext/allowednext_tests.c new file mode 100644 index 0000000..98a437f --- /dev/null +++ b/test/080_allowednext/allowednext_tests.c | |||
| @@ -0,0 +1,42 @@ | |||
| 1 | #include "../test.h" | ||
| 2 | |||
| 3 | bool allowednextmove(uint8_t *, int, uint8_t); | ||
| 4 | |||
| 5 | static 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 | |||
| 14 | int main() { | ||
| 15 | char movestr[STRLENMAX]; | ||
| 16 | uint8_t m[100], next; | ||
| 17 | int n, i, j; | ||
| 18 | |||
| 19 | fgets(movestr, STRLENMAX, stdin); | ||
| 20 | n = atoi(movestr); | ||
| 21 | |||
| 22 | for (i = 0; i < n; i++) { | ||
| 23 | fgets(movestr, STRLENMAX, stdin); | ||
| 24 | movestr[strcspn(movestr, "\n")] = 0; | ||
| 25 | for (j = 0; j < 18; j++) | ||
| 26 | if (!strcmp(movestr, moves[j])) | ||
| 27 | m[i] = j; | ||
| 28 | } | ||
| 29 | fgets(movestr, STRLENMAX, stdin); | ||
| 30 | movestr[strcspn(movestr, "\n")] = 0; | ||
| 31 | for (j = 0; j < 18; j++) | ||
| 32 | if (!strcmp(movestr, moves[j])) | ||
| 33 | next = j; | ||
| 34 | |||
| 35 | fprintf(stderr, "Last two: %s, %s\nNext: %s\n", | ||
| 36 | n > 1 ? moves[m[n-2]] : "-", | ||
| 37 | n > 0 ? moves[m[n-1]] : "-", | ||
| 38 | moves[next]); | ||
| 39 | printf("%s\n", allowednextmove(m, n, next) ? "true" : "false"); | ||
| 40 | |||
| 41 | return 0; | ||
| 42 | } | ||
