commit 50fedbdbf98bcf01bcd95259ac5a93ae108b3c68 parent 5d0dce810cede2acb0c98aa113e3f568209a97b1 Author: Sebastiano Tronto <sebastiano@tronto.net> Date: Fri, 28 Mar 2025 16:48:03 +0100 Make invcoord_co test more comprehensive Diffstat:
29 files changed, 22 insertions(+), 41 deletions(-)
diff --git a/test/079_invcoord_co/00_all.in b/test/079_invcoord_co/00_all.in diff --git a/test/079_invcoord_co/00_all.out b/test/079_invcoord_co/00_all.out @@ -0,0 +1 @@ +All good diff --git a/test/079_invcoord_co/00_solved.in b/test/079_invcoord_co/00_solved.in @@ -1 +0,0 @@ -0 diff --git a/test/079_invcoord_co/00_solved.out b/test/079_invcoord_co/00_solved.out @@ -1 +0,0 @@ -0 diff --git a/test/079_invcoord_co/01_U.in b/test/079_invcoord_co/01_U.in @@ -1 +0,0 @@ -0 diff --git a/test/079_invcoord_co/01_U.out b/test/079_invcoord_co/01_U.out @@ -1 +0,0 @@ -0 diff --git a/test/079_invcoord_co/02_U2.in b/test/079_invcoord_co/02_U2.in @@ -1 +0,0 @@ -0 diff --git a/test/079_invcoord_co/02_U2.out b/test/079_invcoord_co/02_U2.out @@ -1 +0,0 @@ -0 diff --git a/test/079_invcoord_co/03_U3.in b/test/079_invcoord_co/03_U3.in @@ -1 +0,0 @@ -0 diff --git a/test/079_invcoord_co/03_U3.out b/test/079_invcoord_co/03_U3.out @@ -1 +0,0 @@ -0 diff --git a/test/079_invcoord_co/04_D.in b/test/079_invcoord_co/04_D.in @@ -1 +0,0 @@ -0 diff --git a/test/079_invcoord_co/04_D.out b/test/079_invcoord_co/04_D.out @@ -1 +0,0 @@ -0 diff --git a/test/079_invcoord_co/07_R.in b/test/079_invcoord_co/07_R.in @@ -1 +0,0 @@ -1028 diff --git a/test/079_invcoord_co/07_R.out b/test/079_invcoord_co/07_R.out @@ -1 +0,0 @@ -1028 diff --git a/test/079_invcoord_co/08_R2.in b/test/079_invcoord_co/08_R2.in @@ -1 +0,0 @@ -0 diff --git a/test/079_invcoord_co/08_R2.out b/test/079_invcoord_co/08_R2.out @@ -1 +0,0 @@ -0 diff --git a/test/079_invcoord_co/10_L.in b/test/079_invcoord_co/10_L.in @@ -1 +0,0 @@ -105 diff --git a/test/079_invcoord_co/10_L.out b/test/079_invcoord_co/10_L.out @@ -1 +0,0 @@ -105 diff --git a/test/079_invcoord_co/13_F.in b/test/079_invcoord_co/13_F.in @@ -1 +0,0 @@ -1630 diff --git a/test/079_invcoord_co/13_F.out b/test/079_invcoord_co/13_F.out @@ -1 +0,0 @@ -1630 diff --git a/test/079_invcoord_co/14_F2.in b/test/079_invcoord_co/14_F2.in @@ -1 +0,0 @@ -0 diff --git a/test/079_invcoord_co/14_F2.out b/test/079_invcoord_co/14_F2.out @@ -1 +0,0 @@ -0 diff --git a/test/079_invcoord_co/16_B.in b/test/079_invcoord_co/16_B.in @@ -1 +0,0 @@ -516 diff --git a/test/079_invcoord_co/16_B.out b/test/079_invcoord_co/16_B.out @@ -1 +0,0 @@ -516 diff --git a/test/079_invcoord_co/17_B2.in b/test/079_invcoord_co/17_B2.in @@ -1 +0,0 @@ -0 diff --git a/test/079_invcoord_co/17_B2.out b/test/079_invcoord_co/17_B2.out @@ -1 +0,0 @@ -0 diff --git a/test/079_invcoord_co/20_scrambled.in b/test/079_invcoord_co/20_scrambled.in @@ -1 +0,0 @@ -957 diff --git a/test/079_invcoord_co/20_scrambled.out b/test/079_invcoord_co/20_scrambled.out @@ -1 +0,0 @@ -957 diff --git a/test/079_invcoord_co/invcoord_co_tests.c b/test/079_invcoord_co/invcoord_co_tests.c @@ -1,28 +1,34 @@ #include "../test.h" +#define POW_3_7 2187 + int64_t coord_co(cube_t); cube_t invcoord_co(int64_t); void run(void) { - char str[STRLENMAX]; cube_t cube; - int64_t coord; + int64_t coord, coord2; - fgets(str, STRLENMAX, stdin); - coord = atoll(str); + /* Test all possible values for CO coordinate */ + for (coord = 0; coord < POW_3_7; coord++) { + cube = invcoord_co(coord); - cube = invcoord_co(coord); + if (!isconsistent(cube)) { + printf("Not consistent\n"); + return; + } + if (!issolvable(cube)) { + printf("Not solvable\n"); + return; + } - if (!isconsistent(cube)) { - printf("Not consistent\n"); - return; - } - if (!issolvable(cube)) { - printf("Not solvable\n"); - return; + coord2 = coord_co(cube); + if (coord != coord2) { + printf("Error: invcoord of %" PRId64 + " returns %" PRId64 "\n", coord, coord2); + return; + } } - coord = coord_co(cube); - - printf("%" PRId64 "\n", coord); + printf("All good\n"); }