From 6e0f63d8f4608ce32c161691f490914650f4f5c1 Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Thu, 5 Sep 2024 17:01:28 +0200 Subject: Added test for premove and a comment --- test/031_premove/premove_tests.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 test/031_premove/premove_tests.c (limited to 'test/031_premove/premove_tests.c') diff --git a/test/031_premove/premove_tests.c b/test/031_premove/premove_tests.c new file mode 100644 index 0000000..fa3707e --- /dev/null +++ b/test/031_premove/premove_tests.c @@ -0,0 +1,27 @@ +#include "../test.h" + +uint8_t readmove(char); +uint8_t readmodifier(char); +cube_t premove(cube_t, uint8_t); + +void run(void) { + char movestr[STRLENMAX], cubestr[STRLENMAX]; + uint8_t move; + cube_t cube; + + fgets(movestr, STRLENMAX, stdin); + move = readmove(movestr[0]) + readmodifier(movestr[1]); + fgets(cubestr, STRLENMAX, stdin); + cube = readcube("H48", cubestr); + + cube = premove(cube, move); + + if (iserror(cube)) { + printf("Error moving cube\n"); + } else if (!issolvable(cube)) { + printf("Moved cube is not solvable\n"); + } else { + writecube("H48", cube, cubestr); + printf("%s\n", cubestr); + } +} -- cgit v1.3