coord_invcoord_h48_tests.c (930B)
1 #include "../test.h" 2 3 size_t gendata_cocsep(unsigned char *, uint64_t *, cube_t *); 4 int64_t coord_h48(cube_t, const uint32_t *, uint8_t); 5 cube_t invcoord_h48(int64_t, const cube_t *, uint8_t); 6 cube_t transform(cube_t, uint8_t); 7 8 void run(void) { 9 char str[STRLENMAX]; 10 int i; 11 bool found; 12 uint8_t h, t; 13 unsigned char buf[2000000]; 14 uint32_t *cocsepdata; 15 uint64_t selfsim[COCSEP_CLASSES]; 16 int64_t c, cc; 17 oriented_cube_t cube; 18 cube_t invc, rep[COCSEP_CLASSES]; 19 20 gendata_cocsep(buf, selfsim, rep); 21 cocsepdata = (uint32_t *)(buf + INFOSIZE); 22 23 i = 1; 24 h = 11; 25 while (fgets(str, STRLENMAX, stdin) != NULL) { 26 cube = readcube(str); 27 c = coord_h48(cube.cube, cocsepdata, h); 28 invc = invcoord_h48(c, rep, h); 29 for (t = 0, found = false; t < 48; t++) { 30 cube.cube = transform(invc, t); 31 cc = coord_h48(cube.cube, cocsepdata, h); 32 found = found || cc == c; 33 } 34 printf("%d %s\n", i, found ? "ok" : "ERROR"); 35 i++; 36 } 37 }