From da8fdd4955fd24666643915a6728678e9965a0d3 Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Sat, 12 Oct 2024 11:11:28 +0200 Subject: Make writecube safer --- test/020_io_H48_read_write/io_H48_tests.c | 2 +- test/021_io_B32_write/io_B32_read_tests.c | 2 +- test/022_io_B32_read/io_B32_read_tests.c | 2 +- test/023_io_LST_write/io_LST_write_tests.c | 2 +- test/024_io_LST_read/io_LST_read_tests.c | 2 +- test/030_move/move_tests.c | 2 +- test/031_premove/premove_tests.c | 2 +- test/040_inverse_cube/inverse_tests.c | 2 +- test/050_compose/compose_tests.c | 2 +- test/060_transform/transform_tests.c | 2 +- test/075_set_eo/set_eo_tests.c | 2 +- test/076_copy_corners/copy_corners_tests.c | 2 +- test/077_copy_edges/copy_edges_tests.c | 2 +- test/081_getcube/getcube_tests.c | 2 +- test/test.h | 4 ++-- 15 files changed, 16 insertions(+), 16 deletions(-) (limited to 'test') 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 3d4b7e3..7809c87 100644 --- a/test/020_io_H48_read_write/io_H48_tests.c +++ b/test/020_io_H48_read_write/io_H48_tests.c @@ -16,7 +16,7 @@ void run(void) { } else if (!issolvable(cube)) { printf("Cube is not solvable\n"); } else { - writecube("H48", cube, str); + writecube("H48", cube, NISSY_SIZE_H48, str); printf("%s\n", str); } } 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 1d2d334..50e07d4 100644 --- a/test/021_io_B32_write/io_B32_read_tests.c +++ b/test/021_io_B32_write/io_B32_read_tests.c @@ -16,7 +16,7 @@ void run(void) { } else if (!issolvable(cube)) { printf("Cube is not solvable\n"); } else { - writecube("B32", cube, str); + writecube("B32", cube, NISSY_SIZE_B32, str); printf("%s\n", str); } } 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 5fa9daf..e11b017 100644 --- a/test/022_io_B32_read/io_B32_read_tests.c +++ b/test/022_io_B32_read/io_B32_read_tests.c @@ -16,7 +16,7 @@ void run(void) { } else if (!issolvable(cube)) { printf("Cube is not solvable\n"); } else { - writecube("H48", cube, str); + writecube("H48", cube, NISSY_SIZE_H48, str); printf("%s\n", str); } } 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 f041864..363bc6d 100644 --- a/test/023_io_LST_write/io_LST_write_tests.c +++ b/test/023_io_LST_write/io_LST_write_tests.c @@ -16,7 +16,7 @@ void run(void) { } else if (!issolvable(cube)) { printf("Cube is not solvable\n"); } else { - writecube("LST", cube, str); + writecube("LST", cube, STRLENMAX, str); printf("%s\n", str); } } 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 fa80131..1a0f087 100644 --- a/test/024_io_LST_read/io_LST_read_tests.c +++ b/test/024_io_LST_read/io_LST_read_tests.c @@ -16,7 +16,7 @@ void run(void) { } else if (!issolvable(cube)) { printf("Cube is not solvable\n"); } else { - writecube("H48", cube, str); + writecube("H48", cube, NISSY_SIZE_H48, str); printf("%s\n", str); } } diff --git a/test/030_move/move_tests.c b/test/030_move/move_tests.c index d4a109b..2f0ecfb 100644 --- a/test/030_move/move_tests.c +++ b/test/030_move/move_tests.c @@ -17,7 +17,7 @@ void run(void) { } else if (!issolvable(cube)) { printf("Moved cube is not solvable\n"); } else { - writecube("H48", cube, cubestr); + writecube("H48", cube, NISSY_SIZE_H48, cubestr); printf("%s\n", cubestr); } } diff --git a/test/031_premove/premove_tests.c b/test/031_premove/premove_tests.c index fa3707e..07631c1 100644 --- a/test/031_premove/premove_tests.c +++ b/test/031_premove/premove_tests.c @@ -21,7 +21,7 @@ void run(void) { } else if (!issolvable(cube)) { printf("Moved cube is not solvable\n"); } else { - writecube("H48", cube, cubestr); + writecube("H48", cube, NISSY_SIZE_H48, cubestr); printf("%s\n", cubestr); } } diff --git a/test/040_inverse_cube/inverse_tests.c b/test/040_inverse_cube/inverse_tests.c index 4cb7ad1..c1045ab 100644 --- a/test/040_inverse_cube/inverse_tests.c +++ b/test/040_inverse_cube/inverse_tests.c @@ -15,7 +15,7 @@ void run(void) { } else if (!issolvable(inv)) { printf("Inverted cube is not solvable\n"); } else { - writecube("H48", inv, str); + writecube("H48", inv, NISSY_SIZE_H48, str); printf("%s\n", str); } } diff --git a/test/050_compose/compose_tests.c b/test/050_compose/compose_tests.c index e0e65b2..c778838 100644 --- a/test/050_compose/compose_tests.c +++ b/test/050_compose/compose_tests.c @@ -18,7 +18,7 @@ void run(void) { } else if (!issolvable(c3)) { printf("Composed cube is not solvable\n"); } else { - writecube("H48", c3, str); + writecube("H48", c3, NISSY_SIZE_H48, str); printf("%s\n", str); } } diff --git a/test/060_transform/transform_tests.c b/test/060_transform/transform_tests.c index bdb4dc5..80a2031 100644 --- a/test/060_transform/transform_tests.c +++ b/test/060_transform/transform_tests.c @@ -17,7 +17,7 @@ void run(void) { } else if (!issolvable(cube)) { printf("Transformed cube is not solvable\n"); } else { - writecube("H48", cube, cubestr); + writecube("H48", cube, NISSY_SIZE_H48, cubestr); printf("%s\n", cubestr); } } diff --git a/test/075_set_eo/set_eo_tests.c b/test/075_set_eo/set_eo_tests.c index fb2c23e..0c67e87 100644 --- a/test/075_set_eo/set_eo_tests.c +++ b/test/075_set_eo/set_eo_tests.c @@ -30,7 +30,7 @@ void run(void) { fprintf(stderr, "\n"); printf("Setting EO resulted in inconsistent cube\n"); } else { - writecube("H48", cube, str); + writecube("H48", cube, NISSY_SIZE_H48, str); printf("%s\n", str); } } diff --git a/test/076_copy_corners/copy_corners_tests.c b/test/076_copy_corners/copy_corners_tests.c index 7464ecc..d1674fc 100644 --- a/test/076_copy_corners/copy_corners_tests.c +++ b/test/076_copy_corners/copy_corners_tests.c @@ -19,7 +19,7 @@ void run(void) { } else if (!isconsistent(c1)) { printf("Setting EO resulted in inconsistent cube\n"); } else { - writecube("H48", c1, str); + writecube("H48", c1, NISSY_SIZE_H48, str); printf("%s\n", str); } } diff --git a/test/077_copy_edges/copy_edges_tests.c b/test/077_copy_edges/copy_edges_tests.c index 5077861..48c5c53 100644 --- a/test/077_copy_edges/copy_edges_tests.c +++ b/test/077_copy_edges/copy_edges_tests.c @@ -19,7 +19,7 @@ void run(void) { } else if (!isconsistent(c1)) { printf("Setting EO resulted in inconsistent cube\n"); } else { - writecube("H48", c1, str); + writecube("H48", c1, NISSY_SIZE_H48, str); printf("%s\n", str); } } diff --git a/test/081_getcube/getcube_tests.c b/test/081_getcube/getcube_tests.c index 7eb59dc..46c324b 100644 --- a/test/081_getcube/getcube_tests.c +++ b/test/081_getcube/getcube_tests.c @@ -23,7 +23,7 @@ void run(void) { } else if (!isconsistent(cube)) { printf("Inconsistent cube\n"); } else { - writecube("H48", cube, str); + writecube("H48", cube, NISSY_SIZE_H48, str); printf("%s\n", str); } } diff --git a/test/test.h b/test/test.h index b90a399..fe362c7 100644 --- a/test/test.h +++ b/test/test.h @@ -8,6 +8,7 @@ #include #include +#include "../src/nissy.h" #include "../src/arch/arch.h" #include "../src/solvers/tables_types_macros.h" #include "../src/solvers/h48/coordinate_macros.h" @@ -23,8 +24,7 @@ bool isconsistent(cube_t); bool issolvable(cube_t); bool issolved(cube_t); cube_t readcube(char *, char *); -void writecube(char *, cube_t, char *); -void nissy_setlogger(void (*logger_function)(const char *, ...)); +int64_t writecube(char *, cube_t, uint64_t, char *); /* Test function to be implemented by all tests */ void run(void); -- cgit v1.3