aboutsummaryrefslogtreecommitdiff
path: root/test/031_premove/premove_tests.c
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2024-09-05 17:01:28 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2024-09-05 17:01:28 +0200
commit6e0f63d8f4608ce32c161691f490914650f4f5c1 (patch)
treecd87d7445ed4c9ce5aa647fa065e368c9c0e4db2 /test/031_premove/premove_tests.c
parente419ca484e62f2771766a87bfaedf75a5f99c2b1 (diff)
downloadnissy-core-6e0f63d8f4608ce32c161691f490914650f4f5c1.tar.gz
nissy-core-6e0f63d8f4608ce32c161691f490914650f4f5c1.zip
Added test for premove and a comment
Diffstat (limited to 'test/031_premove/premove_tests.c')
-rw-r--r--test/031_premove/premove_tests.c27
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
3uint8_t readmove(char);
4uint8_t readmodifier(char);
5cube_t premove(cube_t, uint8_t);
6
7void 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}

Generated with cgit - Back to sebastiano.tronto.net