commit ad9bdca9741b5f038610cbe0536131ab0dc7b511 parent 41e31b84a9adeae0b6bdbc4c9438bfa5e782c9da Author: Sebastiano Tronto <sebastiano@tronto.net> Date: Tue, 14 Nov 2023 22:01:38 +0100 Added tests for conversion Diffstat:
8 files changed, 31 insertions(+), 0 deletions(-)
diff --git a/test/00_basic/all.in b/test/000_basic/all.in diff --git a/test/00_basic/all.out b/test/000_basic/all.out diff --git a/test/00_basic/basic_tests.c b/test/000_basic/basic_tests.c diff --git a/test/001_cube_conversion/00_solved.in b/test/001_cube_conversion/00_solved.in @@ -0,0 +1 @@ +UF0 UB0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 diff --git a/test/001_cube_conversion/00_solved.out b/test/001_cube_conversion/00_solved.out @@ -0,0 +1 @@ +UF0 UB0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 diff --git a/test/001_cube_conversion/01_scrambled.in b/test/001_cube_conversion/01_scrambled.in @@ -0,0 +1 @@ +BL1 DB0 UL1 DF0 BR1 UF1 DL0 FL1 UB0 DR1 FR1 UR1 UBR2 UBL1 DFR2 DBL2 DBR0 DFL0 UFR0 UFL2 diff --git a/test/001_cube_conversion/01_scrambled.out b/test/001_cube_conversion/01_scrambled.out @@ -0,0 +1 @@ +BL1 DB0 UL1 DF0 BR1 UF1 DL0 FL1 UB0 DR1 FR1 UR1 UBR2 UBL1 DFR2 DBL2 DBR0 DFL0 UFR0 UFL2 diff --git a/test/001_cube_conversion/cube_conversion_tests.c b/test/001_cube_conversion/cube_conversion_tests.c @@ -0,0 +1,27 @@ +#include "../test.h" + +cube_fast_t cubetofast(cube_t); +cube_t fasttocube(cube_fast_t); +bool equal(cube_t, cube_t); + +int main() { + char cubestr[STRLENMAX]; + cube_t cube, cube2; + cube_fast_t fast; + + fgets(cubestr, STRLENMAX, stdin); + cube = readcube("H48", cubestr); + fast = cubetofast(cube); + cube2 = fasttocube(fast); + + if (iserror(cube)) { + printf("Error reading cube\n"); + } else if (iserror(cube2)) { + printf("Error converting cube\n"); + } else { + writecube("H48", cube2, cubestr); + printf("%s\n", cubestr); + } + + return 0; +}