diff options
Diffstat (limited to 'test/020_move/move_tests.c')
| -rw-r--r-- | test/020_move/move_tests.c | 24 |
1 files changed, 7 insertions, 17 deletions
diff --git a/test/020_move/move_tests.c b/test/020_move/move_tests.c index 4a010f1..9e414cc 100644 --- a/test/020_move/move_tests.c +++ b/test/020_move/move_tests.c | |||
| @@ -12,32 +12,22 @@ | |||
| 12 | #define MOVESMAX 1000 | 12 | #define MOVESMAX 1000 |
| 13 | 13 | ||
| 14 | int main() { | 14 | int main() { |
| 15 | char str[STRLENMAX]; | 15 | char movestr[STRLENMAX], cubestr[STRLENMAX]; |
| 16 | int i, n; | ||
| 17 | move_t moves[MOVESMAX]; | ||
| 18 | cube_t cube; | 16 | cube_t cube; |
| 19 | 17 | ||
| 20 | fgets(str, STRLENMAX, stdin); | 18 | fgets(movestr, STRLENMAX, stdin); |
| 21 | n = readmoves(str, moves); | 19 | fgets(cubestr, STRLENMAX, stdin); |
| 20 | cube = readcube("H48", cubestr); | ||
| 22 | 21 | ||
| 23 | if (n == -1) { | 22 | cube = applymoves(cube, movestr); |
| 24 | printf("Error reading moves\n"); | ||
| 25 | return 1; | ||
| 26 | } | ||
| 27 | |||
| 28 | fgets(str, STRLENMAX, stdin); | ||
| 29 | cube = readcube(H48, str); | ||
| 30 | |||
| 31 | for (i = 0; i < n; i++) | ||
| 32 | cube = move(cube, moves[i]); | ||
| 33 | 23 | ||
| 34 | if (iserror(cube)) { | 24 | if (iserror(cube)) { |
| 35 | printf("Error moving cube\n"); | 25 | printf("Error moving cube\n"); |
| 36 | } else if (!issolvable(cube)) { | 26 | } else if (!issolvable(cube)) { |
| 37 | printf("Moved cube is not solvable\n"); | 27 | printf("Moved cube is not solvable\n"); |
| 38 | } else { | 28 | } else { |
| 39 | writecube(H48, cube, str); | 29 | writecube("H48", cube, cubestr); |
| 40 | printf("%s\n", str); | 30 | printf("%s\n", cubestr); |
| 41 | } | 31 | } |
| 42 | 32 | ||
| 43 | return 0; | 33 | return 0; |
