From de6fa5b9122758f261675aa31fe3cb6e7bab92e5 Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Thu, 17 Jul 2025 09:00:38 +0200 Subject: Added unit tests for coord cp and epud --- test/080_invcoord_cp/00_all.in | 0 test/080_invcoord_cp/00_all.out | 1 + test/080_invcoord_cp/invcoord_cp_tests.c | 32 ++++++++++++++++++++++++++++ test/081_invcoord_epud/00_all.in | 0 test/081_invcoord_epud/00_all.out | 1 + test/081_invcoord_epud/invcoord_epud_tests.c | 32 ++++++++++++++++++++++++++++ 6 files changed, 66 insertions(+) create mode 100644 test/080_invcoord_cp/00_all.in create mode 100644 test/080_invcoord_cp/00_all.out create mode 100644 test/080_invcoord_cp/invcoord_cp_tests.c create mode 100644 test/081_invcoord_epud/00_all.in create mode 100644 test/081_invcoord_epud/00_all.out create mode 100644 test/081_invcoord_epud/invcoord_epud_tests.c (limited to 'test') diff --git a/test/080_invcoord_cp/00_all.in b/test/080_invcoord_cp/00_all.in new file mode 100644 index 0000000..e69de29 diff --git a/test/080_invcoord_cp/00_all.out b/test/080_invcoord_cp/00_all.out new file mode 100644 index 0000000..d6109db --- /dev/null +++ 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 new file mode 100644 index 0000000..2eb9ae2 --- /dev/null +++ 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 new file mode 100644 index 0000000..e69de29 diff --git a/test/081_invcoord_epud/00_all.out b/test/081_invcoord_epud/00_all.out new file mode 100644 index 0000000..d6109db --- /dev/null +++ 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 new file mode 100644 index 0000000..bf444cc --- /dev/null +++ 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"); +} -- cgit v1.3