diff options
Diffstat (limited to 'test/080_allowednext/allowednext_tests.c')
| -rw-r--r-- | test/080_allowednext/allowednext_tests.c | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/test/080_allowednext/allowednext_tests.c b/test/080_allowednext/allowednext_tests.c index 7ae7f66..e531911 100644 --- a/test/080_allowednext/allowednext_tests.c +++ b/test/080_allowednext/allowednext_tests.c | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | #include "../test.h" | 1 | #include "../test.h" |
| 2 | 2 | ||
| 3 | bool allowednextmove(uint8_t *, int, uint8_t); | 3 | bool allowednextmove(uint8_t *, uint8_t); |
| 4 | 4 | ||
| 5 | static char *moves[] = { | 5 | static char *moves[] = { |
| 6 | "U", "U2", "U'", | 6 | "U", "U2", "U'", |
| @@ -13,7 +13,7 @@ static char *moves[] = { | |||
| 13 | 13 | ||
| 14 | int main(void) { | 14 | int main(void) { |
| 15 | char movestr[STRLENMAX]; | 15 | char movestr[STRLENMAX]; |
| 16 | uint8_t m[100], next; | 16 | uint8_t m[100]; |
| 17 | int n, i, j; | 17 | int n, i, j; |
| 18 | 18 | ||
| 19 | fgets(movestr, STRLENMAX, stdin); | 19 | fgets(movestr, STRLENMAX, stdin); |
| @@ -26,17 +26,12 @@ int main(void) { | |||
| 26 | if (!strcmp(movestr, moves[j])) | 26 | if (!strcmp(movestr, moves[j])) |
| 27 | m[i] = j; | 27 | m[i] = j; |
| 28 | } | 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 | 29 | ||
| 35 | fprintf(stderr, "Last two: %s, %s\nNext: %s\n", | 30 | fprintf(stderr, "Last two: %s, %s\nNext: %s\n", |
| 31 | n > 2 ? moves[m[n-3]] : "-", | ||
| 36 | n > 1 ? moves[m[n-2]] : "-", | 32 | n > 1 ? moves[m[n-2]] : "-", |
| 37 | n > 0 ? moves[m[n-1]] : "-", | 33 | n > 0 ? moves[m[n-1]] : "-"); |
| 38 | moves[next]); | 34 | printf("%s\n", allowednextmove(m, n) ? "true" : "false"); |
| 39 | printf("%s\n", allowednextmove(m, n, next) ? "true" : "false"); | ||
| 40 | 35 | ||
| 41 | return 0; | 36 | return 0; |
| 42 | } | 37 | } |
