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

basic_tests.c (809B)


      1 #include "../test.h"
      2 
      3 bool issolved(oriented_cube_t);
      4 bool equal(cube_t, cube_t);
      5 
      6 void
      7 check(oriented_cube_t cube, char *name)
      8 {
      9 	printf("%s is%s solvable\n", name, issolvable(cube) ? "" : " NOT");
     10 	printf("%s is%s solved\n", name, issolved(cube) ? "" : " NOT");
     11 }
     12 
     13 void
     14 check2(oriented_cube_t cube1, char *name1, oriented_cube_t cube2, char *name2)
     15 {
     16 	bool eq = equal(cube1.cube, cube2.cube) &&
     17 	    cube1.orientation == cube2.orientation;
     18 	printf("%s and %s are%s equal\n", name1, name2, eq ? "" : " NOT");
     19 }
     20 
     21 void run(void) {
     22 	oriented_cube_t zero, solved;
     23 
     24 	memset(&zero, 0, sizeof(oriented_cube_t));
     25 	solved = solvedcube();
     26 
     27 	check(solved, "Solved");
     28 	check(zero, "Zero");
     29 
     30 	check2(solved, "Solved", solved, "Solved");
     31 	check2(solved, "Solved", zero, "Zero");
     32 	check2(zero, "Zero", solved, "Solved");
     33 }