aboutsummaryrefslogtreecommitdiff
path: root/test/move/move_tests.c
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2023-05-29 01:06:09 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2023-05-29 01:06:09 +0200
commitf987f5af492f2ac9d5aeebd351bcb49175556af2 (patch)
treee4a6a242996f83c2110dcf46dc2b7a3f271f2b44 /test/move/move_tests.c
downloadnissy-core-f987f5af492f2ac9d5aeebd351bcb49175556af2.tar.gz
nissy-core-f987f5af492f2ac9d5aeebd351bcb49175556af2.zip
Initial commit
Diffstat (limited to 'test/move/move_tests.c')
-rw-r--r--test/move/move_tests.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/test/move/move_tests.c b/test/move/move_tests.c
new file mode 100644
index 0000000..23fc45e
--- /dev/null
+++ b/test/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
10int 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}

Generated with cgit - Back to sebastiano.tronto.net