nissy-core

The "engine" of nissy, including the H48 optimal solver.
git clone https://git.tronto.net/nissy-core
Download | Log | Files | Refs | README | LICENSE

commit de6fa5b9122758f261675aa31fe3cb6e7bab92e5
parent 270e5b0444f67781856bf80db51650af9cb89b0c
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date:   Thu, 17 Jul 2025 09:00:38 +0200

Added unit tests for coord cp and epud

Diffstat:
Atest/080_invcoord_cp/00_all.in | 0
Atest/080_invcoord_cp/00_all.out | 1+
Atest/080_invcoord_cp/invcoord_cp_tests.c | 32++++++++++++++++++++++++++++++++
Atest/081_invcoord_epud/00_all.in | 0
Atest/081_invcoord_epud/00_all.out | 1+
Atest/081_invcoord_epud/invcoord_epud_tests.c | 32++++++++++++++++++++++++++++++++
6 files changed, 66 insertions(+), 0 deletions(-)

diff --git a/test/080_invcoord_cp/00_all.in b/test/080_invcoord_cp/00_all.in diff --git a/test/080_invcoord_cp/00_all.out b/test/080_invcoord_cp/00_all.out @@ -0,0 +1 @@ +All good diff --git a/test/080_invcoord_cp/invcoord_cp_tests.c b/test/080_invcoord_cp/invcoord_cp_tests.c @@ -0,0 +1,32 @@ +#include "../test.h" + +#define FACT_8 40320 + +int64_t coord_cp(cube_t); +cube_t invcoord_cp(int64_t); + +void run(void) { + oriented_cube_t cube; + int64_t coord, coord2; + + cube.orientation = 0; + + /* Test all possible values for CP coordinate */ + for (coord = 0; coord < FACT_8; coord++) { + cube.cube = invcoord_cp(coord); + + if (!isconsistent(cube)) { + printf("Not consistent\n"); + return; + } + + coord2 = coord_cp(cube.cube); + if (coord != coord2) { + printf("Error: invcoord of %" PRId64 + " returns %" PRId64 "\n", coord, coord2); + return; + } + } + + printf("All good\n"); +} diff --git a/test/081_invcoord_epud/00_all.in b/test/081_invcoord_epud/00_all.in diff --git a/test/081_invcoord_epud/00_all.out b/test/081_invcoord_epud/00_all.out @@ -0,0 +1 @@ +All good diff --git a/test/081_invcoord_epud/invcoord_epud_tests.c b/test/081_invcoord_epud/invcoord_epud_tests.c @@ -0,0 +1,32 @@ +#include "../test.h" + +#define FACT_8 40320 + +int64_t coord_epud(cube_t); +cube_t invcoord_epud(int64_t); + +void run(void) { + oriented_cube_t cube; + int64_t coord, coord2; + + cube.orientation = 0; + + /* Test all possible values for CP coordinate */ + for (coord = 0; coord < FACT_8; coord++) { + cube.cube = invcoord_epud(coord); + + if (!isconsistent(cube)) { + printf("Not consistent\n"); + return; + } + + coord2 = coord_epud(cube.cube); + if (coord != coord2) { + printf("Error: invcoord of %" PRId64 + " returns %" PRId64 "\n", coord, coord2); + return; + } + } + + printf("All good\n"); +}