diff options
Diffstat (limited to 'test/031_premove/premove_tests.c')
| -rw-r--r-- | test/031_premove/premove_tests.c | 27 |
1 files changed, 27 insertions, 0 deletions
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 @@ | |||
| 1 | #include "../test.h" | ||
| 2 | |||
| 3 | uint8_t readmove(char); | ||
| 4 | uint8_t readmodifier(char); | ||
| 5 | cube_t premove(cube_t, uint8_t); | ||
| 6 | |||
| 7 | void run(void) { | ||
| 8 | char movestr[STRLENMAX], cubestr[STRLENMAX]; | ||
| 9 | uint8_t move; | ||
| 10 | cube_t cube; | ||
| 11 | |||
| 12 | fgets(movestr, STRLENMAX, stdin); | ||
| 13 | move = readmove(movestr[0]) + readmodifier(movestr[1]); | ||
| 14 | fgets(cubestr, STRLENMAX, stdin); | ||
| 15 | cube = readcube("H48", cubestr); | ||
| 16 | |||
| 17 | cube = premove(cube, move); | ||
| 18 | |||
| 19 | if (iserror(cube)) { | ||
| 20 | printf("Error moving cube\n"); | ||
| 21 | } else if (!issolvable(cube)) { | ||
| 22 | printf("Moved cube is not solvable\n"); | ||
| 23 | } else { | ||
| 24 | writecube("H48", cube, cubestr); | ||
| 25 | printf("%s\n", cubestr); | ||
| 26 | } | ||
| 27 | } | ||
