premove_tests.c (616B)
1 #include "../test.h" 2 3 uint8_t readmove(char); 4 uint8_t readmodifier(char); 5 cube_t premove(cube_t, uint8_t); 6 7 void run(void) { 8 char movestr[STRLENMAX], cubestr[STRLENMAX]; 9 uint8_t move; 10 cube_t cube; 11 12 fgets(movestr, STRLENMAX, stdin); 13 move = readmove(movestr[0]) + readmodifier(movestr[1]); 14 fgets(cubestr, STRLENMAX, stdin); 15 cube = readcube("H48", cubestr); 16 17 cube = premove(cube, move); 18 19 if (iserror(cube)) { 20 printf("Error moving cube\n"); 21 } else if (!issolvable(cube)) { 22 printf("Moved cube is not solvable\n"); 23 } else { 24 writecube("H48", cube, NISSY_SIZE_H48, cubestr); 25 printf("%s\n", cubestr); 26 } 27 }