From f987f5af492f2ac9d5aeebd351bcb49175556af2 Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Mon, 29 May 2023 01:06:09 +0200 Subject: Initial commit --- test/move/move_tests.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 test/move/move_tests.c (limited to 'test/move/move_tests.c') 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 @@ +#include +#include +#include + +#include "../../src/cube.h" + +#define STRLENMAX 10000 +#define MOVESMAX 1000 + +int main() { + char str[STRLENMAX]; + int i, n; + move_t moves[MOVESMAX]; + cube_t cube; + + fgets(str, STRLENMAX, stdin); + n = readmoves(str, moves); + + if (n == -1) { + printf("Error reading moves\n"); + return 1; + } + + fgets(str, STRLENMAX, stdin); + cube = readcube(str); + + for (i = 0; i < n; i++) + cube = move(cube, moves[i]); + + if (cube.e == errorcube.e && cube.c == errorcube.c) { + printf("Error moving cube\n"); + } else if (!isconsistent(cube)) { + printf("Moved cube is inconsistent\n"); + } else { + writecube(cube, str); + printf("%s\n", str); + } + + return 0; +} -- cgit v1.3