diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2024-06-17 17:39:06 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2024-06-17 17:39:30 +0200 |
| commit | e986713657bc5f9880e91ed49dd9b0d0227f048d (patch) | |
| tree | 908d371e60546795c4ca1f9a3b67571b964203c5 /test | |
| parent | 02ce9adf6a9168ec66c322ce9e5a5cb9fe1e60a5 (diff) | |
| download | nissy-core-e986713657bc5f9880e91ed49dd9b0d0227f048d.tar.gz nissy-core-e986713657bc5f9880e91ed49dd9b0d0227f048d.zip | |
Use callback function to log to stderr
Diffstat (limited to '')
29 files changed, 40 insertions, 121 deletions
diff --git a/test/000_basic/basic_tests.c b/test/000_basic/basic_tests.c index c4434c5..accde66 100644 --- a/test/000_basic/basic_tests.c +++ b/test/000_basic/basic_tests.c | |||
| @@ -17,7 +17,7 @@ check2(cube_t cube1, char *name1, cube_t cube2, char *name2) | |||
| 17 | equal(cube1, cube2) ? "" : " NOT"); | 17 | equal(cube1, cube2) ? "" : " NOT"); |
| 18 | } | 18 | } |
| 19 | 19 | ||
| 20 | int main(void) { | 20 | void run(void) { |
| 21 | cube_t zero, solved; | 21 | cube_t zero, solved; |
| 22 | 22 | ||
| 23 | memset(&zero, 0, sizeof(cube_t)); | 23 | memset(&zero, 0, sizeof(cube_t)); |
| @@ -28,6 +28,4 @@ int main(void) { | |||
| 28 | check2(solved, "Solved", solved, "Solved"); | 28 | check2(solved, "Solved", solved, "Solved"); |
| 29 | check2(solved, "Solved", zero, "Zero"); | 29 | check2(solved, "Solved", zero, "Zero"); |
| 30 | check2(zero, "Zero", solved, "Solved"); | 30 | check2(zero, "Zero", solved, "Solved"); |
| 31 | |||
| 32 | return 0; | ||
| 33 | } | 31 | } |
diff --git a/test/001_pieces/pieces_tests.c b/test/001_pieces/pieces_tests.c index 1ef2fd0..2e6460b 100644 --- a/test/001_pieces/pieces_tests.c +++ b/test/001_pieces/pieces_tests.c | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | 2 | ||
| 3 | void pieces(cube_t *, uint8_t [static 8], uint8_t [static 12]); | 3 | void pieces(cube_t *, uint8_t [static 8], uint8_t [static 12]); |
| 4 | 4 | ||
| 5 | int main(void) { | 5 | void run(void) { |
| 6 | int i; | 6 | int i; |
| 7 | uint8_t corner[8], edge[12]; | 7 | uint8_t corner[8], edge[12]; |
| 8 | char str[STRLENMAX], *aux; | 8 | char str[STRLENMAX], *aux; |
| @@ -22,6 +22,4 @@ int main(void) { | |||
| 22 | for (i = 0; i < 12; i++) | 22 | for (i = 0; i < 12; i++) |
| 23 | printf("%" PRIu8 " ", edge[i]); | 23 | printf("%" PRIu8 " ", edge[i]); |
| 24 | printf("\n"); | 24 | printf("\n"); |
| 25 | |||
| 26 | return 0; | ||
| 27 | } | 25 | } |
diff --git a/test/010_math_permsign/permsgn_tests.c b/test/010_math_permsign/permsgn_tests.c index 46c7377..04975db 100644 --- a/test/010_math_permsign/permsgn_tests.c +++ b/test/010_math_permsign/permsgn_tests.c | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | 2 | ||
| 3 | int permsign(uint8_t *, int); | 3 | int permsign(uint8_t *, int); |
| 4 | 4 | ||
| 5 | int main(void) { | 5 | void run(void) { |
| 6 | char str[STRLENMAX]; | 6 | char str[STRLENMAX]; |
| 7 | uint8_t a[100]; | 7 | uint8_t a[100]; |
| 8 | int n, i, p; | 8 | int n, i, p; |
| @@ -17,6 +17,4 @@ int main(void) { | |||
| 17 | 17 | ||
| 18 | p = permsign(a, n); | 18 | p = permsign(a, n); |
| 19 | printf("%d\n", p); | 19 | printf("%d\n", p); |
| 20 | |||
| 21 | return 0; | ||
| 22 | } | 20 | } |
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..3d4b7e3 100644 --- a/test/020_io_H48_read_write/io_H48_tests.c +++ b/test/020_io_H48_read_write/io_H48_tests.c | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | #include "../test.h" | 1 | #include "../test.h" |
| 2 | 2 | ||
| 3 | int main(void) { | 3 | void run(void) { |
| 4 | char str[STRLENMAX], *aux; | 4 | char str[STRLENMAX], *aux; |
| 5 | cube_t cube; | 5 | cube_t cube; |
| 6 | 6 | ||
| @@ -19,6 +19,4 @@ int main(void) { | |||
| 19 | writecube("H48", cube, str); | 19 | writecube("H48", cube, str); |
| 20 | printf("%s\n", str); | 20 | printf("%s\n", str); |
| 21 | } | 21 | } |
| 22 | |||
| 23 | return 0; | ||
| 24 | } | 22 | } |
diff --git a/test/021_io_B32_write/io_B32_read_tests.c b/test/021_io_B32_write/io_B32_read_tests.c index 3ff81b1..1d2d334 100644 --- a/test/021_io_B32_write/io_B32_read_tests.c +++ b/test/021_io_B32_write/io_B32_read_tests.c | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | #include "../test.h" | 1 | #include "../test.h" |
| 2 | 2 | ||
| 3 | int main(void) { | 3 | void run(void) { |
| 4 | char str[STRLENMAX], *aux; | 4 | char str[STRLENMAX], *aux; |
| 5 | cube_t cube; | 5 | cube_t cube; |
| 6 | 6 | ||
| @@ -19,6 +19,4 @@ int main(void) { | |||
| 19 | writecube("B32", cube, str); | 19 | writecube("B32", cube, str); |
| 20 | printf("%s\n", str); | 20 | printf("%s\n", str); |
| 21 | } | 21 | } |
| 22 | |||
| 23 | return 0; | ||
| 24 | } | 22 | } |
diff --git a/test/022_io_B32_read/io_B32_read_tests.c b/test/022_io_B32_read/io_B32_read_tests.c index cf987f7..5fa9daf 100644 --- a/test/022_io_B32_read/io_B32_read_tests.c +++ b/test/022_io_B32_read/io_B32_read_tests.c | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | #include "../test.h" | 1 | #include "../test.h" |
| 2 | 2 | ||
| 3 | int main(void) { | 3 | void run(void) { |
| 4 | char str[STRLENMAX], *aux; | 4 | char str[STRLENMAX], *aux; |
| 5 | cube_t cube; | 5 | cube_t cube; |
| 6 | 6 | ||
| @@ -19,6 +19,4 @@ int main(void) { | |||
| 19 | writecube("H48", cube, str); | 19 | writecube("H48", cube, str); |
| 20 | printf("%s\n", str); | 20 | printf("%s\n", str); |
| 21 | } | 21 | } |
| 22 | |||
| 23 | return 0; | ||
| 24 | } | 22 | } |
diff --git a/test/023_io_LST_write/io_LST_write_tests.c b/test/023_io_LST_write/io_LST_write_tests.c index df35632..f041864 100644 --- a/test/023_io_LST_write/io_LST_write_tests.c +++ b/test/023_io_LST_write/io_LST_write_tests.c | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | #include "../test.h" | 1 | #include "../test.h" |
| 2 | 2 | ||
| 3 | int main(void) { | 3 | void run(void) { |
| 4 | char str[STRLENMAX], *aux; | 4 | char str[STRLENMAX], *aux; |
| 5 | cube_t cube; | 5 | cube_t cube; |
| 6 | 6 | ||
| @@ -19,6 +19,4 @@ int main(void) { | |||
| 19 | writecube("LST", cube, str); | 19 | writecube("LST", cube, str); |
| 20 | printf("%s\n", str); | 20 | printf("%s\n", str); |
| 21 | } | 21 | } |
| 22 | |||
| 23 | return 0; | ||
| 24 | } | 22 | } |
diff --git a/test/024_io_LST_read/io_LST_read_tests.c b/test/024_io_LST_read/io_LST_read_tests.c index 506a23d..fa80131 100644 --- a/test/024_io_LST_read/io_LST_read_tests.c +++ b/test/024_io_LST_read/io_LST_read_tests.c | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | #include "../test.h" | 1 | #include "../test.h" |
| 2 | 2 | ||
| 3 | int main(void) { | 3 | void run(void) { |
| 4 | char str[STRLENMAX], *aux; | 4 | char str[STRLENMAX], *aux; |
| 5 | cube_t cube; | 5 | cube_t cube; |
| 6 | 6 | ||
| @@ -19,6 +19,4 @@ int main(void) { | |||
| 19 | writecube("H48", cube, str); | 19 | writecube("H48", cube, str); |
| 20 | printf("%s\n", str); | 20 | printf("%s\n", str); |
| 21 | } | 21 | } |
| 22 | |||
| 23 | return 0; | ||
| 24 | } | 22 | } |
diff --git a/test/030_move/move_tests.c b/test/030_move/move_tests.c index 73e9dbe..d4a109b 100644 --- a/test/030_move/move_tests.c +++ b/test/030_move/move_tests.c | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | 2 | ||
| 3 | cube_t applymoves(cube_t, char *); | 3 | cube_t applymoves(cube_t, char *); |
| 4 | 4 | ||
| 5 | int main(void) { | 5 | void run(void) { |
| 6 | char movestr[STRLENMAX], cubestr[STRLENMAX]; | 6 | char movestr[STRLENMAX], cubestr[STRLENMAX]; |
| 7 | cube_t cube; | 7 | cube_t cube; |
| 8 | 8 | ||
| @@ -20,6 +20,4 @@ int main(void) { | |||
| 20 | writecube("H48", cube, cubestr); | 20 | writecube("H48", cube, cubestr); |
| 21 | printf("%s\n", cubestr); | 21 | printf("%s\n", cubestr); |
| 22 | } | 22 | } |
| 23 | |||
| 24 | return 0; | ||
| 25 | } | 23 | } |
diff --git a/test/040_inverse_cube/inverse_tests.c b/test/040_inverse_cube/inverse_tests.c index 2ff3bc7..4cb7ad1 100644 --- a/test/040_inverse_cube/inverse_tests.c +++ b/test/040_inverse_cube/inverse_tests.c | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | 2 | ||
| 3 | cube_t inverse(cube_t); | 3 | cube_t inverse(cube_t); |
| 4 | 4 | ||
| 5 | int main(void) { | 5 | void run(void) { |
| 6 | char str[STRLENMAX]; | 6 | char str[STRLENMAX]; |
| 7 | cube_t cube, inv; | 7 | cube_t cube, inv; |
| 8 | 8 | ||
| @@ -18,6 +18,4 @@ int main(void) { | |||
| 18 | writecube("H48", inv, str); | 18 | writecube("H48", inv, str); |
| 19 | printf("%s\n", str); | 19 | printf("%s\n", str); |
| 20 | } | 20 | } |
| 21 | |||
| 22 | return 0; | ||
| 23 | } | 21 | } |
diff --git a/test/050_compose/compose_tests.c b/test/050_compose/compose_tests.c index 0ea4eff..e0e65b2 100644 --- a/test/050_compose/compose_tests.c +++ b/test/050_compose/compose_tests.c | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | 2 | ||
| 3 | cube_t compose(cube_t, cube_t); | 3 | cube_t compose(cube_t, cube_t); |
| 4 | 4 | ||
| 5 | int main(void) { | 5 | void run(void) { |
| 6 | char str[STRLENMAX]; | 6 | char str[STRLENMAX]; |
| 7 | cube_t c1, c2, c3; | 7 | cube_t c1, c2, c3; |
| 8 | 8 | ||
| @@ -21,6 +21,4 @@ int main(void) { | |||
| 21 | writecube("H48", c3, str); | 21 | writecube("H48", c3, str); |
| 22 | printf("%s\n", str); | 22 | printf("%s\n", str); |
| 23 | } | 23 | } |
| 24 | |||
| 25 | return 0; | ||
| 26 | } | 24 | } |
diff --git a/test/060_transform/transform_tests.c b/test/060_transform/transform_tests.c index f95ad67..bdb4dc5 100644 --- a/test/060_transform/transform_tests.c +++ b/test/060_transform/transform_tests.c | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | 2 | ||
| 3 | cube_t applytrans(cube_t, char *); | 3 | cube_t applytrans(cube_t, char *); |
| 4 | 4 | ||
| 5 | int main(void) { | 5 | void run(void) { |
| 6 | char cubestr[STRLENMAX], transtr[STRLENMAX]; | 6 | char cubestr[STRLENMAX], transtr[STRLENMAX]; |
| 7 | cube_t cube; | 7 | cube_t cube; |
| 8 | 8 | ||
| @@ -20,6 +20,4 @@ int main(void) { | |||
| 20 | writecube("H48", cube, cubestr); | 20 | writecube("H48", cube, cubestr); |
| 21 | printf("%s\n", cubestr); | 21 | printf("%s\n", cubestr); |
| 22 | } | 22 | } |
| 23 | |||
| 24 | return 0; | ||
| 25 | } | 23 | } |
diff --git a/test/061_inverse_trans/inverse_trans_tests.c b/test/061_inverse_trans/inverse_trans_tests.c index 77bd40b..bbc1ac9 100644 --- a/test/061_inverse_trans/inverse_trans_tests.c +++ b/test/061_inverse_trans/inverse_trans_tests.c | |||
| @@ -6,7 +6,7 @@ cube_t applymoves(cube_t, char *); | |||
| 6 | cube_t applytrans(cube_t, char *); | 6 | cube_t applytrans(cube_t, char *); |
| 7 | extern char *transstr[]; | 7 | extern char *transstr[]; |
| 8 | 8 | ||
| 9 | int main(void) { | 9 | void run(void) { |
| 10 | uint8_t t, tinv; | 10 | uint8_t t, tinv; |
| 11 | cube_t cube; | 11 | cube_t cube; |
| 12 | 12 | ||
| @@ -33,6 +33,4 @@ int main(void) { | |||
| 33 | transstr[t], tinv); | 33 | transstr[t], tinv); |
| 34 | } | 34 | } |
| 35 | } | 35 | } |
| 36 | |||
| 37 | return 0; | ||
| 38 | } | 36 | } |
diff --git a/test/071_coord_eo/coord_eo_tests.c b/test/071_coord_eo/coord_eo_tests.c index 3defb8b..78e4395 100644 --- a/test/071_coord_eo/coord_eo_tests.c +++ b/test/071_coord_eo/coord_eo_tests.c | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | 2 | ||
| 3 | int64_t coord_eo(cube_t); | 3 | int64_t coord_eo(cube_t); |
| 4 | 4 | ||
| 5 | int main(void) { | 5 | void run(void) { |
| 6 | char str[STRLENMAX]; | 6 | char str[STRLENMAX]; |
| 7 | cube_t cube; | 7 | cube_t cube; |
| 8 | int64_t result; | 8 | int64_t result; |
| @@ -13,6 +13,4 @@ int main(void) { | |||
| 13 | result = coord_eo(cube); | 13 | result = coord_eo(cube); |
| 14 | 14 | ||
| 15 | printf("%" PRId64 "\n", result); | 15 | printf("%" PRId64 "\n", result); |
| 16 | |||
| 17 | return 0; | ||
| 18 | } | 16 | } |
diff --git a/test/072_coord_co/coord_co_tests.c b/test/072_coord_co/coord_co_tests.c index c7af24c..3b84d74 100644 --- a/test/072_coord_co/coord_co_tests.c +++ b/test/072_coord_co/coord_co_tests.c | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | 2 | ||
| 3 | int64_t coord_co(cube_t); | 3 | int64_t coord_co(cube_t); |
| 4 | 4 | ||
| 5 | int main(void) { | 5 | void run(void) { |
| 6 | char str[STRLENMAX]; | 6 | char str[STRLENMAX]; |
| 7 | cube_t cube; | 7 | cube_t cube; |
| 8 | int64_t result; | 8 | int64_t result; |
| @@ -13,6 +13,4 @@ int main(void) { | |||
| 13 | result = coord_co(cube); | 13 | result = coord_co(cube); |
| 14 | 14 | ||
| 15 | printf("%" PRId64 "\n", result); | 15 | printf("%" PRId64 "\n", result); |
| 16 | |||
| 17 | return 0; | ||
| 18 | } | 16 | } |
diff --git a/test/073_coord_csep/coord_csep_tests.c b/test/073_coord_csep/coord_csep_tests.c index a6e13c5..6d20079 100644 --- a/test/073_coord_csep/coord_csep_tests.c +++ b/test/073_coord_csep/coord_csep_tests.c | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | 2 | ||
| 3 | int64_t coord_csep(cube_t); | 3 | int64_t coord_csep(cube_t); |
| 4 | 4 | ||
| 5 | int main(void) { | 5 | void run(void) { |
| 6 | char str[STRLENMAX]; | 6 | char str[STRLENMAX]; |
| 7 | cube_t cube; | 7 | cube_t cube; |
| 8 | int64_t result; | 8 | int64_t result; |
| @@ -13,6 +13,4 @@ int main(void) { | |||
| 13 | result = coord_csep(cube); | 13 | result = coord_csep(cube); |
| 14 | 14 | ||
| 15 | printf("%" PRId64 "\n", result); | 15 | printf("%" PRId64 "\n", result); |
| 16 | |||
| 17 | return 0; | ||
| 18 | } | 16 | } |
diff --git a/test/074_coord_esep/coord_esep_tests.c b/test/074_coord_esep/coord_esep_tests.c index 0ed3ef3..134ab59 100644 --- a/test/074_coord_esep/coord_esep_tests.c +++ b/test/074_coord_esep/coord_esep_tests.c | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | 2 | ||
| 3 | int64_t coord_esep(cube_t); | 3 | int64_t coord_esep(cube_t); |
| 4 | 4 | ||
| 5 | int main(void) { | 5 | void run(void) { |
| 6 | char str[STRLENMAX]; | 6 | char str[STRLENMAX]; |
| 7 | cube_t cube; | 7 | cube_t cube; |
| 8 | int64_t result; | 8 | int64_t result; |
| @@ -13,6 +13,4 @@ int main(void) { | |||
| 13 | result = coord_esep(cube); | 13 | result = coord_esep(cube); |
| 14 | 14 | ||
| 15 | printf("%" PRId64 "\n", result); | 15 | printf("%" PRId64 "\n", result); |
| 16 | |||
| 17 | return 0; | ||
| 18 | } | 16 | } |
diff --git a/test/075_set_eo/set_eo_tests.c b/test/075_set_eo/set_eo_tests.c index 9c01a50..fb2c23e 100644 --- a/test/075_set_eo/set_eo_tests.c +++ b/test/075_set_eo/set_eo_tests.c | |||
| @@ -4,7 +4,7 @@ int64_t coord_eo(cube_t); | |||
| 4 | void set_eo(cube_t *, int64_t); | 4 | void set_eo(cube_t *, int64_t); |
| 5 | void pieces(cube_t *, uint8_t [static 8], uint8_t [static 12]); | 5 | void pieces(cube_t *, uint8_t [static 8], uint8_t [static 12]); |
| 6 | 6 | ||
| 7 | int main(void) { | 7 | void run(void) { |
| 8 | char str[STRLENMAX]; | 8 | char str[STRLENMAX]; |
| 9 | cube_t cube; | 9 | cube_t cube; |
| 10 | uint8_t edge[12], corner[8]; | 10 | uint8_t edge[12], corner[8]; |
| @@ -33,6 +33,4 @@ int main(void) { | |||
| 33 | writecube("H48", cube, str); | 33 | writecube("H48", cube, str); |
| 34 | printf("%s\n", str); | 34 | printf("%s\n", str); |
| 35 | } | 35 | } |
| 36 | |||
| 37 | return 0; | ||
| 38 | } | 36 | } |
diff --git a/test/076_copy_corners/copy_corners_tests.c b/test/076_copy_corners/copy_corners_tests.c index 446a849..7464ecc 100644 --- a/test/076_copy_corners/copy_corners_tests.c +++ b/test/076_copy_corners/copy_corners_tests.c | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | 2 | ||
| 3 | void copy_corners(cube_t *, cube_t); | 3 | void copy_corners(cube_t *, cube_t); |
| 4 | 4 | ||
| 5 | int main(void) { | 5 | void run(void) { |
| 6 | char str[STRLENMAX]; | 6 | char str[STRLENMAX]; |
| 7 | cube_t c1, c2; | 7 | cube_t c1, c2; |
| 8 | 8 | ||
| @@ -22,6 +22,4 @@ int main(void) { | |||
| 22 | writecube("H48", c1, str); | 22 | writecube("H48", c1, str); |
| 23 | printf("%s\n", str); | 23 | printf("%s\n", str); |
| 24 | } | 24 | } |
| 25 | |||
| 26 | return 0; | ||
| 27 | } | 25 | } |
diff --git a/test/077_copy_edges/copy_edges_tests.c b/test/077_copy_edges/copy_edges_tests.c index 9afcb73..5077861 100644 --- a/test/077_copy_edges/copy_edges_tests.c +++ b/test/077_copy_edges/copy_edges_tests.c | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | 2 | ||
| 3 | void copy_edges(cube_t *, cube_t); | 3 | void copy_edges(cube_t *, cube_t); |
| 4 | 4 | ||
| 5 | int main(void) { | 5 | void run(void) { |
| 6 | char str[STRLENMAX]; | 6 | char str[STRLENMAX]; |
| 7 | cube_t c1, c2; | 7 | cube_t c1, c2; |
| 8 | 8 | ||
| @@ -22,6 +22,4 @@ int main(void) { | |||
| 22 | writecube("H48", c1, str); | 22 | writecube("H48", c1, str); |
| 23 | printf("%s\n", str); | 23 | printf("%s\n", str); |
| 24 | } | 24 | } |
| 25 | |||
| 26 | return 0; | ||
| 27 | } | 25 | } |
diff --git a/test/078_invcoord_esep/invcoord_esep_tests.c b/test/078_invcoord_esep/invcoord_esep_tests.c index 0b83175..45f508b 100644 --- a/test/078_invcoord_esep/invcoord_esep_tests.c +++ b/test/078_invcoord_esep/invcoord_esep_tests.c | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | int64_t coord_esep(cube_t); | 3 | int64_t coord_esep(cube_t); |
| 4 | cube_t invcoord_esep(int64_t); | 4 | cube_t invcoord_esep(int64_t); |
| 5 | 5 | ||
| 6 | int main(void) { | 6 | void run(void) { |
| 7 | char str[STRLENMAX]; | 7 | char str[STRLENMAX]; |
| 8 | cube_t cube; | 8 | cube_t cube; |
| 9 | int64_t i; | 9 | int64_t i; |
| @@ -16,6 +16,4 @@ int main(void) { | |||
| 16 | i = coord_esep(cube); | 16 | i = coord_esep(cube); |
| 17 | 17 | ||
| 18 | printf("%" PRId64 "\n", i); | 18 | printf("%" PRId64 "\n", i); |
| 19 | |||
| 20 | return 0; | ||
| 21 | } | 19 | } |
diff --git a/test/080_allowednext/allowednext_tests.c b/test/080_allowednext/allowednext_tests.c index e531911..644d4c5 100644 --- a/test/080_allowednext/allowednext_tests.c +++ b/test/080_allowednext/allowednext_tests.c | |||
| @@ -11,7 +11,7 @@ static char *moves[] = { | |||
| 11 | "B", "B2", "B'", | 11 | "B", "B2", "B'", |
| 12 | }; | 12 | }; |
| 13 | 13 | ||
| 14 | int main(void) { | 14 | void run(void) { |
| 15 | char movestr[STRLENMAX]; | 15 | char movestr[STRLENMAX]; |
| 16 | uint8_t m[100]; | 16 | uint8_t m[100]; |
| 17 | int n, i, j; | 17 | int n, i, j; |
| @@ -32,6 +32,4 @@ int main(void) { | |||
| 32 | n > 1 ? moves[m[n-2]] : "-", | 32 | n > 1 ? moves[m[n-2]] : "-", |
| 33 | n > 0 ? moves[m[n-1]] : "-"); | 33 | n > 0 ? moves[m[n-1]] : "-"); |
| 34 | printf("%s\n", allowednextmove(m, n) ? "true" : "false"); | 34 | printf("%s\n", allowednextmove(m, n) ? "true" : "false"); |
| 35 | |||
| 36 | return 0; | ||
| 37 | } | 35 | } |
diff --git a/test/090_solve_simple/solve_simple_tests.c b/test/090_solve_simple/solve_simple_tests.c index 5ba6d20..f5e00e2 100644 --- a/test/090_solve_simple/solve_simple_tests.c +++ b/test/090_solve_simple/solve_simple_tests.c | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | int64_t solve(cube_t, char *, char *, char *, int8_t, int8_t, int64_t, int8_t, | 3 | int64_t solve(cube_t, char *, char *, char *, int8_t, int8_t, int64_t, int8_t, |
| 4 | void *, char *); | 4 | void *, char *); |
| 5 | 5 | ||
| 6 | int main(void) { | 6 | void run(void) { |
| 7 | char cubestr[STRLENMAX], solverstr[STRLENMAX], optionsstr[STRLENMAX]; | 7 | char cubestr[STRLENMAX], solverstr[STRLENMAX], optionsstr[STRLENMAX]; |
| 8 | char nisstypestr[STRLENMAX], minmovesstr[STRLENMAX]; | 8 | char nisstypestr[STRLENMAX], minmovesstr[STRLENMAX]; |
| 9 | char maxmovesstr[STRLENMAX], maxsolsstr[STRLENMAX]; | 9 | char maxmovesstr[STRLENMAX], maxsolsstr[STRLENMAX]; |
| @@ -45,6 +45,4 @@ int main(void) { | |||
| 45 | ); | 45 | ); |
| 46 | 46 | ||
| 47 | printf("%s", solutionsstr); | 47 | printf("%s", solutionsstr); |
| 48 | |||
| 49 | return 0; | ||
| 50 | } | 48 | } |
diff --git a/test/100_gendata_cocsep/gendata_cocsep_tests.c b/test/100_gendata_cocsep/gendata_cocsep_tests.c index 9d8f03c..4a29ebb 100644 --- a/test/100_gendata_cocsep/gendata_cocsep_tests.c +++ b/test/100_gendata_cocsep/gendata_cocsep_tests.c | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | size_t gendata_cocsep(void *, uint64_t *, cube_t *); | 5 | size_t gendata_cocsep(void *, uint64_t *, cube_t *); |
| 6 | 6 | ||
| 7 | int main(void) { | 7 | void run(void) { |
| 8 | uint32_t buf[300000], i; | 8 | uint32_t buf[300000], i; |
| 9 | uint64_t selfsim[COCSEP_CLASSES]; | 9 | uint64_t selfsim[COCSEP_CLASSES]; |
| 10 | cube_t rep[COCSEP_CLASSES]; | 10 | cube_t rep[COCSEP_CLASSES]; |
| @@ -17,6 +17,4 @@ int main(void) { | |||
| 17 | printf("Max value: %" PRIu32 "\n", buf[result/4-11]); | 17 | printf("Max value: %" PRIu32 "\n", buf[result/4-11]); |
| 18 | for (i = 0; i < 10; i++) | 18 | for (i = 0; i < 10; i++) |
| 19 | printf("%" PRIu32 ": %" PRIu32 "\n", i, buf[result/4-10+i]); | 19 | printf("%" PRIu32 ": %" PRIu32 "\n", i, buf[result/4-10+i]); |
| 20 | |||
| 21 | return 0; | ||
| 22 | } | 20 | } |
diff --git a/test/101_cocsep_selfsim/cocsep_selfsim_tests.c b/test/101_cocsep_selfsim/cocsep_selfsim_tests.c index 195f9ba..9d9a8b2 100644 --- a/test/101_cocsep_selfsim/cocsep_selfsim_tests.c +++ b/test/101_cocsep_selfsim/cocsep_selfsim_tests.c | |||
| @@ -12,7 +12,7 @@ | |||
| 12 | size_t gendata_cocsep(void *, uint64_t *, cube_t *); | 12 | size_t gendata_cocsep(void *, uint64_t *, cube_t *); |
| 13 | int64_t coord_cocsep(cube_t); | 13 | int64_t coord_cocsep(cube_t); |
| 14 | 14 | ||
| 15 | int main(void) { | 15 | void run(void) { |
| 16 | char str[STRLENMAX]; | 16 | char str[STRLENMAX]; |
| 17 | uint32_t buf[300000], data; | 17 | uint32_t buf[300000], data; |
| 18 | int64_t coord, coclass; | 18 | int64_t coord, coclass; |
| @@ -35,6 +35,4 @@ int main(void) { | |||
| 35 | } | 35 | } |
| 36 | printf("\n"); | 36 | printf("\n"); |
| 37 | } | 37 | } |
| 38 | |||
| 39 | return 0; | ||
| 40 | } | 38 | } |
diff --git a/test/102_coord_invcoord_h48/coord_invcoord_h48_tests.c b/test/102_coord_invcoord_h48/coord_invcoord_h48_tests.c index b0668df..77dea81 100644 --- a/test/102_coord_invcoord_h48/coord_invcoord_h48_tests.c +++ b/test/102_coord_invcoord_h48/coord_invcoord_h48_tests.c | |||
| @@ -7,7 +7,7 @@ int64_t coord_h48(cube_t, const uint32_t *, uint8_t); | |||
| 7 | cube_t invcoord_h48(int64_t, const cube_t *, uint8_t); | 7 | cube_t invcoord_h48(int64_t, const cube_t *, uint8_t); |
| 8 | cube_t transform(cube_t, uint8_t); | 8 | cube_t transform(cube_t, uint8_t); |
| 9 | 9 | ||
| 10 | int main(void) { | 10 | void run(void) { |
| 11 | char str[STRLENMAX]; | 11 | char str[STRLENMAX]; |
| 12 | int i; | 12 | int i; |
| 13 | bool found; | 13 | bool found; |
| @@ -33,6 +33,4 @@ int main(void) { | |||
| 33 | printf("%d %s\n", i, found ? "ok" : "ERROR"); | 33 | printf("%d %s\n", i, found ? "ok" : "ERROR"); |
| 34 | i++; | 34 | i++; |
| 35 | } | 35 | } |
| 36 | |||
| 37 | return 0; | ||
| 38 | } | 36 | } |
diff --git a/test/103_gendata_h48/gendata_h48_tests.c b/test/103_gendata_h48/gendata_h48_tests.c index f0910cc..666f9f6 100644 --- a/test/103_gendata_h48/gendata_h48_tests.c +++ b/test/103_gendata_h48/gendata_h48_tests.c | |||
| @@ -6,7 +6,7 @@ | |||
| 6 | 6 | ||
| 7 | size_t gendata_h48(void *, uint8_t, uint8_t); | 7 | size_t gendata_h48(void *, uint8_t, uint8_t); |
| 8 | 8 | ||
| 9 | int main(void) { | 9 | void run(void) { |
| 10 | char str[STRLENMAX]; | 10 | char str[STRLENMAX]; |
| 11 | uint8_t h, i; | 11 | uint8_t h, i; |
| 12 | uint32_t *buf, *h48info; | 12 | uint32_t *buf, *h48info; |
| @@ -31,5 +31,4 @@ int main(void) { | |||
| 31 | printf("%" PRIu32 ": %" PRIu32 "\n", i, h48info[i+1]); | 31 | printf("%" PRIu32 ": %" PRIu32 "\n", i, h48info[i+1]); |
| 32 | 32 | ||
| 33 | free(buf); | 33 | free(buf); |
| 34 | return 0; | ||
| 35 | } | 34 | } |
diff --git a/test/test b/test/test deleted file mode 100755 index 3adee3a..0000000 --- a/test/test +++ /dev/null | |||
| @@ -1,41 +0,0 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | detectsan() { cc -fsanitize=$1 -dM -E -x c - </dev/null | grep "SANITIZE"; } | ||
| 4 | |||
| 5 | re="${TEST:-$@}" | ||
| 6 | |||
| 7 | CC="cc -DDEBUG -std=c99 -pedantic -Wall -Wextra \ | ||
| 8 | -Wno-unused-parameter -Wno-unused-function -g3 -D$CUBETYPE" | ||
| 9 | |||
| 10 | [ "$CUBETYPE" = "CUBE_AVX2" ] && CC="$CC -mavx2" | ||
| 11 | [ -n "$(detectsan address)" ] && CC="$CC -fsanitize=address" | ||
| 12 | [ -n "$(detectsan undefined)" ] && CC="$CC -fsanitize=undefined" | ||
| 13 | |||
| 14 | TESTBIN="test/run" | ||
| 15 | TESTOUT="test/last.out" | ||
| 16 | TESTERR="test/last.err" | ||
| 17 | CUBEOBJ="debugcube.o" | ||
| 18 | |||
| 19 | for t in test/*; do | ||
| 20 | if [ -n "$re" ] && [ -z "$(echo "$t" | grep "$re")" ]; then | ||
| 21 | continue | ||
| 22 | fi | ||
| 23 | if [ ! -d $t ]; then continue; fi | ||
| 24 | $CC -o $TESTBIN $t/*.c $CUBEOBJ || exit 1; | ||
| 25 | for cin in $t/*.in; do | ||
| 26 | c=$(echo "$cin" | sed 's/\.in//') | ||
| 27 | cout=$c.out | ||
| 28 | printf "$c: " | ||
| 29 | $TESTBIN < "$cin" > $TESTOUT 2> $TESTERR | ||
| 30 | if diff $cout $TESTOUT; then | ||
| 31 | printf "OK\n" | ||
| 32 | else | ||
| 33 | printf "Test failed! stderr:\n" | ||
| 34 | cat $TESTERR | ||
| 35 | exit 1 | ||
| 36 | fi | ||
| 37 | done | ||
| 38 | done | ||
| 39 | |||
| 40 | echo "All tests passed!" | ||
| 41 | rm -rf $TESTBIN $TESTOUT $TESTERR $CUBEOBJ | ||
diff --git a/test/test.h b/test/test.h index 1bbb9fc..415e093 100644 --- a/test/test.h +++ b/test/test.h | |||
| @@ -1,4 +1,5 @@ | |||
| 1 | #include <inttypes.h> | 1 | #include <inttypes.h> |
| 2 | #include <stdarg.h> | ||
| 2 | #include <stdbool.h> | 3 | #include <stdbool.h> |
| 3 | #include <stdio.h> | 4 | #include <stdio.h> |
| 4 | #include <stdlib.h> | 5 | #include <stdlib.h> |
| @@ -24,3 +25,15 @@ bool issolvable(cube_t); | |||
| 24 | bool issolved(cube_t); | 25 | bool issolved(cube_t); |
| 25 | cube_t readcube(char *, char *); | 26 | cube_t readcube(char *, char *); |
| 26 | void writecube(char *, cube_t, char *); | 27 | void writecube(char *, cube_t, char *); |
| 28 | void nissy_setlogger(void (*logger_function)(const char *, va_list)); | ||
| 29 | |||
| 30 | /* Test function to be implemented by all tests */ | ||
| 31 | void run(void); | ||
| 32 | |||
| 33 | void log_stderr(const char *str, va_list vl) { vfprintf(stderr, str, vl); } | ||
| 34 | |||
| 35 | int main(void) { | ||
| 36 | nissy_setlogger(log_stderr); | ||
| 37 | run(); | ||
| 38 | return 0; | ||
| 39 | } | ||
