h48

A prototype for an optimal Rubik's cube solver, work in progress.
git clone https://git.tronto.net/h48
Download | Log | Files | Refs | README | LICENSE

invcoord_co_tests.c (613B)


      1 #include "../test.h"
      2 
      3 #define POW_3_7 2187
      4 
      5 int64_t coord_co(cube_t);
      6 cube_t invcoord_co(int64_t);
      7 
      8 void run(void) {
      9 	cube_t cube;
     10 	int64_t coord, coord2;
     11 
     12 	/* Test all possible values for CO coordinate */
     13 	for (coord = 0; coord < POW_3_7; coord++) {
     14 		cube = invcoord_co(coord);
     15 
     16 		if (!isconsistent(cube)) {
     17 			printf("Not consistent\n");
     18 			return;
     19 		}
     20 		if (!issolvable(cube)) {
     21 			printf("Not solvable\n");
     22 			return;
     23 		}
     24 
     25 		coord2 = coord_co(cube);
     26 		if (coord != coord2) {
     27 			printf("Error: invcoord of %" PRId64
     28 			    " returns %" PRId64 "\n", coord, coord2);
     29 			return;
     30 		}
     31 	}
     32 
     33 	printf("All good\n");
     34 }