diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2023-11-13 23:47:00 +0100 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2023-11-13 23:47:00 +0100 |
| commit | 41e31b84a9adeae0b6bdbc4c9438bfa5e782c9da (patch) | |
| tree | b6e9ae4db711e6b902ce5ae0f04e0b83c193cd26 /test | |
| parent | 4444e53eaadf33aa309a40849730be332ca6d0de (diff) | |
| download | nissy-core-41e31b84a9adeae0b6bdbc4c9438bfa5e782c9da.tar.gz nissy-core-41e31b84a9adeae0b6bdbc4c9438bfa5e782c9da.zip | |
Test cleanup
Diffstat (limited to 'test')
| -rw-r--r-- | test/00_basic/basic_tests.c | 13 | ||||
| -rw-r--r-- | test/010_io_H48_read_write/io_H48_tests.c | 12 | ||||
| -rw-r--r-- | test/011_io_SRC_write/io_SRC_tests.c | 12 | ||||
| -rw-r--r-- | test/012_io_AVX_write/io_AVX_tests.c | 15 | ||||
| -rw-r--r-- | test/020_move/move_tests.c | 13 | ||||
| -rw-r--r-- | test/030_inverse_cube/inverse_tests.c | 12 | ||||
| -rw-r--r-- | test/040_compose/compose_tests.c | 12 | ||||
| -rw-r--r-- | test/050_transform/transform_tests.c | 12 | ||||
| -rw-r--r-- | test/061_coord_eo/coord_eo_tests.c | 10 | ||||
| -rw-r--r-- | test/070_solve_simple/solve_simple_tests.c | 38 | ||||
| -rw-r--r-- | test/test.h | 21 |
11 files changed, 54 insertions, 116 deletions
diff --git a/test/00_basic/basic_tests.c b/test/00_basic/basic_tests.c index af0f2cd..17f1b2b 100644 --- a/test/00_basic/basic_tests.c +++ b/test/00_basic/basic_tests.c | |||
| @@ -1,13 +1,7 @@ | |||
| 1 | #include <stdbool.h> | 1 | #include "../test.h" |
| 2 | #include <stdint.h> | ||
| 3 | #include <stdio.h> | ||
| 4 | #include <string.h> | ||
| 5 | 2 | ||
| 6 | #ifdef CUBE_AVX2 | 3 | bool issolved(cube_t); |
| 7 | #include <immintrin.h> | 4 | bool equal(cube_t, cube_t); |
| 8 | #endif | ||
| 9 | |||
| 10 | #include "../../cube.h" | ||
| 11 | 5 | ||
| 12 | void | 6 | void |
| 13 | check(cube_t cube, char *name) | 7 | check(cube_t cube, char *name) |
| @@ -19,7 +13,6 @@ check(cube_t cube, char *name) | |||
| 19 | void | 13 | void |
| 20 | check2(cube_t cube1, char *name1, cube_t cube2, char *name2) | 14 | check2(cube_t cube1, char *name1, cube_t cube2, char *name2) |
| 21 | { | 15 | { |
| 22 | fprintf(stderr, "check2 %s %s\n", name1, name2); | ||
| 23 | printf("%s and %s are%s equal\n", name1, name2, | 16 | printf("%s and %s are%s equal\n", name1, name2, |
| 24 | equal(cube1, cube2) ? "" : " NOT"); | 17 | equal(cube1, cube2) ? "" : " NOT"); |
| 25 | } | 18 | } |
diff --git a/test/010_io_H48_read_write/io_H48_tests.c b/test/010_io_H48_read_write/io_H48_tests.c index 70d1a91..71df1e7 100644 --- a/test/010_io_H48_read_write/io_H48_tests.c +++ b/test/010_io_H48_read_write/io_H48_tests.c | |||
| @@ -1,14 +1,4 @@ | |||
| 1 | #include <stdbool.h> | 1 | #include "../test.h" |
| 2 | #include <stdint.h> | ||
| 3 | #include <stdio.h> | ||
| 4 | |||
| 5 | #ifdef CUBE_AVX2 | ||
| 6 | #include <immintrin.h> | ||
| 7 | #endif | ||
| 8 | |||
| 9 | #include "../../cube.h" | ||
| 10 | |||
| 11 | #define STRLENMAX 10000 | ||
| 12 | 2 | ||
| 13 | int main() { | 3 | int main() { |
| 14 | char *c, str[STRLENMAX]; | 4 | char *c, str[STRLENMAX]; |
diff --git a/test/011_io_SRC_write/io_SRC_tests.c b/test/011_io_SRC_write/io_SRC_tests.c index c2d10f6..5ae3d99 100644 --- a/test/011_io_SRC_write/io_SRC_tests.c +++ b/test/011_io_SRC_write/io_SRC_tests.c | |||
| @@ -1,14 +1,4 @@ | |||
| 1 | #include <stdbool.h> | 1 | #include "../test.h" |
| 2 | #include <stdint.h> | ||
| 3 | #include <stdio.h> | ||
| 4 | |||
| 5 | #ifdef CUBE_AVX2 | ||
| 6 | #include <immintrin.h> | ||
| 7 | #endif | ||
| 8 | |||
| 9 | #include "../../cube.h" | ||
| 10 | |||
| 11 | #define STRLENMAX 10000 | ||
| 12 | 2 | ||
| 13 | int main() { | 3 | int main() { |
| 14 | char *c, str[STRLENMAX]; | 4 | char *c, str[STRLENMAX]; |
diff --git a/test/012_io_AVX_write/io_AVX_tests.c b/test/012_io_AVX_write/io_AVX_tests.c index cbe6ef0..7dc944e 100644 --- a/test/012_io_AVX_write/io_AVX_tests.c +++ b/test/012_io_AVX_write/io_AVX_tests.c | |||
| @@ -1,15 +1,12 @@ | |||
| 1 | #include <stdbool.h> | 1 | #include "../test.h" |
| 2 | #include <stdint.h> | ||
| 3 | #include <stdio.h> | ||
| 4 | |||
| 5 | #ifdef CUBE_AVX2 | ||
| 6 | #include <immintrin.h> | ||
| 7 | #endif | ||
| 8 | |||
| 9 | #include "../../cube.h" | ||
| 10 | 2 | ||
| 11 | #define STRLENMAX 10000 | 3 | #define STRLENMAX 10000 |
| 12 | 4 | ||
| 5 | bool iserror(cube_t); | ||
| 6 | bool issolvable(cube_t); | ||
| 7 | cube_t readcube(char *, char *); | ||
| 8 | void writecube(char *, cube_t, char *); | ||
| 9 | |||
| 13 | int main() { | 10 | int main() { |
| 14 | char *c, str[STRLENMAX]; | 11 | char *c, str[STRLENMAX]; |
| 15 | cube_t cube; | 12 | cube_t cube; |
diff --git a/test/020_move/move_tests.c b/test/020_move/move_tests.c index 9e414cc..dde4c4e 100644 --- a/test/020_move/move_tests.c +++ b/test/020_move/move_tests.c | |||
| @@ -1,15 +1,6 @@ | |||
| 1 | #include <stdbool.h> | 1 | #include "../test.h" |
| 2 | #include <stdint.h> | ||
| 3 | #include <stdio.h> | ||
| 4 | 2 | ||
| 5 | #ifdef CUBE_AVX2 | 3 | cube_t applymoves(cube_t, char *); |
| 6 | #include <immintrin.h> | ||
| 7 | #endif | ||
| 8 | |||
| 9 | #include "../../cube.h" | ||
| 10 | |||
| 11 | #define STRLENMAX 10000 | ||
| 12 | #define MOVESMAX 1000 | ||
| 13 | 4 | ||
| 14 | int main() { | 5 | int main() { |
| 15 | char movestr[STRLENMAX], cubestr[STRLENMAX]; | 6 | char movestr[STRLENMAX], cubestr[STRLENMAX]; |
diff --git a/test/030_inverse_cube/inverse_tests.c b/test/030_inverse_cube/inverse_tests.c index 9151e42..d6d47ba 100644 --- a/test/030_inverse_cube/inverse_tests.c +++ b/test/030_inverse_cube/inverse_tests.c | |||
| @@ -1,14 +1,6 @@ | |||
| 1 | #include <stdbool.h> | 1 | #include "../test.h" |
| 2 | #include <stdint.h> | ||
| 3 | #include <stdio.h> | ||
| 4 | 2 | ||
| 5 | #ifdef CUBE_AVX2 | 3 | cube_t inverse(cube_t); |
| 6 | #include <immintrin.h> | ||
| 7 | #endif | ||
| 8 | |||
| 9 | #include "../../cube.h" | ||
| 10 | |||
| 11 | #define STRLENMAX 10000 | ||
| 12 | 4 | ||
| 13 | int main() { | 5 | int main() { |
| 14 | char str[STRLENMAX]; | 6 | char str[STRLENMAX]; |
diff --git a/test/040_compose/compose_tests.c b/test/040_compose/compose_tests.c index c9c11af..d28b225 100644 --- a/test/040_compose/compose_tests.c +++ b/test/040_compose/compose_tests.c | |||
| @@ -1,14 +1,6 @@ | |||
| 1 | #include <stdbool.h> | 1 | #include "../test.h" |
| 2 | #include <stdint.h> | ||
| 3 | #include <stdio.h> | ||
| 4 | 2 | ||
| 5 | #ifdef CUBE_AVX2 | 3 | cube_t compose(cube_t, cube_t); |
| 6 | #include <immintrin.h> | ||
| 7 | #endif | ||
| 8 | |||
| 9 | #include "../../cube.h" | ||
| 10 | |||
| 11 | #define STRLENMAX 10000 | ||
| 12 | 4 | ||
| 13 | int main() { | 5 | int main() { |
| 14 | char str[STRLENMAX]; | 6 | char str[STRLENMAX]; |
diff --git a/test/050_transform/transform_tests.c b/test/050_transform/transform_tests.c index e22a4a1..c1bc5af 100644 --- a/test/050_transform/transform_tests.c +++ b/test/050_transform/transform_tests.c | |||
| @@ -1,14 +1,6 @@ | |||
| 1 | #include <stdbool.h> | 1 | #include "../test.h" |
| 2 | #include <stdint.h> | ||
| 3 | #include <stdio.h> | ||
| 4 | 2 | ||
| 5 | #ifdef CUBE_AVX2 | 3 | cube_t applytrans(cube_t, char *); |
| 6 | #include <immintrin.h> | ||
| 7 | #endif | ||
| 8 | |||
| 9 | #include "../../cube.h" | ||
| 10 | |||
| 11 | #define STRLENMAX 10000 | ||
| 12 | 4 | ||
| 13 | int main() { | 5 | int main() { |
| 14 | char cubestr[STRLENMAX], transtr[STRLENMAX]; | 6 | char cubestr[STRLENMAX], transtr[STRLENMAX]; |
diff --git a/test/061_coord_eo/coord_eo_tests.c b/test/061_coord_eo/coord_eo_tests.c index bd3db8a..2dfba92 100644 --- a/test/061_coord_eo/coord_eo_tests.c +++ b/test/061_coord_eo/coord_eo_tests.c | |||
| @@ -1,15 +1,5 @@ | |||
| 1 | #include <stdbool.h> | ||
| 2 | #include <inttypes.h> | ||
| 3 | #include <stdio.h> | ||
| 4 | |||
| 5 | #ifdef CUBE_AVX2 | ||
| 6 | #include <immintrin.h> | ||
| 7 | #endif | ||
| 8 | |||
| 9 | #include "../test.h" | 1 | #include "../test.h" |
| 10 | 2 | ||
| 11 | #define STRLENMAX 10000 | ||
| 12 | |||
| 13 | int64_t coord_fast_eo(cube_fast_t); | 3 | int64_t coord_fast_eo(cube_fast_t); |
| 14 | cube_fast_t cubetofast(cube_t); | 4 | cube_fast_t cubetofast(cube_t); |
| 15 | 5 | ||
diff --git a/test/070_solve_simple/solve_simple_tests.c b/test/070_solve_simple/solve_simple_tests.c index 14a1674..4756dc0 100644 --- a/test/070_solve_simple/solve_simple_tests.c +++ b/test/070_solve_simple/solve_simple_tests.c | |||
| @@ -1,33 +1,25 @@ | |||
| 1 | #include <stdbool.h> | 1 | #include "../test.h" |
| 2 | #include <stdint.h> | ||
| 3 | #include <stdio.h> | ||
| 4 | #include <stdlib.h> | ||
| 5 | #include <string.h> | ||
| 6 | 2 | ||
| 7 | #ifdef CUBE_AVX2 | 3 | int64_t solve(cube_t, char *, char *, char *, int8_t, int8_t, int64_t, int8_t, |
| 8 | #include <immintrin.h> | 4 | void *, char *); |
| 9 | #endif | ||
| 10 | |||
| 11 | #include "../../cube.h" | ||
| 12 | |||
| 13 | #define S 10000 | ||
| 14 | 5 | ||
| 15 | int main() { | 6 | int main() { |
| 16 | char cubestr[S], solverstr[S], optionsstr[S], nisstypestr[S]; | 7 | char cubestr[STRLENMAX], solverstr[STRLENMAX], optionsstr[STRLENMAX]; |
| 17 | char minmovesstr[S], maxmovesstr[S], maxsolsstr[S], optimalstr[S]; | 8 | char nisstypestr[STRLENMAX], minmovesstr[STRLENMAX]; |
| 18 | char solutionsstr[S]; | 9 | char maxmovesstr[STRLENMAX], maxsolsstr[STRLENMAX]; |
| 10 | char optimalstr[STRLENMAX], solutionsstr[STRLENMAX]; | ||
| 19 | cube_t cube; | 11 | cube_t cube; |
| 20 | int64_t maxsols; | 12 | int64_t maxsols; |
| 21 | int8_t minmoves, maxmoves, optimal; | 13 | int8_t minmoves, maxmoves, optimal; |
| 22 | 14 | ||
| 23 | fgets(cubestr, S, stdin); | 15 | fgets(cubestr, STRLENMAX, stdin); |
| 24 | fgets(solverstr, S, stdin); | 16 | fgets(solverstr, STRLENMAX, stdin); |
| 25 | fgets(optionsstr, S, stdin); | 17 | fgets(optionsstr, STRLENMAX, stdin); |
| 26 | fgets(nisstypestr, S, stdin); | 18 | fgets(nisstypestr, STRLENMAX, stdin); |
| 27 | fgets(minmovesstr, S, stdin); | 19 | fgets(minmovesstr, STRLENMAX, stdin); |
| 28 | fgets(maxmovesstr, S, stdin); | 20 | fgets(maxmovesstr, STRLENMAX, stdin); |
| 29 | fgets(maxsolsstr, S, stdin); | 21 | fgets(maxsolsstr, STRLENMAX, stdin); |
| 30 | fgets(optimalstr, S, stdin); | 22 | fgets(optimalstr, STRLENMAX, stdin); |
| 31 | 23 | ||
| 32 | solverstr[strcspn(solverstr, "\n")] = 0; | 24 | solverstr[strcspn(solverstr, "\n")] = 0; |
| 33 | optionsstr[strcspn(optionsstr, "\n")] = 0; | 25 | optionsstr[strcspn(optionsstr, "\n")] = 0; |
diff --git a/test/test.h b/test/test.h index 607a52d..7c5400e 100644 --- a/test/test.h +++ b/test/test.h | |||
| @@ -1,7 +1,26 @@ | |||
| 1 | #include "../cube.h" | 1 | #include <inttypes.h> |
| 2 | #include <stdbool.h> | ||
| 3 | #include <stdio.h> | ||
| 4 | #include <stdlib.h> | ||
| 5 | #include <string.h> | ||
| 6 | |||
| 7 | #define STRLENMAX 10000 | ||
| 8 | |||
| 9 | typedef struct { | ||
| 10 | uint8_t corner[8]; | ||
| 11 | uint8_t edge[12]; | ||
| 12 | } cube_t; | ||
| 2 | 13 | ||
| 3 | #ifdef CUBE_AVX2 | 14 | #ifdef CUBE_AVX2 |
| 15 | #include <immintrin.h> | ||
| 4 | typedef __m256i cube_fast_t; | 16 | typedef __m256i cube_fast_t; |
| 5 | #else | 17 | #else |
| 6 | typedef cube_t cube_fast_t; | 18 | typedef cube_t cube_fast_t; |
| 7 | #endif | 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 | cube_t readcube(char *, char *); | ||
| 26 | void writecube(char *, cube_t, char *); | ||
