nissy-nx

A Rubik's cube optimal solver
git clone https://git.tronto.net/nissy-nx
Download | Log | Files | Refs | README | LICENSE

coord_tests.c (959B)


      1 #include "coord_tests.h"
      2 
      3 bool testmethod_indexes_consistent(void *);
      4 
      5 Test test_indexes_consistent = {
      6 	.name  = "Consitency of index and anti-index",
      7 	.t     = testmethod_indexes_consistent,
      8 	.cases = (void **)all_coordinates,
      9 };
     10 Test *coord_pre_init[] = {
     11 	&test_indexes_consistent,
     12 	NULL
     13 };
     14 TestSuite coord_pre_init_suite = {
     15 	.setup    = NULL,
     16 	.tests    = coord_pre_init,
     17 	.teardown = NULL,
     18 };
     19 
     20 TestSuite *coord_suites[] = {
     21 	&coord_pre_init_suite,
     22 	NULL
     23 };
     24 
     25 bool
     26 testmethod_indexes_consistent(void *a)
     27 {
     28 	uint64_t ui, uj;
     29 	Cube c;
     30 	Coordinate *coord;
     31 
     32 	coord = (Coordinate *)a;
     33 
     34 	if (coord->type != COMP_COORD)
     35 		return true; /* Not applicable */
     36 
     37 	gen_coord(coord);
     38 	for (ui = 0; ui < coord->max; ui++) {
     39 		indexers_makecube(coord->i, ui, &c);
     40 		uj = indexers_getind(coord->i, &c);
     41 		if (ui != uj) {
     42 			fprintf(stderr, "Error with coordinate %s: "
     43 				"%" PRIu64 " != %" PRIu64 "\n",
     44 				coord->name, uj, ui);
     45 			return false;
     46 		}
     47 	}
     48 
     49 	return true;
     50 }