aboutsummaryrefslogtreecommitdiff
path: root/test/031_premove
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
parente419ca484e62f2771766a87bfaedf75a5f99c2b1 (diff)
downloadnissy-core-6e0f63d8f4608ce32c161691f490914650f4f5c1.tar.gz
nissy-core-6e0f63d8f4608ce32c161691f490914650f4f5c1.zip
Added test for premove and a comment
Diffstat (limited to 'test/031_premove')
-rw-r--r--test/031_premove/001_U_solved.in2
-rw-r--r--test/031_premove/001_U_solved.out1
-rw-r--r--test/031_premove/002_U_scrambled.in4
-rw-r--r--test/031_premove/002_U_scrambled.out1
-rw-r--r--test/031_premove/003_F3_scrambled.in4
-rw-r--r--test/031_premove/003_F3_scrambled.out1
-rw-r--r--test/031_premove/premove_tests.c27
7 files changed, 40 insertions, 0 deletions
diff --git a/test/031_premove/001_U_solved.in b/test/031_premove/001_U_solved.in
new file mode 100644
index 0000000..62495cb
--- /dev/null
+++ b/test/031_premove/001_U_solved.in
@@ -0,0 +1,2 @@
1U
2UF0 UB0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0
diff --git a/test/031_premove/001_U_solved.out b/test/031_premove/001_U_solved.out
new file mode 100644
index 0000000..7721ab5
--- /dev/null
+++ b/test/031_premove/001_U_solved.out
@@ -0,0 +1 @@
UL0 UR0 DB0 DF0 UF0 UB0 DL0 DR0 FR0 FL0 BL0 BR0 UFL0 UBR0 DFL0 DBR0 UBL0 UFR0 DFR0 DBL0
diff --git a/test/031_premove/002_U_scrambled.in b/test/031_premove/002_U_scrambled.in
new file mode 100644
index 0000000..423c408
--- /dev/null
+++ b/test/031_premove/002_U_scrambled.in
@@ -0,0 +1,4 @@
1U
2UL0 BL0 BR1 DL0 FR0 DF0 DB1 DR1 UB0 FL0 UF0 UR1 DFL0 UFR1 DBR1 UBR2 DBL2 DFR0 UFL1 UBL2
3
4// Scramble: U R D' L D' F L2 D L F B D2 B' L2 F U2 L2 D2 R2 L2 B'
diff --git a/test/031_premove/002_U_scrambled.out b/test/031_premove/002_U_scrambled.out
new file mode 100644
index 0000000..b25b400
--- /dev/null
+++ b/test/031_premove/002_U_scrambled.out
@@ -0,0 +1 @@
UB0 BL0 BR1 DL0 FR0 DF0 DB1 DR1 UR0 FL0 UL0 UF1 DFL0 UFL1 DBR1 UFR2 DBL2 DFR0 UBL1 UBR2
diff --git a/test/031_premove/003_F3_scrambled.in b/test/031_premove/003_F3_scrambled.in
new file mode 100644
index 0000000..d222a18
--- /dev/null
+++ b/test/031_premove/003_F3_scrambled.in
@@ -0,0 +1,4 @@
1F'
2UL0 BL0 BR1 DL0 FR0 DF0 DB1 DR1 UB0 FL0 UF0 UR1 DFL0 UFR1 DBR1 UBR2 DBL2 DFR0 UFL1 UBL2
3
4// Scramble: U R D' L D' F L2 D L F B D2 B' L2 F U2 L2 D2 R2 L2 B'
diff --git a/test/031_premove/003_F3_scrambled.out b/test/031_premove/003_F3_scrambled.out
new file mode 100644
index 0000000..9d8d663
--- /dev/null
+++ b/test/031_premove/003_F3_scrambled.out
@@ -0,0 +1 @@
UL0 BL0 BR1 DL0 UF1 FR1 DB1 DR1 UB0 DF1 FL1 UR1 DFR1 UFL2 DBR1 UBR2 DBL2 UFR2 DFL0 UBL2
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