diff options
| -rw-r--r-- | src/core/moves.h | 1 | ||||
| -rw-r--r-- | test/031_premove/001_U_solved.in | 2 | ||||
| -rw-r--r-- | test/031_premove/001_U_solved.out | 1 | ||||
| -rw-r--r-- | test/031_premove/002_U_scrambled.in | 4 | ||||
| -rw-r--r-- | test/031_premove/002_U_scrambled.out | 1 | ||||
| -rw-r--r-- | test/031_premove/003_F3_scrambled.in | 4 | ||||
| -rw-r--r-- | test/031_premove/003_F3_scrambled.out | 1 | ||||
| -rw-r--r-- | test/031_premove/premove_tests.c | 27 |
8 files changed, 41 insertions, 0 deletions
diff --git a/src/core/moves.h b/src/core/moves.h index b542235..5d08a66 100644 --- a/src/core/moves.h +++ b/src/core/moves.h | |||
| @@ -111,6 +111,7 @@ move(cube_t c, uint8_t m) | |||
| 111 | } | 111 | } |
| 112 | } | 112 | } |
| 113 | 113 | ||
| 114 | /* Applies the INVERSE of m BEFORE the scramble corresponding to c */ | ||
| 114 | STATIC cube_t | 115 | STATIC cube_t |
| 115 | premove(cube_t c, uint8_t m) | 116 | premove(cube_t c, uint8_t m) |
| 116 | { | 117 | { |
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 @@ | |||
| 1 | U | ||
| 2 | UF0 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 @@ | |||
| 1 | U | ||
| 2 | UL0 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 @@ | |||
| 1 | F' | ||
| 2 | UL0 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 | |||
| 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 | } | ||
