diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/000_basic/basic_tests.c | 11 | ||||
| -rw-r--r-- | test/001_cube_conversion/cube_conversion_tests.c | 4 | ||||
| -rw-r--r-- | test/020_io_H48_read_write/io_H48_tests.c | 4 | ||||
| -rw-r--r-- | test/023_io_LST_write/io_LST_tests.c | 4 | ||||
| -rw-r--r-- | test/024_io_LST_read/io_LST_tests.c | 4 | ||||
| -rw-r--r-- | test/030_move/move_tests.c | 4 | ||||
| -rw-r--r-- | test/040_inverse_cube/inverse_tests.c | 8 | ||||
| -rw-r--r-- | test/050_compose/compose_tests.c | 4 | ||||
| -rw-r--r-- | test/060_transform/transform_tests.c | 4 | ||||
| -rw-r--r-- | test/061_inverse_trans/inverse_trans_tests.c | 8 | ||||
| -rw-r--r-- | test/last.err | 0 | ||||
| -rw-r--r-- | test/last.out | 1 | ||||
| -rw-r--r-- | test/test.h | 21 |
13 files changed, 28 insertions, 49 deletions
diff --git a/test/000_basic/basic_tests.c b/test/000_basic/basic_tests.c index c4434c5..53ccc9f 100644 --- a/test/000_basic/basic_tests.c +++ b/test/000_basic/basic_tests.c | |||
| @@ -1,27 +1,24 @@ | |||
| 1 | #include "../test.h" | 1 | #include "../test.h" |
| 2 | 2 | ||
| 3 | bool issolved(cube_t); | ||
| 4 | bool equal(cube_t, cube_t); | ||
| 5 | |||
| 6 | void | 3 | void |
| 7 | check(cube_t cube, char *name) | 4 | check(cube_t cube, char *name) |
| 8 | { | 5 | { |
| 9 | printf("%s is%s solvable\n", name, issolvable(cube) ? "" : " NOT"); | 6 | printf("%s is%s solvable\n", name, cube_solvable(cube) ? "" : " NOT"); |
| 10 | printf("%s is%s solved\n", name, issolved(cube) ? "" : " NOT"); | 7 | printf("%s is%s solved\n", name, cube_solved(cube) ? "" : " NOT"); |
| 11 | } | 8 | } |
| 12 | 9 | ||
| 13 | void | 10 | void |
| 14 | check2(cube_t cube1, char *name1, cube_t cube2, char *name2) | 11 | check2(cube_t cube1, char *name1, cube_t cube2, char *name2) |
| 15 | { | 12 | { |
| 16 | printf("%s and %s are%s equal\n", name1, name2, | 13 | printf("%s and %s are%s equal\n", name1, name2, |
| 17 | equal(cube1, cube2) ? "" : " NOT"); | 14 | cube_equal(cube1, cube2) ? "" : " NOT"); |
| 18 | } | 15 | } |
| 19 | 16 | ||
| 20 | int main(void) { | 17 | int main(void) { |
| 21 | cube_t zero, solved; | 18 | cube_t zero, solved; |
| 22 | 19 | ||
| 23 | memset(&zero, 0, sizeof(cube_t)); | 20 | memset(&zero, 0, sizeof(cube_t)); |
| 24 | solved = solvedcube(); | 21 | solved = cube_new(); |
| 25 | check(solved, "Solved"); | 22 | check(solved, "Solved"); |
| 26 | check(zero, "Zero"); | 23 | check(zero, "Zero"); |
| 27 | 24 | ||
diff --git a/test/001_cube_conversion/cube_conversion_tests.c b/test/001_cube_conversion/cube_conversion_tests.c index 589eb82..fe8a68f 100644 --- a/test/001_cube_conversion/cube_conversion_tests.c +++ b/test/001_cube_conversion/cube_conversion_tests.c | |||
| @@ -14,9 +14,9 @@ int main(void) { | |||
| 14 | fast = cubetofast(cube); | 14 | fast = cubetofast(cube); |
| 15 | cube2 = fasttocube(fast); | 15 | cube2 = fasttocube(fast); |
| 16 | 16 | ||
| 17 | if (iserror(cube)) { | 17 | if (cube_error(cube)) { |
| 18 | printf("Error reading cube\n"); | 18 | printf("Error reading cube\n"); |
| 19 | } else if (iserror(cube2)) { | 19 | } else if (cube_error(cube2)) { |
| 20 | printf("Error converting cube\n"); | 20 | printf("Error converting cube\n"); |
| 21 | } else { | 21 | } else { |
| 22 | writecube("H48", cube2, cubestr); | 22 | writecube("H48", cube2, cubestr); |
diff --git a/test/020_io_H48_read_write/io_H48_tests.c b/test/020_io_H48_read_write/io_H48_tests.c index 705356c..222e4d4 100644 --- a/test/020_io_H48_read_write/io_H48_tests.c +++ b/test/020_io_H48_read_write/io_H48_tests.c | |||
| @@ -11,9 +11,9 @@ int main(void) { | |||
| 11 | 11 | ||
| 12 | cube = readcube("H48", str); | 12 | cube = readcube("H48", str); |
| 13 | 13 | ||
| 14 | if (iserror(cube)) { | 14 | if (cube_error(cube)) { |
| 15 | printf("Error reading cube\n"); | 15 | printf("Error reading cube\n"); |
| 16 | } else if (!issolvable(cube)) { | 16 | } else if (!cube_solvable(cube)) { |
| 17 | printf("Cube is not solvable\n"); | 17 | printf("Cube is not solvable\n"); |
| 18 | } else { | 18 | } else { |
| 19 | writecube("H48", cube, str); | 19 | writecube("H48", cube, str); |
diff --git a/test/023_io_LST_write/io_LST_tests.c b/test/023_io_LST_write/io_LST_tests.c index df35632..8a3ce22 100644 --- a/test/023_io_LST_write/io_LST_tests.c +++ b/test/023_io_LST_write/io_LST_tests.c | |||
| @@ -11,9 +11,9 @@ int main(void) { | |||
| 11 | 11 | ||
| 12 | cube = readcube("H48", str); | 12 | cube = readcube("H48", str); |
| 13 | 13 | ||
| 14 | if (iserror(cube)) { | 14 | if (cube_error(cube)) { |
| 15 | printf("Error reading cube\n"); | 15 | printf("Error reading cube\n"); |
| 16 | } else if (!issolvable(cube)) { | 16 | } else if (!cube_solvable(cube)) { |
| 17 | printf("Cube is not solvable\n"); | 17 | printf("Cube is not solvable\n"); |
| 18 | } else { | 18 | } else { |
| 19 | writecube("LST", cube, str); | 19 | writecube("LST", cube, str); |
diff --git a/test/024_io_LST_read/io_LST_tests.c b/test/024_io_LST_read/io_LST_tests.c index 506a23d..81d4c54 100644 --- a/test/024_io_LST_read/io_LST_tests.c +++ b/test/024_io_LST_read/io_LST_tests.c | |||
| @@ -11,9 +11,9 @@ int main(void) { | |||
| 11 | 11 | ||
| 12 | cube = readcube("LST", str); | 12 | cube = readcube("LST", str); |
| 13 | 13 | ||
| 14 | if (iserror(cube)) { | 14 | if (cube_error(cube)) { |
| 15 | printf("Error reading cube\n"); | 15 | printf("Error reading cube\n"); |
| 16 | } else if (!issolvable(cube)) { | 16 | } else if (!cube_solvable(cube)) { |
| 17 | printf("Cube is not solvable\n"); | 17 | printf("Cube is not solvable\n"); |
| 18 | } else { | 18 | } else { |
| 19 | writecube("H48", cube, str); | 19 | writecube("H48", cube, str); |
diff --git a/test/030_move/move_tests.c b/test/030_move/move_tests.c index 73e9dbe..39458ba 100644 --- a/test/030_move/move_tests.c +++ b/test/030_move/move_tests.c | |||
| @@ -12,9 +12,9 @@ int main(void) { | |||
| 12 | 12 | ||
| 13 | cube = applymoves(cube, movestr); | 13 | cube = applymoves(cube, movestr); |
| 14 | 14 | ||
| 15 | if (iserror(cube)) { | 15 | if (cube_error(cube)) { |
| 16 | printf("Error moving cube\n"); | 16 | printf("Error moving cube\n"); |
| 17 | } else if (!issolvable(cube)) { | 17 | } else if (!cube_solvable(cube)) { |
| 18 | printf("Moved cube is not solvable\n"); | 18 | printf("Moved cube is not solvable\n"); |
| 19 | } else { | 19 | } else { |
| 20 | writecube("H48", cube, cubestr); | 20 | writecube("H48", cube, cubestr); |
diff --git a/test/040_inverse_cube/inverse_tests.c b/test/040_inverse_cube/inverse_tests.c index 2ff3bc7..ca7e481 100644 --- a/test/040_inverse_cube/inverse_tests.c +++ b/test/040_inverse_cube/inverse_tests.c | |||
| @@ -1,18 +1,16 @@ | |||
| 1 | #include "../test.h" | 1 | #include "../test.h" |
| 2 | 2 | ||
| 3 | cube_t inverse(cube_t); | ||
| 4 | |||
| 5 | int main(void) { | 3 | int main(void) { |
| 6 | char str[STRLENMAX]; | 4 | char str[STRLENMAX]; |
| 7 | cube_t cube, inv; | 5 | cube_t cube, inv; |
| 8 | 6 | ||
| 9 | fgets(str, STRLENMAX, stdin); | 7 | fgets(str, STRLENMAX, stdin); |
| 10 | cube = readcube("H48", str); | 8 | cube = readcube("H48", str); |
| 11 | inv = inverse(cube); | 9 | inv = cube_inverse(cube); |
| 12 | 10 | ||
| 13 | if (iserror(inv)) { | 11 | if (cube_error(inv)) { |
| 14 | printf("Error inverting cube\n"); | 12 | printf("Error inverting cube\n"); |
| 15 | } else if (!issolvable(inv)) { | 13 | } else if (!cube_solvable(inv)) { |
| 16 | printf("Inverted cube is not solvable\n"); | 14 | printf("Inverted cube is not solvable\n"); |
| 17 | } else { | 15 | } else { |
| 18 | writecube("H48", inv, str); | 16 | writecube("H48", inv, str); |
diff --git a/test/050_compose/compose_tests.c b/test/050_compose/compose_tests.c index 0ea4eff..c0bbbef 100644 --- a/test/050_compose/compose_tests.c +++ b/test/050_compose/compose_tests.c | |||
| @@ -13,9 +13,9 @@ int main(void) { | |||
| 13 | 13 | ||
| 14 | c3 = compose(c1, c2); | 14 | c3 = compose(c1, c2); |
| 15 | 15 | ||
| 16 | if (iserror(c3)) { | 16 | if (cube_error(c3)) { |
| 17 | printf("Error composing cubes\n"); | 17 | printf("Error composing cubes\n"); |
| 18 | } else if (!issolvable(c3)) { | 18 | } else if (!cube_solvable(c3)) { |
| 19 | printf("Composed cube is not solvable\n"); | 19 | printf("Composed cube is not solvable\n"); |
| 20 | } else { | 20 | } else { |
| 21 | writecube("H48", c3, str); | 21 | writecube("H48", c3, str); |
diff --git a/test/060_transform/transform_tests.c b/test/060_transform/transform_tests.c index f95ad67..8680a0b 100644 --- a/test/060_transform/transform_tests.c +++ b/test/060_transform/transform_tests.c | |||
| @@ -12,9 +12,9 @@ int main(void) { | |||
| 12 | 12 | ||
| 13 | cube = applytrans(cube, transtr); | 13 | cube = applytrans(cube, transtr); |
| 14 | 14 | ||
| 15 | if (iserror(cube)) { | 15 | if (cube_error(cube)) { |
| 16 | printf("Error transforming cube\n"); | 16 | printf("Error transforming cube\n"); |
| 17 | } else if (!issolvable(cube)) { | 17 | } else if (!cube_solvable(cube)) { |
| 18 | printf("Transformed cube is not solvable\n"); | 18 | printf("Transformed cube is not solvable\n"); |
| 19 | } else { | 19 | } else { |
| 20 | writecube("H48", cube, cubestr); | 20 | writecube("H48", cube, cubestr); |
diff --git a/test/061_inverse_trans/inverse_trans_tests.c b/test/061_inverse_trans/inverse_trans_tests.c index 77bd40b..7de8f66 100644 --- a/test/061_inverse_trans/inverse_trans_tests.c +++ b/test/061_inverse_trans/inverse_trans_tests.c | |||
| @@ -11,7 +11,7 @@ int main(void) { | |||
| 11 | cube_t cube; | 11 | cube_t cube; |
| 12 | 12 | ||
| 13 | for (t = 0; t < 48; t++) { | 13 | for (t = 0; t < 48; t++) { |
| 14 | cube = solvedcube(); | 14 | cube = cube_new(); |
| 15 | cube = applymoves(cube, "R"); | 15 | cube = applymoves(cube, "R"); |
| 16 | cube = applymoves(cube, "U"); | 16 | cube = applymoves(cube, "U"); |
| 17 | cube = applymoves(cube, "F"); | 17 | cube = applymoves(cube, "F"); |
| @@ -20,15 +20,15 @@ int main(void) { | |||
| 20 | tinv = inverse_trans(t); | 20 | tinv = inverse_trans(t); |
| 21 | cube = applytrans(cube, transstr[tinv]); | 21 | cube = applytrans(cube, transstr[tinv]); |
| 22 | 22 | ||
| 23 | if (iserror(cube)) { | 23 | if (cube_error(cube)) { |
| 24 | printf("Error transforming cube\n"); | 24 | printf("Error transforming cube\n"); |
| 25 | } else if (!issolvable(cube)) { | 25 | } else if (!cube_solvable(cube)) { |
| 26 | printf("Transformed cube is not solvable\n"); | 26 | printf("Transformed cube is not solvable\n"); |
| 27 | } else { | 27 | } else { |
| 28 | cube = applymoves(cube, "F'"); | 28 | cube = applymoves(cube, "F'"); |
| 29 | cube = applymoves(cube, "U'"); | 29 | cube = applymoves(cube, "U'"); |
| 30 | cube = applymoves(cube, "R'"); | 30 | cube = applymoves(cube, "R'"); |
| 31 | if (!issolved(cube)) | 31 | if (!cube_solved(cube)) |
| 32 | printf("%s: Error! Got %" PRIu8 "\n", | 32 | printf("%s: Error! Got %" PRIu8 "\n", |
| 33 | transstr[t], tinv); | 33 | transstr[t], tinv); |
| 34 | } | 34 | } |
diff --git a/test/last.err b/test/last.err new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test/last.err | |||
diff --git a/test/last.out b/test/last.out new file mode 100644 index 0000000..102ac1b --- /dev/null +++ b/test/last.out | |||
| @@ -0,0 +1 @@ | |||
| UL1 UB0 DL1 UR0 BL1 DR1 BR0 DB0 FL1 UF0 FR1 DF0 DFR2 DFL0 DBL0 UFL0 UBR1 UBL0 UFR2 DBR1 | |||
diff --git a/test/test.h b/test/test.h index 3cbfd10..92ed0db 100644 --- a/test/test.h +++ b/test/test.h | |||
| @@ -4,24 +4,7 @@ | |||
| 4 | #include <stdlib.h> | 4 | #include <stdlib.h> |
| 5 | #include <string.h> | 5 | #include <string.h> |
| 6 | 6 | ||
| 7 | #define STRLENMAX 10000 | 7 | #include "../cube.h" |
| 8 | |||
| 9 | typedef struct { | ||
| 10 | uint8_t corner[8]; | ||
| 11 | uint8_t edge[12]; | ||
| 12 | } cube_t; | ||
| 13 | 8 | ||
| 14 | #ifdef CUBE_AVX2 | 9 | #define STRLENMAX 10000 |
| 15 | #include <immintrin.h> | ||
| 16 | typedef __m256i cube_fast_t; | ||
| 17 | #else | ||
| 18 | typedef cube_t cube_fast_t; | 10 | typedef cube_t cube_fast_t; |
| 19 | #endif | ||
| 20 | |||
| 21 | /* Basic functions used in most tests */ | ||
| 22 | cube_t solvedcube(void); | ||
| 23 | bool iserror(cube_t); | ||
| 24 | bool issolvable(cube_t); | ||
| 25 | bool issolved(cube_t); | ||
| 26 | cube_t readcube(char *, char *); | ||
| 27 | void writecube(char *, cube_t, char *); | ||
