From 455c7d9c8185acdd8c8fe74ad4a59a3e0756d75d Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Sat, 4 Feb 2023 18:00:31 +0100 Subject: Moved coordinate index consistency test to tests folder --- tests/coord_tests.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 tests/coord_tests.c (limited to 'tests/coord_tests.c') diff --git a/tests/coord_tests.c b/tests/coord_tests.c new file mode 100644 index 0000000..8d6b6d3 --- /dev/null +++ b/tests/coord_tests.c @@ -0,0 +1,50 @@ +#include "coord_tests.h" + +bool testmethod_indexes_consistent(void *); + +Test test_indexes_consistent = { + .name = "Consitency of index and anti-index", + .t = testmethod_indexes_consistent, + .cases = (void **)all_coordinates, +}; +Test *coord_pre_init[] = { + &test_indexes_consistent, + NULL +}; +TestSuite coord_pre_init_suite = { + .setup = NULL, + .tests = coord_pre_init, + .teardown = NULL, +}; + +TestSuite *coord_suites[] = { + &coord_pre_init_suite, + NULL +}; + +bool +testmethod_indexes_consistent(void *a) +{ + uint64_t ui, uj; + Cube c; + Coordinate *coord; + + coord = (Coordinate *)a; + + if (coord->type != COMP_COORD) + return true; /* Not applicable */ + + gen_coord(coord); + for (ui = 0; ui < coord->max; ui++) { + indexers_makecube(coord->i, ui, &c); + uj = indexers_getind(coord->i, &c); + if (ui != uj) { + fprintf(stderr, "Error with coordinate %s: " + "%" PRIu64 " != %" PRIu64 "\n", + coord->name, uj, ui); + return false; + } + } + + return true; +} -- cgit v1.3