diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2023-06-19 15:06:11 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2023-06-19 15:06:11 +0200 |
| commit | c5dfc897160bc9bbc6a91c77b5d58d421fd1cfe1 (patch) | |
| tree | ad73b01c37697c8b7392c85ffc7a02fb6a08e5f6 /test/02_move/move_tests.c | |
| parent | 7e9afaa14ca293a7e9d5a76af36d9a0aecbb031d (diff) | |
| download | nissy-core-c5dfc897160bc9bbc6a91c77b5d58d421fd1cfe1.tar.gz nissy-core-c5dfc897160bc9bbc6a91c77b5d58d421fd1cfe1.zip | |
Renamed test folders to keep order
Diffstat (limited to 'test/02_move/move_tests.c')
| -rw-r--r-- | test/02_move/move_tests.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/test/02_move/move_tests.c b/test/02_move/move_tests.c new file mode 100644 index 0000000..23fc45e --- /dev/null +++ b/test/02_move/move_tests.c | |||
| @@ -0,0 +1,40 @@ | |||
| 1 | #include <stdbool.h> | ||
| 2 | #include <stdint.h> | ||
| 3 | #include <stdio.h> | ||
| 4 | |||
| 5 | #include "../../src/cube.h" | ||
| 6 | |||
| 7 | #define STRLENMAX 10000 | ||
| 8 | #define MOVESMAX 1000 | ||
| 9 | |||
| 10 | int main() { | ||
| 11 | char str[STRLENMAX]; | ||
| 12 | int i, n; | ||
| 13 | move_t moves[MOVESMAX]; | ||
| 14 | cube_t cube; | ||
| 15 | |||
| 16 | fgets(str, STRLENMAX, stdin); | ||
| 17 | n = readmoves(str, moves); | ||
| 18 | |||
| 19 | if (n == -1) { | ||
| 20 | printf("Error reading moves\n"); | ||
| 21 | return 1; | ||
| 22 | } | ||
| 23 | |||
| 24 | fgets(str, STRLENMAX, stdin); | ||
| 25 | cube = readcube(str); | ||
| 26 | |||
| 27 | for (i = 0; i < n; i++) | ||
| 28 | cube = move(cube, moves[i]); | ||
| 29 | |||
| 30 | if (cube.e == errorcube.e && cube.c == errorcube.c) { | ||
| 31 | printf("Error moving cube\n"); | ||
| 32 | } else if (!isconsistent(cube)) { | ||
| 33 | printf("Moved cube is inconsistent\n"); | ||
| 34 | } else { | ||
| 35 | writecube(cube, str); | ||
| 36 | printf("%s\n", str); | ||
| 37 | } | ||
| 38 | |||
| 39 | return 0; | ||
| 40 | } | ||
