diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2025-04-22 16:12:21 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2025-04-22 16:12:21 +0200 |
| commit | bab22e1946a656088804b61cf765461b48744971 (patch) | |
| tree | 43ae3798e5c2f4fc63e68df72d134e742fcaf834 | |
| parent | 93522effba2f200257141189de5925a23fca93b8 (diff) | |
| download | nissy-core-bab22e1946a656088804b61cf765461b48744971.tar.gz nissy-core-bab22e1946a656088804b61cf765461b48744971.zip | |
Update tests for oriented_cube_t
Diffstat (limited to '')
38 files changed, 196 insertions, 142 deletions
diff --git a/src/core/core.h b/src/core/core.h index fce1751..c211788 100644 --- a/src/core/core.h +++ b/src/core/core.h | |||
| @@ -1,3 +1,4 @@ | |||
| 1 | #include "core_types.h" | ||
| 1 | #include "constant_cubes.h" | 2 | #include "constant_cubes.h" |
| 2 | #include "cube.h" | 3 | #include "cube.h" |
| 3 | #include "moves.h" | 4 | #include "moves.h" |
diff --git a/src/core/core_types.h b/src/core/core_types.h new file mode 100644 index 0000000..2ad8938 --- /dev/null +++ b/src/core/core_types.h | |||
| @@ -0,0 +1,4 @@ | |||
| 1 | typedef struct { | ||
| 2 | cube_t cube; | ||
| 3 | uint8_t orientation; | ||
| 4 | } oriented_cube_t; | ||
diff --git a/src/core/cube.h b/src/core/cube.h index a045e55..76c3ff1 100644 --- a/src/core/cube.h +++ b/src/core/cube.h | |||
| @@ -1,17 +1,33 @@ | |||
| 1 | STATIC cube_t solvedcube(void); | 1 | #define ZERO_ORIENTED_CUBE ((oriented_cube_t) {0}) |
| 2 | #define SOLVED_ORIENTED_CUBE \ | ||
| 3 | ((oriented_cube_t) { .cube = SOLVED_CUBE, .orientation = 0 }) | ||
| 4 | |||
| 5 | STATIC oriented_cube_t solvedcube(void); | ||
| 2 | STATIC cube_t cubefromarray(uint8_t [static 8], uint8_t [static 12]); | 6 | STATIC cube_t cubefromarray(uint8_t [static 8], uint8_t [static 12]); |
| 3 | STATIC bool isconsistent(cube_t); | 7 | STATIC bool isconsistent(oriented_cube_t); |
| 4 | STATIC bool issolvable(cube_t); | 8 | STATIC bool issolvable(oriented_cube_t); |
| 5 | STATIC bool issolved(cube_t); | 9 | STATIC bool issolved(oriented_cube_t); |
| 6 | STATIC bool iserror(cube_t); | 10 | STATIC bool iserror(oriented_cube_t); |
| 7 | STATIC void getcube_fix(long long *, long long *, long long *, long long *); | 11 | STATIC void getcube_fix(long long *, long long *, long long *, long long *); |
| 8 | STATIC cube_t getcube(int64_t, int64_t, int64_t, int64_t); | 12 | STATIC cube_t getcube(int64_t, int64_t, int64_t, int64_t); |
| 9 | 13 | ||
| 10 | /* This is used only in tests, use SOLVED_CUBE directly everywhere else */ | 14 | STATIC oriented_cube_t readcube(const char *); |
| 11 | STATIC cube_t | 15 | STATIC int64_t writecube(oriented_cube_t, size_t n, char [n]); |
| 16 | STATIC uint8_t readco(const char *); | ||
| 17 | STATIC uint8_t readcp(const char *); | ||
| 18 | STATIC uint8_t readeo(const char *); | ||
| 19 | STATIC uint8_t readep(const char *); | ||
| 20 | |||
| 21 | STATIC uint8_t b32toedge(char); | ||
| 22 | STATIC uint8_t b32tocorner(char); | ||
| 23 | STATIC char edgetob32(uint8_t); | ||
| 24 | STATIC char cornertob32(uint8_t); | ||
| 25 | |||
| 26 | /* This is used only in tests, use SOLVED_ORIENTED_CUBE everywhere else */ | ||
| 27 | STATIC oriented_cube_t | ||
| 12 | solvedcube(void) | 28 | solvedcube(void) |
| 13 | { | 29 | { |
| 14 | return SOLVED_CUBE; | 30 | return SOLVED_ORIENTED_CUBE; |
| 15 | } | 31 | } |
| 16 | 32 | ||
| 17 | STATIC cube_t | 33 | STATIC cube_t |
| @@ -24,12 +40,12 @@ cubefromarray(uint8_t c[static 8], uint8_t e[static 12]) | |||
| 24 | } | 40 | } |
| 25 | 41 | ||
| 26 | STATIC bool | 42 | STATIC bool |
| 27 | isconsistent(cube_t cube) | 43 | isconsistent(oriented_cube_t cube) |
| 28 | { | 44 | { |
| 29 | uint8_t i, p, e, piece, corner[8], edge[12]; | 45 | uint8_t i, p, e, piece, corner[8], edge[12]; |
| 30 | bool found[12]; | 46 | bool found[12]; |
| 31 | 47 | ||
| 32 | pieces(&cube, corner, edge); | 48 | pieces(&cube.cube, corner, edge); |
| 33 | 49 | ||
| 34 | for (i = 0; i < 12; i++) | 50 | for (i = 0; i < 12; i++) |
| 35 | found[i] = false; | 51 | found[i] = false; |
| @@ -63,25 +79,29 @@ isconsistent(cube_t cube) | |||
| 63 | if (!found[i]) | 79 | if (!found[i]) |
| 64 | goto inconsistent_cp; | 80 | goto inconsistent_cp; |
| 65 | 81 | ||
| 82 | if (cube.orientation >= 24) | ||
| 83 | goto inconsistent_orientation; | ||
| 84 | |||
| 66 | return true; | 85 | return true; |
| 67 | 86 | ||
| 68 | inconsistent_ep: | 87 | inconsistent_ep: |
| 69 | inconsistent_cp: | 88 | inconsistent_cp: |
| 70 | inconsistent_eo: | 89 | inconsistent_eo: |
| 71 | inconsistent_co: | 90 | inconsistent_co: |
| 72 | /* We used to do more logging here, hence the 4 different labels */ | 91 | inconsistent_orientation: |
| 92 | /* We used to do more logging here, hence the different labels */ | ||
| 73 | return false; | 93 | return false; |
| 74 | } | 94 | } |
| 75 | 95 | ||
| 76 | STATIC bool | 96 | STATIC bool |
| 77 | issolvable(cube_t cube) | 97 | issolvable(oriented_cube_t cube) |
| 78 | { | 98 | { |
| 79 | uint8_t i, eo, co, piece, edge[12], corner[8], ep[12], cp[8]; | 99 | uint8_t i, eo, co, piece, edge[12], corner[8], ep[12], cp[8]; |
| 80 | 100 | ||
| 81 | DBG_ASSERT(isconsistent(cube), false, | 101 | DBG_ASSERT(isconsistent(cube), false, |
| 82 | "issolvable: cube is inconsistent\n"); | 102 | "issolvable: cube is inconsistent\n"); |
| 83 | 103 | ||
| 84 | pieces(&cube, corner, edge); | 104 | pieces(&cube.cube, corner, edge); |
| 85 | for (i = 0; i < 12; i++) | 105 | for (i = 0; i < 12; i++) |
| 86 | ep[i] = edge[i] & PBITS; | 106 | ep[i] = edge[i] & PBITS; |
| 87 | for (i = 0; i < 8; i++) | 107 | for (i = 0; i < 8; i++) |
| @@ -120,15 +140,15 @@ issolvable_co: | |||
| 120 | } | 140 | } |
| 121 | 141 | ||
| 122 | bool | 142 | bool |
| 123 | issolved(cube_t cube) | 143 | issolved(oriented_cube_t cube) |
| 124 | { | 144 | { |
| 125 | return equal(cube, SOLVED_CUBE); | 145 | return equal(cube.cube, SOLVED_CUBE); |
| 126 | } | 146 | } |
| 127 | 147 | ||
| 128 | bool | 148 | bool |
| 129 | iserror(cube_t cube) | 149 | iserror(oriented_cube_t cube) |
| 130 | { | 150 | { |
| 131 | return equal(cube, ZERO_CUBE); | 151 | return equal(cube.cube, ZERO_CUBE); |
| 132 | } | 152 | } |
| 133 | 153 | ||
| 134 | STATIC void | 154 | STATIC void |
| @@ -175,21 +195,6 @@ getcube(int64_t ep, int64_t eo, int64_t cp, int64_t co) | |||
| 175 | return cubefromarray(carr, earr); | 195 | return cubefromarray(carr, earr); |
| 176 | } | 196 | } |
| 177 | 197 | ||
| 178 | |||
| 179 | /******************************************************************************/ | ||
| 180 | |||
| 181 | STATIC cube_t readcube(const char *); | ||
| 182 | STATIC int64_t writecube(cube_t, size_t n, char [n]); | ||
| 183 | STATIC uint8_t readco(const char *); | ||
| 184 | STATIC uint8_t readcp(const char *); | ||
| 185 | STATIC uint8_t readeo(const char *); | ||
| 186 | STATIC uint8_t readep(const char *); | ||
| 187 | |||
| 188 | STATIC uint8_t b32toedge(char); | ||
| 189 | STATIC uint8_t b32tocorner(char); | ||
| 190 | STATIC char edgetob32(uint8_t); | ||
| 191 | STATIC char cornertob32(uint8_t); | ||
| 192 | |||
| 193 | STATIC uint8_t | 198 | STATIC uint8_t |
| 194 | readco(const char *str) | 199 | readco(const char *str) |
| 195 | { | 200 | { |
| @@ -243,11 +248,11 @@ readep(const char *str) | |||
| 243 | return UINT8_ERROR; | 248 | return UINT8_ERROR; |
| 244 | } | 249 | } |
| 245 | 250 | ||
| 246 | STATIC cube_t | 251 | STATIC oriented_cube_t |
| 247 | readcube(const char *buf) | 252 | readcube(const char *buf) |
| 248 | { | 253 | { |
| 249 | int i; | 254 | int i; |
| 250 | uint8_t c[8], e[12]; | 255 | uint8_t c[8], e[12], orientation; |
| 251 | 256 | ||
| 252 | for (i = 0; i < 8; i++) { | 257 | for (i = 0; i < 8; i++) { |
| 253 | c[i] = b32tocorner(buf[i]); | 258 | c[i] = b32tocorner(buf[i]); |
| @@ -258,14 +263,14 @@ readcube(const char *buf) | |||
| 258 | } else { | 263 | } else { |
| 259 | LOG("(char '%c')\n", buf[i]); | 264 | LOG("(char '%c')\n", buf[i]); |
| 260 | } | 265 | } |
| 261 | return ZERO_CUBE; | 266 | return ZERO_ORIENTED_CUBE; |
| 262 | } | 267 | } |
| 263 | } | 268 | } |
| 264 | 269 | ||
| 265 | if (buf[8] != '=') { | 270 | if (buf[8] != '=') { |
| 266 | LOG("Error reading separator: a single '=' " | 271 | LOG("Error reading separator: a single '=' " |
| 267 | "must be used to separate edges and corners\n"); | 272 | "must be used to separate edges and corners\n"); |
| 268 | return ZERO_CUBE; | 273 | return ZERO_ORIENTED_CUBE; |
| 269 | } | 274 | } |
| 270 | 275 | ||
| 271 | for (i = 0; i < 12; i++) { | 276 | for (i = 0; i < 12; i++) { |
| @@ -277,15 +282,25 @@ readcube(const char *buf) | |||
| 277 | } else { | 282 | } else { |
| 278 | LOG("(char '%c')\n", buf[i+9]); | 283 | LOG("(char '%c')\n", buf[i+9]); |
| 279 | } | 284 | } |
| 280 | return ZERO_CUBE; | 285 | return ZERO_ORIENTED_CUBE; |
| 281 | } | 286 | } |
| 282 | } | 287 | } |
| 283 | 288 | ||
| 284 | return cubefromarray(c, e); | 289 | orientation = (uint8_t)(buf[22] - 'A'); |
| 290 | if (orientation >= 24) { | ||
| 291 | LOG("Error reading orientation: impossible value %" PRIu8 | ||
| 292 | " (%c)\n", orientation, buf[22]); | ||
| 293 | return ZERO_ORIENTED_CUBE; | ||
| 294 | } | ||
| 295 | |||
| 296 | return (oriented_cube_t) { | ||
| 297 | .cube = cubefromarray(c, e), | ||
| 298 | .orientation = orientation | ||
| 299 | }; | ||
| 285 | } | 300 | } |
| 286 | 301 | ||
| 287 | STATIC int64_t | 302 | STATIC int64_t |
| 288 | writecube(cube_t cube, size_t buf_size, char buf[buf_size]) | 303 | writecube(oriented_cube_t cube, size_t buf_size, char buf[buf_size]) |
| 289 | { | 304 | { |
| 290 | int i; | 305 | int i; |
| 291 | uint8_t corner[8], edge[12]; | 306 | uint8_t corner[8], edge[12]; |
| @@ -297,7 +312,7 @@ writecube(cube_t cube, size_t buf_size, char buf[buf_size]) | |||
| 297 | return NISSY_ERROR_BUFFER_SIZE; | 312 | return NISSY_ERROR_BUFFER_SIZE; |
| 298 | } | 313 | } |
| 299 | 314 | ||
| 300 | pieces(&cube, corner, edge); | 315 | pieces(&cube.cube, corner, edge); |
| 301 | 316 | ||
| 302 | for (i = 0; i < 8; i++) | 317 | for (i = 0; i < 8; i++) |
| 303 | buf[i] = cornertob32(corner[i]); | 318 | buf[i] = cornertob32(corner[i]); |
| @@ -307,9 +322,8 @@ writecube(cube_t cube, size_t buf_size, char buf[buf_size]) | |||
| 307 | for (i = 0; i < 12; i++) | 322 | for (i = 0; i < 12; i++) |
| 308 | buf[i+9] = edgetob32(edge[i]); | 323 | buf[i+9] = edgetob32(edge[i]); |
| 309 | 324 | ||
| 310 | /* TODO */ | ||
| 311 | buf[21] = '='; | 325 | buf[21] = '='; |
| 312 | buf[22] = 'A'; | 326 | buf[22] = (char)cube.orientation + 'A'; |
| 313 | buf[23] = '\0'; | 327 | buf[23] = '\0'; |
| 314 | 328 | ||
| 315 | return NISSY_OK; | 329 | return NISSY_OK; |
| @@ -351,4 +365,3 @@ cornertob32(uint8_t corner) | |||
| 351 | 365 | ||
| 352 | return val < 26 ? 'A' + (char)val : 'a' + (char)(val - 26); | 366 | return val < 26 ? 'A' + (char)val : 'a' + (char)(val - 26); |
| 353 | } | 367 | } |
| 354 | /******************************************************************************/ | ||
diff --git a/src/core/moves.h b/src/core/moves.h index 8f91167..7e80946 100644 --- a/src/core/moves.h +++ b/src/core/moves.h | |||
| @@ -21,7 +21,7 @@ STATIC uint8_t inverse_move(uint8_t); | |||
| 21 | STATIC void sortparallel_moves(size_t n, uint8_t [n]); | 21 | STATIC void sortparallel_moves(size_t n, uint8_t [n]); |
| 22 | STATIC bool are_lastmoves_singlecw(size_t n, const uint8_t [n]); | 22 | STATIC bool are_lastmoves_singlecw(size_t n, const uint8_t [n]); |
| 23 | 23 | ||
| 24 | STATIC cube_t applymoves(cube_t, const char *); | 24 | STATIC oriented_cube_t applymoves(oriented_cube_t, const char *); |
| 25 | 25 | ||
| 26 | #define FOREACH_READMOVE(ARG_BUF, ARG_MOVE, ARG_C, ARG_MAX, \ | 26 | #define FOREACH_READMOVE(ARG_BUF, ARG_MOVE, ARG_C, ARG_MAX, \ |
| 27 | RET_ERROR, ARG_ACTION) \ | 27 | RET_ERROR, ARG_ACTION) \ |
| @@ -319,17 +319,17 @@ are_lastmoves_singlecw(size_t n, const uint8_t moves[n]) | |||
| 319 | return isbase(moves[n-1]) && (!two || isbase(moves[n-2])); | 319 | return isbase(moves[n-1]) && (!two || isbase(moves[n-2])); |
| 320 | } | 320 | } |
| 321 | 321 | ||
| 322 | STATIC cube_t | 322 | STATIC oriented_cube_t |
| 323 | applymoves(cube_t cube, const char *buf) | 323 | applymoves(oriented_cube_t cube, const char *buf) |
| 324 | { | 324 | { |
| 325 | int c; | 325 | int c; |
| 326 | uint8_t m; | 326 | uint8_t m; |
| 327 | 327 | ||
| 328 | DBG_ASSERT(isconsistent(cube), ZERO_CUBE, | 328 | DBG_ASSERT(isconsistent(cube), ZERO_ORIENTED_CUBE, |
| 329 | "move error: inconsistent cube\n"); | 329 | "move error: inconsistent cube\n"); |
| 330 | 330 | ||
| 331 | FOREACH_READMOVE(buf, m, c, -1, ZERO_CUBE, | 331 | FOREACH_READMOVE(buf, m, c, -1, ZERO_ORIENTED_CUBE, |
| 332 | cube = move(cube, m); | 332 | cube.cube = move(cube.cube, m); |
| 333 | ) | 333 | ) |
| 334 | 334 | ||
| 335 | return cube; | 335 | return cube; |
diff --git a/src/core/transform.h b/src/core/transform.h index 28b8d93..763a4ae 100644 --- a/src/core/transform.h +++ b/src/core/transform.h | |||
| @@ -23,7 +23,7 @@ STATIC void writetrans(uint8_t, char [static NISSY_SIZE_TRANSFORMATION]); | |||
| 23 | STATIC cube_t transform_edges(cube_t, uint8_t); | 23 | STATIC cube_t transform_edges(cube_t, uint8_t); |
| 24 | STATIC cube_t transform_corners(cube_t, uint8_t); | 24 | STATIC cube_t transform_corners(cube_t, uint8_t); |
| 25 | STATIC cube_t transform(cube_t, uint8_t); | 25 | STATIC cube_t transform(cube_t, uint8_t); |
| 26 | STATIC cube_t applytrans(cube_t, const char *); | 26 | STATIC oriented_cube_t applytrans(oriented_cube_t, const char *); |
| 27 | STATIC_INLINE uint8_t inverse_trans(uint8_t); | 27 | STATIC_INLINE uint8_t inverse_trans(uint8_t); |
| 28 | STATIC uint8_t transform_move(uint8_t, uint8_t); | 28 | STATIC uint8_t transform_move(uint8_t, uint8_t); |
| 29 | STATIC uint64_t symmetry_mask(cube_t); | 29 | STATIC uint64_t symmetry_mask(cube_t); |
| @@ -367,12 +367,12 @@ transform(cube_t c, uint8_t t) | |||
| 367 | } | 367 | } |
| 368 | } | 368 | } |
| 369 | 369 | ||
| 370 | STATIC cube_t | 370 | STATIC oriented_cube_t |
| 371 | applytrans(cube_t cube, const char *buf) | 371 | applytrans(oriented_cube_t cube, const char *buf) |
| 372 | { | 372 | { |
| 373 | uint8_t t; | 373 | uint8_t t; |
| 374 | 374 | ||
| 375 | DBG_ASSERT(isconsistent(cube), ZERO_CUBE, | 375 | DBG_ASSERT(isconsistent(cube), ZERO_ORIENTED_CUBE, |
| 376 | "transformation error: inconsistent cube\n"); | 376 | "transformation error: inconsistent cube\n"); |
| 377 | 377 | ||
| 378 | t = readtrans(buf); | 378 | t = readtrans(buf); |
| @@ -380,7 +380,10 @@ applytrans(cube_t cube, const char *buf) | |||
| 380 | if (t == UINT8_ERROR) | 380 | if (t == UINT8_ERROR) |
| 381 | LOG("Unknown transformation: %s\n", buf); | 381 | LOG("Unknown transformation: %s\n", buf); |
| 382 | 382 | ||
| 383 | return transform(cube, t); | 383 | return (oriented_cube_t){ |
| 384 | .cube = transform(cube.cube, t), | ||
| 385 | .orientation = cube.orientation | ||
| 386 | }; | ||
| 384 | } | 387 | } |
| 385 | 388 | ||
| 386 | STATIC_INLINE uint8_t | 389 | STATIC_INLINE uint8_t |
diff --git a/src/nissy.c b/src/nissy.c index bf56f40..27f2b35 100644 --- a/src/nissy.c +++ b/src/nissy.c | |||
| @@ -17,7 +17,7 @@ long long parse_h48_solver( | |||
| 17 | STATIC bool checkdata(const unsigned char *, const tableinfo_t [static 1]); | 17 | STATIC bool checkdata(const unsigned char *, const tableinfo_t [static 1]); |
| 18 | STATIC bool distribution_equal(const uint64_t [static INFO_DISTRIBUTION_LEN], | 18 | STATIC bool distribution_equal(const uint64_t [static INFO_DISTRIBUTION_LEN], |
| 19 | const uint64_t [static INFO_DISTRIBUTION_LEN], uint8_t); | 19 | const uint64_t [static INFO_DISTRIBUTION_LEN], uint8_t); |
| 20 | STATIC long long write_result(cube_t, char [static NISSY_SIZE_CUBE]); | 20 | STATIC long long write_result(oriented_cube_t, char [static NISSY_SIZE_CUBE]); |
| 21 | STATIC size_t my_strnlen(const char *, size_t); | 21 | STATIC size_t my_strnlen(const char *, size_t); |
| 22 | STATIC long long nissy_dataid(const char *, char [static NISSY_SIZE_DATAID]); | 22 | STATIC long long nissy_dataid(const char *, char [static NISSY_SIZE_DATAID]); |
| 23 | STATIC long long nissy_gendata_unsafe( | 23 | STATIC long long nissy_gendata_unsafe( |
| @@ -117,7 +117,7 @@ distribution_equal( | |||
| 117 | } | 117 | } |
| 118 | 118 | ||
| 119 | STATIC long long | 119 | STATIC long long |
| 120 | write_result(cube_t cube, char result[static NISSY_SIZE_CUBE]) | 120 | write_result(oriented_cube_t cube, char result[static NISSY_SIZE_CUBE]) |
| 121 | { | 121 | { |
| 122 | writecube(cube, NISSY_SIZE_CUBE, result); | 122 | writecube(cube, NISSY_SIZE_CUBE, result); |
| 123 | 123 | ||
| @@ -147,7 +147,7 @@ nissy_inverse( | |||
| 147 | char result[static NISSY_SIZE_CUBE] | 147 | char result[static NISSY_SIZE_CUBE] |
| 148 | ) | 148 | ) |
| 149 | { | 149 | { |
| 150 | cube_t c, res; | 150 | oriented_cube_t c, res; |
| 151 | long long err; | 151 | long long err; |
| 152 | 152 | ||
| 153 | c = readcube(cube); | 153 | c = readcube(cube); |
| @@ -158,7 +158,10 @@ nissy_inverse( | |||
| 158 | goto nissy_inverse_error; | 158 | goto nissy_inverse_error; |
| 159 | } | 159 | } |
| 160 | 160 | ||
| 161 | res = inverse(c); | 161 | res = (oriented_cube_t) { |
| 162 | .cube = inverse(c.cube), | ||
| 163 | .orientation = c.orientation | ||
| 164 | }; | ||
| 162 | 165 | ||
| 163 | if (!isconsistent(res)) { | 166 | if (!isconsistent(res)) { |
| 164 | LOG("[inverse] Unknown error: inverted cube is invalid\n"); | 167 | LOG("[inverse] Unknown error: inverted cube is invalid\n"); |
| @@ -169,7 +172,7 @@ nissy_inverse( | |||
| 169 | return write_result(res, result); | 172 | return write_result(res, result); |
| 170 | 173 | ||
| 171 | nissy_inverse_error: | 174 | nissy_inverse_error: |
| 172 | writecube(ZERO_CUBE, NISSY_SIZE_CUBE, result); | 175 | writecube(ZERO_ORIENTED_CUBE, NISSY_SIZE_CUBE, result); |
| 173 | return err; | 176 | return err; |
| 174 | } | 177 | } |
| 175 | 178 | ||
| @@ -180,7 +183,7 @@ nissy_applymoves( | |||
| 180 | char result[static NISSY_SIZE_CUBE] | 183 | char result[static NISSY_SIZE_CUBE] |
| 181 | ) | 184 | ) |
| 182 | { | 185 | { |
| 183 | cube_t c, res; | 186 | oriented_cube_t c, res; |
| 184 | long long err; | 187 | long long err; |
| 185 | 188 | ||
| 186 | if (moves == NULL) { | 189 | if (moves == NULL) { |
| @@ -208,7 +211,7 @@ nissy_applymoves( | |||
| 208 | return write_result(res, result); | 211 | return write_result(res, result); |
| 209 | 212 | ||
| 210 | nissy_applymoves_error: | 213 | nissy_applymoves_error: |
| 211 | writecube(ZERO_CUBE, NISSY_SIZE_CUBE, result); | 214 | writecube(ZERO_ORIENTED_CUBE, NISSY_SIZE_CUBE, result); |
| 212 | return err; | 215 | return err; |
| 213 | } | 216 | } |
| 214 | 217 | ||
| @@ -219,7 +222,7 @@ nissy_applytrans( | |||
| 219 | char result[static NISSY_SIZE_CUBE] | 222 | char result[static NISSY_SIZE_CUBE] |
| 220 | ) | 223 | ) |
| 221 | { | 224 | { |
| 222 | cube_t c, res; | 225 | oriented_cube_t c, res; |
| 223 | long long err; | 226 | long long err; |
| 224 | 227 | ||
| 225 | c = readcube(cube); | 228 | c = readcube(cube); |
| @@ -241,7 +244,7 @@ nissy_applytrans( | |||
| 241 | return write_result(res, result); | 244 | return write_result(res, result); |
| 242 | 245 | ||
| 243 | nissy_applytrans_error: | 246 | nissy_applytrans_error: |
| 244 | writecube(ZERO_CUBE, NISSY_SIZE_CUBE, result); | 247 | writecube(ZERO_ORIENTED_CUBE, NISSY_SIZE_CUBE, result); |
| 245 | return err; | 248 | return err; |
| 246 | } | 249 | } |
| 247 | 250 | ||
| @@ -269,13 +272,14 @@ nissy_getcube( | |||
| 269 | 272 | ||
| 270 | c = getcube(ep, eo, cp, co); | 273 | c = getcube(ep, eo, cp, co); |
| 271 | 274 | ||
| 272 | if (!isconsistent(c)) { | 275 | if (!isconsistent((oriented_cube_t){ .cube = c, .orientation = 0 })) { |
| 273 | LOG("[getcube] Error: could not get cube with ep=%lld, " | 276 | LOG("[getcube] Error: could not get cube with ep=%lld, " |
| 274 | "eo=%lld, cp=%lld, co=%lld.\n", ep, eo, cp, co); | 277 | "eo=%lld, cp=%lld, co=%lld.\n", ep, eo, cp, co); |
| 275 | return NISSY_ERROR_OPTIONS; | 278 | return NISSY_ERROR_OPTIONS; |
| 276 | } | 279 | } |
| 277 | 280 | ||
| 278 | return write_result(c, result); | 281 | /* TODO: should support orientation */ |
| 282 | return write_result((oriented_cube_t){.cube = c, .orientation = 0}, result); | ||
| 279 | } | 283 | } |
| 280 | 284 | ||
| 281 | long long | 285 | long long |
| @@ -456,6 +460,7 @@ nissy_solve( | |||
| 456 | long long stats[static NISSY_SIZE_SOLVE_STATS] | 460 | long long stats[static NISSY_SIZE_SOLVE_STATS] |
| 457 | ) | 461 | ) |
| 458 | { | 462 | { |
| 463 | oriented_cube_t oc; | ||
| 459 | cube_t c; | 464 | cube_t c; |
| 460 | long long parse_ret; | 465 | long long parse_ret; |
| 461 | uint8_t h, k; | 466 | uint8_t h, k; |
| @@ -466,14 +471,17 @@ nissy_solve( | |||
| 466 | return NISSY_ERROR_NULL_POINTER; | 471 | return NISSY_ERROR_NULL_POINTER; |
| 467 | } | 472 | } |
| 468 | 473 | ||
| 469 | c = readcube(cube); | 474 | oc = readcube(cube); |
| 475 | c = oc.cube; | ||
| 470 | 476 | ||
| 471 | if (!isconsistent(c)) { | 477 | /* TODO: solve should handle oriented cubes */ |
| 478 | |||
| 479 | if (!isconsistent(oc)) { | ||
| 472 | LOG("[solve] Error: cube is invalid\n"); | 480 | LOG("[solve] Error: cube is invalid\n"); |
| 473 | return NISSY_ERROR_INVALID_CUBE; | 481 | return NISSY_ERROR_INVALID_CUBE; |
| 474 | } | 482 | } |
| 475 | 483 | ||
| 476 | if (!issolvable(c)) { | 484 | if (!issolvable((oriented_cube_t){ .cube = c, .orientation = 0})) { |
| 477 | /* TODO: this is step-dependent */ | 485 | /* TODO: this is step-dependent */ |
| 478 | LOG("[solve] Error: cube is not solvable\n"); | 486 | LOG("[solve] Error: cube is not solvable\n"); |
| 479 | return NISSY_ERROR_UNSOLVABLE_CUBE; | 487 | return NISSY_ERROR_UNSOLVABLE_CUBE; |
diff --git a/src/solvers/h48/solve.h b/src/solvers/h48/solve.h index cf7095c..d19309b 100644 --- a/src/solvers/h48/solve.h +++ b/src/solvers/h48/solve.h | |||
| @@ -155,7 +155,7 @@ solve_h48_dfs(dfsarg_solve_h48_t arg[static 1]) | |||
| 155 | bool ulbi, ulbn; | 155 | bool ulbi, ulbn; |
| 156 | cube_t backup_cube, backup_inverse; | 156 | cube_t backup_cube, backup_inverse; |
| 157 | 157 | ||
| 158 | if (issolved(arg->cube)) { | 158 | if (equal(arg->cube, SOLVED_CUBE)) { |
| 159 | nm = arg->solution_moves->nmoves | 159 | nm = arg->solution_moves->nmoves |
| 160 | + arg->solution_moves->npremoves; | 160 | + arg->solution_moves->npremoves; |
| 161 | if (arg->target_depth != nm) | 161 | if (arg->target_depth != nm) |
| @@ -282,7 +282,7 @@ solve_h48_maketasks( | |||
| 282 | cube_t backup_cube; | 282 | cube_t backup_cube; |
| 283 | solution_moves_t moves; | 283 | solution_moves_t moves; |
| 284 | 284 | ||
| 285 | if (issolved(maketasks_arg->cube)) { | 285 | if (equal(maketasks_arg->cube, SOLVED_CUBE)) { |
| 286 | if (maketasks_arg->nmoves > maketasks_arg->maxmoves || | 286 | if (maketasks_arg->nmoves > maketasks_arg->maxmoves || |
| 287 | maketasks_arg->nmoves < maketasks_arg->minmoves || | 287 | maketasks_arg->nmoves < maketasks_arg->minmoves || |
| 288 | solutions_done(solve_arg->solution_list, | 288 | solutions_done(solve_arg->solution_list, |
diff --git a/test/000_basic/basic_tests.c b/test/000_basic/basic_tests.c index accde66..df38e88 100644 --- a/test/000_basic/basic_tests.c +++ b/test/000_basic/basic_tests.c | |||
| @@ -1,27 +1,29 @@ | |||
| 1 | #include "../test.h" | 1 | #include "../test.h" |
| 2 | 2 | ||
| 3 | bool issolved(cube_t); | 3 | bool issolved(oriented_cube_t); |
| 4 | bool equal(cube_t, cube_t); | 4 | bool equal(cube_t, cube_t); |
| 5 | 5 | ||
| 6 | void | 6 | void |
| 7 | check(cube_t cube, char *name) | 7 | check(oriented_cube_t cube, char *name) |
| 8 | { | 8 | { |
| 9 | printf("%s is%s solvable\n", name, issolvable(cube) ? "" : " NOT"); | 9 | printf("%s is%s solvable\n", name, issolvable(cube) ? "" : " NOT"); |
| 10 | printf("%s is%s solved\n", name, issolved(cube) ? "" : " NOT"); | 10 | printf("%s is%s solved\n", name, issolved(cube) ? "" : " NOT"); |
| 11 | } | 11 | } |
| 12 | 12 | ||
| 13 | void | 13 | void |
| 14 | check2(cube_t cube1, char *name1, cube_t cube2, char *name2) | 14 | check2(oriented_cube_t cube1, char *name1, oriented_cube_t cube2, char *name2) |
| 15 | { | 15 | { |
| 16 | printf("%s and %s are%s equal\n", name1, name2, | 16 | bool eq = equal(cube1.cube, cube2.cube) && |
| 17 | equal(cube1, cube2) ? "" : " NOT"); | 17 | cube1.orientation == cube2.orientation; |
| 18 | printf("%s and %s are%s equal\n", name1, name2, eq ? "" : " NOT"); | ||
| 18 | } | 19 | } |
| 19 | 20 | ||
| 20 | void run(void) { | 21 | void run(void) { |
| 21 | cube_t zero, solved; | 22 | oriented_cube_t zero, solved; |
| 22 | 23 | ||
| 23 | memset(&zero, 0, sizeof(cube_t)); | 24 | memset(&zero, 0, sizeof(oriented_cube_t)); |
| 24 | solved = solvedcube(); | 25 | solved = solvedcube(); |
| 26 | |||
| 25 | check(solved, "Solved"); | 27 | check(solved, "Solved"); |
| 26 | check(zero, "Zero"); | 28 | check(zero, "Zero"); |
| 27 | 29 | ||
diff --git a/test/001_pieces/pieces_tests.c b/test/001_pieces/pieces_tests.c index 452a11b..f46a143 100644 --- a/test/001_pieces/pieces_tests.c +++ b/test/001_pieces/pieces_tests.c | |||
| @@ -6,7 +6,7 @@ void run(void) { | |||
| 6 | int i; | 6 | int i; |
| 7 | uint8_t corner[8], edge[12]; | 7 | uint8_t corner[8], edge[12]; |
| 8 | char str[STRLENMAX], *aux; | 8 | char str[STRLENMAX], *aux; |
| 9 | cube_t cube; | 9 | oriented_cube_t cube; |
| 10 | 10 | ||
| 11 | aux = str; | 11 | aux = str; |
| 12 | while (fgets(aux, STRLENMAX, stdin) != NULL) | 12 | while (fgets(aux, STRLENMAX, stdin) != NULL) |
| @@ -14,7 +14,7 @@ void run(void) { | |||
| 14 | aux++; | 14 | aux++; |
| 15 | 15 | ||
| 16 | cube = readcube(str); | 16 | cube = readcube(str); |
| 17 | pieces(&cube, corner, edge); | 17 | pieces(&cube.cube, corner, edge); |
| 18 | 18 | ||
| 19 | for (i = 0; i < 8; i++) | 19 | for (i = 0; i < 8; i++) |
| 20 | printf("%" PRIu8 " ", corner[i]); | 20 | printf("%" PRIu8 " ", corner[i]); |
diff --git a/test/020_io_cube_read_write/01_solved_oneline.in b/test/020_io_cube_read_write/01_solved_oriented.in index 5aa6ba7..5aa6ba7 100644 --- a/test/020_io_cube_read_write/01_solved_oneline.in +++ b/test/020_io_cube_read_write/01_solved_oriented.in | |||
diff --git a/test/020_io_cube_read_write/01_solved_oneline.out b/test/020_io_cube_read_write/01_solved_oriented.out index 5aa6ba7..5aa6ba7 100644 --- a/test/020_io_cube_read_write/01_solved_oneline.out +++ b/test/020_io_cube_read_write/01_solved_oriented.out | |||
diff --git a/test/020_io_cube_read_write/02_solve_misoriented.in b/test/020_io_cube_read_write/02_solve_misoriented.in new file mode 100644 index 0000000..f3279c5 --- /dev/null +++ b/test/020_io_cube_read_write/02_solve_misoriented.in | |||
| @@ -0,0 +1 @@ | |||
| ABCDEFGH=ABCDEFGHIJKL=L | |||
diff --git a/test/020_io_cube_read_write/02_solve_misoriented.out b/test/020_io_cube_read_write/02_solve_misoriented.out new file mode 100644 index 0000000..f3279c5 --- /dev/null +++ b/test/020_io_cube_read_write/02_solve_misoriented.out | |||
| @@ -0,0 +1 @@ | |||
| ABCDEFGH=ABCDEFGHIJKL=L | |||
diff --git a/test/020_io_cube_read_write/io_cube_tests.c b/test/020_io_cube_read_write/io_cube_tests.c index c9df1a9..3d7601c 100644 --- a/test/020_io_cube_read_write/io_cube_tests.c +++ b/test/020_io_cube_read_write/io_cube_tests.c | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | 2 | ||
| 3 | void run(void) { | 3 | void run(void) { |
| 4 | char str[STRLENMAX], *aux; | 4 | char str[STRLENMAX], *aux; |
| 5 | cube_t cube; | 5 | oriented_cube_t cube; |
| 6 | 6 | ||
| 7 | aux = str; | 7 | aux = str; |
| 8 | while (fgets(aux, STRLENMAX, stdin) != NULL) | 8 | while (fgets(aux, STRLENMAX, stdin) != NULL) |
diff --git a/test/030_move/move_tests.c b/test/030_move/move_tests.c index e5aed44..98c9592 100644 --- a/test/030_move/move_tests.c +++ b/test/030_move/move_tests.c | |||
| @@ -1,10 +1,10 @@ | |||
| 1 | #include "../test.h" | 1 | #include "../test.h" |
| 2 | 2 | ||
| 3 | cube_t applymoves(cube_t, char *); | 3 | oriented_cube_t applymoves(oriented_cube_t, char *); |
| 4 | 4 | ||
| 5 | void run(void) { | 5 | void run(void) { |
| 6 | char movestr[STRLENMAX], cubestr[STRLENMAX]; | 6 | char movestr[STRLENMAX], cubestr[STRLENMAX]; |
| 7 | cube_t cube; | 7 | oriented_cube_t cube; |
| 8 | 8 | ||
| 9 | fgets(movestr, STRLENMAX, stdin); | 9 | fgets(movestr, STRLENMAX, stdin); |
| 10 | fgets(cubestr, STRLENMAX, stdin); | 10 | fgets(cubestr, STRLENMAX, stdin); |
diff --git a/test/031_premove/premove_tests.c b/test/031_premove/premove_tests.c index 24773cd..10bed92 100644 --- a/test/031_premove/premove_tests.c +++ b/test/031_premove/premove_tests.c | |||
| @@ -7,14 +7,14 @@ cube_t premove(cube_t, uint8_t); | |||
| 7 | void run(void) { | 7 | void run(void) { |
| 8 | char movestr[STRLENMAX], cubestr[STRLENMAX]; | 8 | char movestr[STRLENMAX], cubestr[STRLENMAX]; |
| 9 | uint8_t move; | 9 | uint8_t move; |
| 10 | cube_t cube; | 10 | oriented_cube_t cube; |
| 11 | 11 | ||
| 12 | fgets(movestr, STRLENMAX, stdin); | 12 | fgets(movestr, STRLENMAX, stdin); |
| 13 | move = readmove(movestr[0]) + readmodifier(movestr[1]); | 13 | move = readmove(movestr[0]) + readmodifier(movestr[1]); |
| 14 | fgets(cubestr, STRLENMAX, stdin); | 14 | fgets(cubestr, STRLENMAX, stdin); |
| 15 | cube = readcube(cubestr); | 15 | cube = readcube(cubestr); |
| 16 | 16 | ||
| 17 | cube = premove(cube, move); | 17 | cube.cube = premove(cube.cube, move); |
| 18 | 18 | ||
| 19 | if (iserror(cube)) { | 19 | if (iserror(cube)) { |
| 20 | printf("Error moving cube\n"); | 20 | printf("Error moving cube\n"); |
diff --git a/test/040_inverse_cube/inverse_tests.c b/test/040_inverse_cube/inverse_tests.c index 9e8925a..f0401ea 100644 --- a/test/040_inverse_cube/inverse_tests.c +++ b/test/040_inverse_cube/inverse_tests.c | |||
| @@ -4,11 +4,14 @@ cube_t inverse(cube_t); | |||
| 4 | 4 | ||
| 5 | void run(void) { | 5 | void run(void) { |
| 6 | char str[STRLENMAX]; | 6 | char str[STRLENMAX]; |
| 7 | cube_t cube, inv; | 7 | oriented_cube_t cube, inv; |
| 8 | 8 | ||
| 9 | fgets(str, STRLENMAX, stdin); | 9 | fgets(str, STRLENMAX, stdin); |
| 10 | cube = readcube(str); | 10 | cube = readcube(str); |
| 11 | inv = inverse(cube); | 11 | inv = (oriented_cube_t) { |
| 12 | .cube = inverse(cube.cube), | ||
| 13 | .orientation = cube.orientation | ||
| 14 | }; | ||
| 12 | 15 | ||
| 13 | if (iserror(inv)) { | 16 | if (iserror(inv)) { |
| 14 | printf("Error inverting cube\n"); | 17 | printf("Error inverting cube\n"); |
diff --git a/test/050_compose/compose_tests.c b/test/050_compose/compose_tests.c index c61775f..3dea055 100644 --- a/test/050_compose/compose_tests.c +++ b/test/050_compose/compose_tests.c | |||
| @@ -4,14 +4,17 @@ cube_t compose(cube_t, cube_t); | |||
| 4 | 4 | ||
| 5 | void run(void) { | 5 | void run(void) { |
| 6 | char str[STRLENMAX]; | 6 | char str[STRLENMAX]; |
| 7 | cube_t c1, c2, c3; | 7 | oriented_cube_t c1, c2, c3; |
| 8 | 8 | ||
| 9 | fgets(str, STRLENMAX, stdin); | 9 | fgets(str, STRLENMAX, stdin); |
| 10 | c1 = readcube(str); | 10 | c1 = readcube(str); |
| 11 | fgets(str, STRLENMAX, stdin); | 11 | fgets(str, STRLENMAX, stdin); |
| 12 | c2 = readcube(str); | 12 | c2 = readcube(str); |
| 13 | 13 | ||
| 14 | c3 = compose(c1, c2); | 14 | c3 = (oriented_cube_t) { |
| 15 | .cube = compose(c1.cube, c2.cube), | ||
| 16 | .orientation = c1.orientation | ||
| 17 | }; | ||
| 15 | 18 | ||
| 16 | if (iserror(c3)) { | 19 | if (iserror(c3)) { |
| 17 | printf("Error composing cubes\n"); | 20 | printf("Error composing cubes\n"); |
diff --git a/test/060_transform/transform_tests.c b/test/060_transform/transform_tests.c index 4ae161c..82694b2 100644 --- a/test/060_transform/transform_tests.c +++ b/test/060_transform/transform_tests.c | |||
| @@ -1,10 +1,10 @@ | |||
| 1 | #include "../test.h" | 1 | #include "../test.h" |
| 2 | 2 | ||
| 3 | cube_t applytrans(cube_t, char *); | 3 | oriented_cube_t applytrans(oriented_cube_t, char *); |
| 4 | 4 | ||
| 5 | void run(void) { | 5 | void run(void) { |
| 6 | char cubestr[STRLENMAX], transtr[STRLENMAX]; | 6 | char cubestr[STRLENMAX], transtr[STRLENMAX]; |
| 7 | cube_t cube; | 7 | oriented_cube_t cube; |
| 8 | 8 | ||
| 9 | fgets(transtr, STRLENMAX, stdin); | 9 | fgets(transtr, STRLENMAX, stdin); |
| 10 | fgets(cubestr, STRLENMAX, stdin); | 10 | fgets(cubestr, STRLENMAX, stdin); |
diff --git a/test/061_inverse_trans/inverse_trans_tests.c b/test/061_inverse_trans/inverse_trans_tests.c index 441fef8..bad39fa 100644 --- a/test/061_inverse_trans/inverse_trans_tests.c +++ b/test/061_inverse_trans/inverse_trans_tests.c | |||
| @@ -2,13 +2,13 @@ | |||
| 2 | 2 | ||
| 3 | uint8_t readtrans(char [static NISSY_SIZE_TRANSFORMATION]); | 3 | uint8_t readtrans(char [static NISSY_SIZE_TRANSFORMATION]); |
| 4 | uint8_t inverse_trans(uint8_t); | 4 | uint8_t inverse_trans(uint8_t); |
| 5 | cube_t applymoves(cube_t, char *); | 5 | oriented_cube_t applymoves(oriented_cube_t, char *); |
| 6 | cube_t applytrans(cube_t, char *); | 6 | oriented_cube_t applytrans(oriented_cube_t, char *); |
| 7 | extern char *transstr[]; | 7 | extern char *transstr[]; |
| 8 | 8 | ||
| 9 | void run(void) { | 9 | void run(void) { |
| 10 | uint8_t t, tinv; | 10 | uint8_t t, tinv; |
| 11 | cube_t cube; | 11 | oriented_cube_t cube; |
| 12 | 12 | ||
| 13 | for (t = 0; t < 48; t++) { | 13 | for (t = 0; t < 48; t++) { |
| 14 | cube = solvedcube(); | 14 | cube = solvedcube(); |
diff --git a/test/062_transform_move/transform_move_tests.c b/test/062_transform_move/transform_move_tests.c index 66889f9..4f554c7 100644 --- a/test/062_transform_move/transform_move_tests.c +++ b/test/062_transform_move/transform_move_tests.c | |||
| @@ -6,14 +6,14 @@ cube_t applytrans(cube_t, const char *); | |||
| 6 | uint8_t transform_move(uint8_t, uint8_t); | 6 | uint8_t transform_move(uint8_t, uint8_t); |
| 7 | int64_t readmoves(const char *, size_t n, uint8_t [n]); | 7 | int64_t readmoves(const char *, size_t n, uint8_t [n]); |
| 8 | cube_t move(cube_t, uint8_t); | 8 | cube_t move(cube_t, uint8_t); |
| 9 | cube_t applymoves(cube_t, const char *); | 9 | oriented_cube_t applymoves(oriented_cube_t, const char *); |
| 10 | uint8_t readtrans(const char[static NISSY_SIZE_TRANSFORMATION]); | 10 | uint8_t readtrans(const char[static NISSY_SIZE_TRANSFORMATION]); |
| 11 | 11 | ||
| 12 | void run(void) { | 12 | void run(void) { |
| 13 | char movestr[STRLENMAX], transtr[STRLENMAX], cubestr[STRLENMAX]; | 13 | char movestr[STRLENMAX], transtr[STRLENMAX], cubestr[STRLENMAX]; |
| 14 | uint8_t t, moves[MAXMOVES]; | 14 | uint8_t t, moves[MAXMOVES]; |
| 15 | int i, n; | 15 | int i, n; |
| 16 | cube_t cube; | 16 | oriented_cube_t cube; |
| 17 | 17 | ||
| 18 | fgets(transtr, STRLENMAX, stdin); | 18 | fgets(transtr, STRLENMAX, stdin); |
| 19 | fgets(movestr, STRLENMAX, stdin); | 19 | fgets(movestr, STRLENMAX, stdin); |
| @@ -22,7 +22,7 @@ void run(void) { | |||
| 22 | n = readmoves(movestr, MAXMOVES, moves); | 22 | n = readmoves(movestr, MAXMOVES, moves); |
| 23 | t = readtrans(transtr); | 23 | t = readtrans(transtr); |
| 24 | for (i = 0; i < n; i++) | 24 | for (i = 0; i < n; i++) |
| 25 | cube = move(cube, transform_move(moves[i], t)); | 25 | cube.cube = move(cube.cube, transform_move(moves[i], t)); |
| 26 | 26 | ||
| 27 | writecube(cube, STRLENMAX, cubestr); | 27 | writecube(cube, STRLENMAX, cubestr); |
| 28 | printf("%s\n", cubestr); | 28 | printf("%s\n", cubestr); |
diff --git a/test/063_symmetry_mask/symmetry_mask_tests.c b/test/063_symmetry_mask/symmetry_mask_tests.c index c14fd14..e717b12 100644 --- a/test/063_symmetry_mask/symmetry_mask_tests.c +++ b/test/063_symmetry_mask/symmetry_mask_tests.c | |||
| @@ -5,11 +5,11 @@ uint64_t symmetry_mask(cube_t); | |||
| 5 | void run(void) { | 5 | void run(void) { |
| 6 | char str[STRLENMAX]; | 6 | char str[STRLENMAX]; |
| 7 | uint64_t i, result; | 7 | uint64_t i, result; |
| 8 | cube_t cube; | 8 | oriented_cube_t cube; |
| 9 | 9 | ||
| 10 | fgets(str, STRLENMAX, stdin); | 10 | fgets(str, STRLENMAX, stdin); |
| 11 | cube = readcube(str); | 11 | cube = readcube(str); |
| 12 | result = symmetry_mask(cube); | 12 | result = symmetry_mask(cube.cube); |
| 13 | 13 | ||
| 14 | for (i = 0; i < 48; result >>= 1, i++) | 14 | for (i = 0; i < 48; result >>= 1, i++) |
| 15 | printf("%" PRIu64, result % UINT64_C(2)); | 15 | printf("%" PRIu64, result % UINT64_C(2)); |
diff --git a/test/071_coord_eo/coord_eo_tests.c b/test/071_coord_eo/coord_eo_tests.c index 11a8ac3..360720e 100644 --- a/test/071_coord_eo/coord_eo_tests.c +++ b/test/071_coord_eo/coord_eo_tests.c | |||
| @@ -4,13 +4,13 @@ int64_t coord_eo(cube_t); | |||
| 4 | 4 | ||
| 5 | void run(void) { | 5 | void run(void) { |
| 6 | char str[STRLENMAX]; | 6 | char str[STRLENMAX]; |
| 7 | cube_t cube; | 7 | oriented_cube_t cube; |
| 8 | int64_t result; | 8 | int64_t result; |
| 9 | 9 | ||
| 10 | fgets(str, STRLENMAX, stdin); | 10 | fgets(str, STRLENMAX, stdin); |
| 11 | cube = readcube(str); | 11 | cube = readcube(str); |
| 12 | 12 | ||
| 13 | result = coord_eo(cube); | 13 | result = coord_eo(cube.cube); |
| 14 | 14 | ||
| 15 | printf("%" PRId64 "\n", result); | 15 | printf("%" PRId64 "\n", result); |
| 16 | } | 16 | } |
diff --git a/test/072_coord_co/coord_co_tests.c b/test/072_coord_co/coord_co_tests.c index b1de223..440ad2e 100644 --- a/test/072_coord_co/coord_co_tests.c +++ b/test/072_coord_co/coord_co_tests.c | |||
| @@ -4,13 +4,13 @@ int64_t coord_co(cube_t); | |||
| 4 | 4 | ||
| 5 | void run(void) { | 5 | void run(void) { |
| 6 | char str[STRLENMAX]; | 6 | char str[STRLENMAX]; |
| 7 | cube_t cube; | 7 | oriented_cube_t cube; |
| 8 | int64_t result; | 8 | int64_t result; |
| 9 | 9 | ||
| 10 | fgets(str, STRLENMAX, stdin); | 10 | fgets(str, STRLENMAX, stdin); |
| 11 | cube = readcube(str); | 11 | cube = readcube(str); |
| 12 | 12 | ||
| 13 | result = coord_co(cube); | 13 | result = coord_co(cube.cube); |
| 14 | 14 | ||
| 15 | printf("%" PRId64 "\n", result); | 15 | printf("%" PRId64 "\n", result); |
| 16 | } | 16 | } |
diff --git a/test/073_coord_csep/coord_csep_tests.c b/test/073_coord_csep/coord_csep_tests.c index 6fe16b2..21a3b3a 100644 --- a/test/073_coord_csep/coord_csep_tests.c +++ b/test/073_coord_csep/coord_csep_tests.c | |||
| @@ -4,13 +4,13 @@ int64_t coord_csep(cube_t); | |||
| 4 | 4 | ||
| 5 | void run(void) { | 5 | void run(void) { |
| 6 | char str[STRLENMAX]; | 6 | char str[STRLENMAX]; |
| 7 | cube_t cube; | 7 | oriented_cube_t cube; |
| 8 | int64_t result; | 8 | int64_t result; |
| 9 | 9 | ||
| 10 | fgets(str, STRLENMAX, stdin); | 10 | fgets(str, STRLENMAX, stdin); |
| 11 | cube = readcube(str); | 11 | cube = readcube(str); |
| 12 | 12 | ||
| 13 | result = coord_csep(cube); | 13 | result = coord_csep(cube.cube); |
| 14 | 14 | ||
| 15 | printf("%" PRId64 "\n", result); | 15 | printf("%" PRId64 "\n", result); |
| 16 | } | 16 | } |
diff --git a/test/074_coord_esep/coord_esep_tests.c b/test/074_coord_esep/coord_esep_tests.c index 7c53c9a..679e1c6 100644 --- a/test/074_coord_esep/coord_esep_tests.c +++ b/test/074_coord_esep/coord_esep_tests.c | |||
| @@ -4,13 +4,13 @@ int64_t coord_esep(cube_t); | |||
| 4 | 4 | ||
| 5 | void run(void) { | 5 | void run(void) { |
| 6 | char str[STRLENMAX]; | 6 | char str[STRLENMAX]; |
| 7 | cube_t cube; | 7 | oriented_cube_t cube; |
| 8 | int64_t result; | 8 | int64_t result; |
| 9 | 9 | ||
| 10 | fgets(str, STRLENMAX, stdin); | 10 | fgets(str, STRLENMAX, stdin); |
| 11 | cube = readcube(str); | 11 | cube = readcube(str); |
| 12 | 12 | ||
| 13 | result = coord_esep(cube); | 13 | result = coord_esep(cube.cube); |
| 14 | 14 | ||
| 15 | printf("%" PRId64 "\n", result); | 15 | printf("%" PRId64 "\n", result); |
| 16 | } | 16 | } |
diff --git a/test/075_set_eo/set_eo_tests.c b/test/075_set_eo/set_eo_tests.c index 2e05e9a..ef2156d 100644 --- a/test/075_set_eo/set_eo_tests.c +++ b/test/075_set_eo/set_eo_tests.c | |||
| @@ -6,7 +6,7 @@ void pieces(cube_t *, uint8_t [static 8], uint8_t [static 12]); | |||
| 6 | 6 | ||
| 7 | void run(void) { | 7 | void run(void) { |
| 8 | char str[STRLENMAX]; | 8 | char str[STRLENMAX]; |
| 9 | cube_t cube; | 9 | oriented_cube_t cube; |
| 10 | uint8_t edge[12], corner[8]; | 10 | uint8_t edge[12], corner[8]; |
| 11 | int64_t eo; | 11 | int64_t eo; |
| 12 | 12 | ||
| @@ -15,12 +15,12 @@ void run(void) { | |||
| 15 | fgets(str, STRLENMAX, stdin); | 15 | fgets(str, STRLENMAX, stdin); |
| 16 | eo = atoi(str); | 16 | eo = atoi(str); |
| 17 | 17 | ||
| 18 | set_eo(&cube, eo); | 18 | set_eo(&cube.cube, eo); |
| 19 | 19 | ||
| 20 | if (iserror(cube)) { | 20 | if (iserror(cube)) { |
| 21 | printf("Error setting EO\n"); | 21 | printf("Error setting EO\n"); |
| 22 | } else if (!isconsistent(cube)) { | 22 | } else if (!isconsistent(cube)) { |
| 23 | pieces(&cube, corner, edge); | 23 | pieces(&cube.cube, corner, edge); |
| 24 | fprintf(stderr, "edges: "); | 24 | fprintf(stderr, "edges: "); |
| 25 | for (int i = 0; i < 12; i++) | 25 | for (int i = 0; i < 12; i++) |
| 26 | fprintf(stderr, "%d ", edge[i]); | 26 | fprintf(stderr, "%d ", edge[i]); |
diff --git a/test/076_copy_corners/copy_corners_tests.c b/test/076_copy_corners/copy_corners_tests.c index 94e2a2a..02e949b 100644 --- a/test/076_copy_corners/copy_corners_tests.c +++ b/test/076_copy_corners/copy_corners_tests.c | |||
| @@ -4,7 +4,7 @@ void copy_corners(cube_t *, cube_t); | |||
| 4 | 4 | ||
| 5 | void run(void) { | 5 | void run(void) { |
| 6 | char str[STRLENMAX]; | 6 | char str[STRLENMAX]; |
| 7 | cube_t c1, c2; | 7 | oriented_cube_t c1, c2; |
| 8 | 8 | ||
| 9 | fgets(str, STRLENMAX, stdin); | 9 | fgets(str, STRLENMAX, stdin); |
| 10 | c1 = readcube(str); | 10 | c1 = readcube(str); |
| @@ -12,7 +12,7 @@ void run(void) { | |||
| 12 | fgets(str, STRLENMAX, stdin); | 12 | fgets(str, STRLENMAX, stdin); |
| 13 | c2 = readcube(str); | 13 | c2 = readcube(str); |
| 14 | 14 | ||
| 15 | copy_corners(&c1, c2); | 15 | copy_corners(&c1.cube, c2.cube); |
| 16 | 16 | ||
| 17 | if (iserror(c1)) { | 17 | if (iserror(c1)) { |
| 18 | printf("Error setting EO\n"); | 18 | printf("Error setting EO\n"); |
diff --git a/test/077_copy_edges/copy_edges_tests.c b/test/077_copy_edges/copy_edges_tests.c index 36e32af..f3b0589 100644 --- a/test/077_copy_edges/copy_edges_tests.c +++ b/test/077_copy_edges/copy_edges_tests.c | |||
| @@ -4,7 +4,7 @@ void copy_edges(cube_t *, cube_t); | |||
| 4 | 4 | ||
| 5 | void run(void) { | 5 | void run(void) { |
| 6 | char str[STRLENMAX]; | 6 | char str[STRLENMAX]; |
| 7 | cube_t c1, c2; | 7 | oriented_cube_t c1, c2; |
| 8 | 8 | ||
| 9 | fgets(str, STRLENMAX, stdin); | 9 | fgets(str, STRLENMAX, stdin); |
| 10 | c1 = readcube(str); | 10 | c1 = readcube(str); |
| @@ -12,7 +12,7 @@ void run(void) { | |||
| 12 | fgets(str, STRLENMAX, stdin); | 12 | fgets(str, STRLENMAX, stdin); |
| 13 | c2 = readcube(str); | 13 | c2 = readcube(str); |
| 14 | 14 | ||
| 15 | copy_edges(&c1, c2); | 15 | copy_edges(&c1.cube, c2.cube); |
| 16 | 16 | ||
| 17 | if (iserror(c1)) { | 17 | if (iserror(c1)) { |
| 18 | printf("Error setting EO\n"); | 18 | printf("Error setting EO\n"); |
diff --git a/test/078_invcoord_esep/invcoord_esep_tests.c b/test/078_invcoord_esep/invcoord_esep_tests.c index ebf35b0..9945e77 100644 --- a/test/078_invcoord_esep/invcoord_esep_tests.c +++ b/test/078_invcoord_esep/invcoord_esep_tests.c | |||
| @@ -5,15 +5,15 @@ cube_t invcoord_esep(int64_t); | |||
| 5 | 5 | ||
| 6 | void run(void) { | 6 | void run(void) { |
| 7 | char str[STRLENMAX]; | 7 | char str[STRLENMAX]; |
| 8 | cube_t cube; | 8 | oriented_cube_t cube; |
| 9 | int64_t i; | 9 | int64_t i; |
| 10 | 10 | ||
| 11 | fgets(str, STRLENMAX, stdin); | 11 | fgets(str, STRLENMAX, stdin); |
| 12 | cube = readcube(str); | 12 | cube = readcube(str); |
| 13 | 13 | ||
| 14 | i = coord_esep(cube); | 14 | i = coord_esep(cube.cube); |
| 15 | cube = invcoord_esep(i); | 15 | cube.cube = invcoord_esep(i); |
| 16 | i = coord_esep(cube); | 16 | i = coord_esep(cube.cube); |
| 17 | 17 | ||
| 18 | printf("%" PRId64 "\n", i); | 18 | printf("%" PRId64 "\n", i); |
| 19 | } | 19 | } |
diff --git a/test/079_invcoord_co/invcoord_co_tests.c b/test/079_invcoord_co/invcoord_co_tests.c index 9f7c3d5..fcd68d0 100644 --- a/test/079_invcoord_co/invcoord_co_tests.c +++ b/test/079_invcoord_co/invcoord_co_tests.c | |||
| @@ -6,12 +6,14 @@ int64_t coord_co(cube_t); | |||
| 6 | cube_t invcoord_co(int64_t); | 6 | cube_t invcoord_co(int64_t); |
| 7 | 7 | ||
| 8 | void run(void) { | 8 | void run(void) { |
| 9 | cube_t cube; | 9 | oriented_cube_t cube; |
| 10 | int64_t coord, coord2; | 10 | int64_t coord, coord2; |
| 11 | 11 | ||
| 12 | cube.orientation = 0; | ||
| 13 | |||
| 12 | /* Test all possible values for CO coordinate */ | 14 | /* Test all possible values for CO coordinate */ |
| 13 | for (coord = 0; coord < POW_3_7; coord++) { | 15 | for (coord = 0; coord < POW_3_7; coord++) { |
| 14 | cube = invcoord_co(coord); | 16 | cube.cube = invcoord_co(coord); |
| 15 | 17 | ||
| 16 | if (!isconsistent(cube)) { | 18 | if (!isconsistent(cube)) { |
| 17 | printf("Not consistent\n"); | 19 | printf("Not consistent\n"); |
| @@ -22,7 +24,7 @@ void run(void) { | |||
| 22 | return; | 24 | return; |
| 23 | } | 25 | } |
| 24 | 26 | ||
| 25 | coord2 = coord_co(cube); | 27 | coord2 = coord_co(cube.cube); |
| 26 | if (coord != coord2) { | 28 | if (coord != coord2) { |
| 27 | printf("Error: invcoord of %" PRId64 | 29 | printf("Error: invcoord of %" PRId64 |
| 28 | " returns %" PRId64 "\n", coord, coord2); | 30 | " returns %" PRId64 "\n", coord, coord2); |
diff --git a/test/081_getcube/getcube_tests.c b/test/081_getcube/getcube_tests.c index 916c42b..07e621e 100644 --- a/test/081_getcube/getcube_tests.c +++ b/test/081_getcube/getcube_tests.c | |||
| @@ -4,7 +4,7 @@ cube_t getcube(int64_t, int64_t, int64_t, int64_t); | |||
| 4 | 4 | ||
| 5 | void run(void) { | 5 | void run(void) { |
| 6 | char str[STRLENMAX]; | 6 | char str[STRLENMAX]; |
| 7 | cube_t cube; | 7 | oriented_cube_t cube; |
| 8 | int64_t ep, eo, cp, co; | 8 | int64_t ep, eo, cp, co; |
| 9 | 9 | ||
| 10 | fgets(str, STRLENMAX, stdin); | 10 | fgets(str, STRLENMAX, stdin); |
| @@ -16,7 +16,10 @@ void run(void) { | |||
| 16 | fgets(str, STRLENMAX, stdin); | 16 | fgets(str, STRLENMAX, stdin); |
| 17 | co = atoll(str); | 17 | co = atoll(str); |
| 18 | 18 | ||
| 19 | cube = getcube(ep, eo, cp, co); | 19 | cube = (oriented_cube_t) { |
| 20 | .cube = getcube(ep, eo, cp, co), | ||
| 21 | .orientation = 0 | ||
| 22 | }; | ||
| 20 | 23 | ||
| 21 | if (iserror(cube)) { | 24 | if (iserror(cube)) { |
| 22 | printf("Error cube\n"); | 25 | printf("Error cube\n"); |
diff --git a/test/101_cocsep_transform_invariant/cocsep_transform_invariant.c b/test/101_cocsep_transform_invariant/cocsep_transform_invariant.c index 7ded2e9..5553fd1 100644 --- a/test/101_cocsep_transform_invariant/cocsep_transform_invariant.c +++ b/test/101_cocsep_transform_invariant/cocsep_transform_invariant.c | |||
| @@ -11,7 +11,8 @@ void run(void) { | |||
| 11 | uint64_t selfsim[COCSEP_CLASSES]; | 11 | uint64_t selfsim[COCSEP_CLASSES]; |
| 12 | int64_t coord, tcoord; | 12 | int64_t coord, tcoord; |
| 13 | char str[STRLENMAX]; | 13 | char str[STRLENMAX]; |
| 14 | cube_t cube, transd, rep[COCSEP_CLASSES]; | 14 | oriented_cube_t cube; |
| 15 | cube_t rep[COCSEP_CLASSES], transd; | ||
| 15 | 16 | ||
| 16 | fgets(str, STRLENMAX, stdin); | 17 | fgets(str, STRLENMAX, stdin); |
| 17 | cube = readcube(str); | 18 | cube = readcube(str); |
| @@ -19,9 +20,9 @@ void run(void) { | |||
| 19 | gendata_cocsep(buf, selfsim, rep); | 20 | gendata_cocsep(buf, selfsim, rep); |
| 20 | cocsepdata = (uint32_t *)((char *)buf + INFOSIZE); | 21 | cocsepdata = (uint32_t *)((char *)buf + INFOSIZE); |
| 21 | 22 | ||
| 22 | coord = (int64_t)COCLASS(cocsepdata[coord_cocsep(cube)]); | 23 | coord = (int64_t)COCLASS(cocsepdata[coord_cocsep(cube.cube)]); |
| 23 | for (t = 0; t < 48; t++) { | 24 | for (t = 0; t < 48; t++) { |
| 24 | transd = transform(cube, t); | 25 | transd = transform(cube.cube, t); |
| 25 | tcoord = (int64_t)COCLASS(cocsepdata[coord_cocsep(transd)]); | 26 | tcoord = (int64_t)COCLASS(cocsepdata[coord_cocsep(transd)]); |
| 26 | if (coord != tcoord) | 27 | if (coord != tcoord) |
| 27 | printf("Error: expected %" PRId64 | 28 | printf("Error: expected %" PRId64 |
diff --git a/test/102_cocsep_selfsim/cocsep_selfsim_tests.c b/test/102_cocsep_selfsim/cocsep_selfsim_tests.c index 9966321..1a1c6f2 100644 --- a/test/102_cocsep_selfsim/cocsep_selfsim_tests.c +++ b/test/102_cocsep_selfsim/cocsep_selfsim_tests.c | |||
| @@ -16,7 +16,8 @@ void run(void) { | |||
| 16 | uint32_t *cocsepdata, data; | 16 | uint32_t *cocsepdata, data; |
| 17 | int64_t coord, coclass; | 17 | int64_t coord, coclass; |
| 18 | uint64_t selfsim[COCSEP_CLASSES], sim, t; | 18 | uint64_t selfsim[COCSEP_CLASSES], sim, t; |
| 19 | cube_t cube, rep[COCSEP_CLASSES]; | 19 | oriented_cube_t cube; |
| 20 | cube_t rep[COCSEP_CLASSES]; | ||
| 20 | 21 | ||
| 21 | gendata_cocsep(buf, selfsim, rep); | 22 | gendata_cocsep(buf, selfsim, rep); |
| 22 | cocsepdata = (uint32_t *)(buf + INFOSIZE); | 23 | cocsepdata = (uint32_t *)(buf + INFOSIZE); |
| @@ -25,7 +26,7 @@ void run(void) { | |||
| 25 | 26 | ||
| 26 | while (fgets(str, STRLENMAX, stdin) != NULL) { | 27 | while (fgets(str, STRLENMAX, stdin) != NULL) { |
| 27 | cube = readcube(str); | 28 | cube = readcube(str); |
| 28 | coord = coord_cocsep(cube); | 29 | coord = coord_cocsep(cube.cube); |
| 29 | data = cocsepdata[coord]; | 30 | data = cocsepdata[coord]; |
| 30 | coclass = (data & (0xFFFU << 16)) >> 16; | 31 | coclass = (data & (0xFFFU << 16)) >> 16; |
| 31 | sim = selfsim[coclass]; | 32 | sim = selfsim[coclass]; |
diff --git a/test/110_coord_invcoord_h48/coord_invcoord_h48_tests.c b/test/110_coord_invcoord_h48/coord_invcoord_h48_tests.c index 458ad31..0333f27 100644 --- a/test/110_coord_invcoord_h48/coord_invcoord_h48_tests.c +++ b/test/110_coord_invcoord_h48/coord_invcoord_h48_tests.c | |||
| @@ -14,7 +14,8 @@ void run(void) { | |||
| 14 | uint32_t *cocsepdata; | 14 | uint32_t *cocsepdata; |
| 15 | uint64_t selfsim[COCSEP_CLASSES]; | 15 | uint64_t selfsim[COCSEP_CLASSES]; |
| 16 | int64_t c, cc; | 16 | int64_t c, cc; |
| 17 | cube_t cube, invc, rep[COCSEP_CLASSES]; | 17 | oriented_cube_t cube; |
| 18 | cube_t invc, rep[COCSEP_CLASSES]; | ||
| 18 | 19 | ||
| 19 | gendata_cocsep(buf, selfsim, rep); | 20 | gendata_cocsep(buf, selfsim, rep); |
| 20 | cocsepdata = (uint32_t *)(buf + INFOSIZE); | 21 | cocsepdata = (uint32_t *)(buf + INFOSIZE); |
| @@ -23,11 +24,11 @@ void run(void) { | |||
| 23 | h = 11; | 24 | h = 11; |
| 24 | while (fgets(str, STRLENMAX, stdin) != NULL) { | 25 | while (fgets(str, STRLENMAX, stdin) != NULL) { |
| 25 | cube = readcube(str); | 26 | cube = readcube(str); |
| 26 | c = coord_h48(cube, cocsepdata, h); | 27 | c = coord_h48(cube.cube, cocsepdata, h); |
| 27 | invc = invcoord_h48(c, rep, h); | 28 | invc = invcoord_h48(c, rep, h); |
| 28 | for (t = 0, found = false; t < 48; t++) { | 29 | for (t = 0, found = false; t < 48; t++) { |
| 29 | cube = transform(invc, t); | 30 | cube.cube = transform(invc, t); |
| 30 | cc = coord_h48(cube, cocsepdata, h); | 31 | cc = coord_h48(cube.cube, cocsepdata, h); |
| 31 | found = found || cc == c; | 32 | found = found || cc == c; |
| 32 | } | 33 | } |
| 33 | printf("%d %s\n", i, found ? "ok" : "ERROR"); | 34 | printf("%d %s\n", i, found ? "ok" : "ERROR"); |
diff --git a/test/121_coorddata_dr/coorddata_dr.c b/test/121_coorddata_dr/coorddata_dr.c index d7efcfb..e8407c8 100644 --- a/test/121_coorddata_dr/coorddata_dr.c +++ b/test/121_coorddata_dr/coorddata_dr.c | |||
| @@ -16,6 +16,7 @@ void run(void) { | |||
| 16 | unsigned char *data; | 16 | unsigned char *data; |
| 17 | size_t size; | 17 | size_t size; |
| 18 | cube_t cube; | 18 | cube_t cube; |
| 19 | oriented_cube_t oc; | ||
| 19 | uint64_t coord, coord2; | 20 | uint64_t coord, coord2; |
| 20 | 21 | ||
| 21 | size = coordinate_dr_gendata(NULL); | 22 | size = coordinate_dr_gendata(NULL); |
| @@ -25,7 +26,8 @@ void run(void) { | |||
| 25 | for (coord = 0; coord < BOUND; coord++) { | 26 | for (coord = 0; coord < BOUND; coord++) { |
| 26 | cube = coordinate_dr_cube(coord, data); | 27 | cube = coordinate_dr_cube(coord, data); |
| 27 | 28 | ||
| 28 | if (!isconsistent(cube)) { | 29 | oc = (oriented_cube_t) { .cube = cube, .orientation = 0 }; |
| 30 | if (!isconsistent(oc)) { | ||
| 29 | printf("Error: invcoord of %" PRId64 | 31 | printf("Error: invcoord of %" PRId64 |
| 30 | " is not consistent\n", coord); | 32 | " is not consistent\n", coord); |
| 31 | goto cleanup; | 33 | goto cleanup; |
| @@ -43,9 +45,10 @@ void run(void) { | |||
| 43 | } | 45 | } |
| 44 | 46 | ||
| 45 | if (!found) { | 47 | if (!found) { |
| 48 | oc = (oriented_cube_t){.cube = cube, .orientation = 0}; | ||
| 46 | printf("Error: invcoord of %" PRId64 " returns %" | 49 | printf("Error: invcoord of %" PRId64 " returns %" |
| 47 | PRId64 " with cube:\n", coord, coord2); | 50 | PRId64 " with cube:\n", coord, coord2); |
| 48 | writecube(cube, STRLENMAX, str); | 51 | writecube(oc, STRLENMAX, str); |
| 49 | printf("%s\n", str); | 52 | printf("%s\n", str); |
| 50 | goto cleanup; | 53 | goto cleanup; |
| 51 | } | 54 | } |
diff --git a/test/122_coorddata_dreo/coorddata_dreo.c b/test/122_coorddata_dreo/coorddata_dreo.c index 98c954d..942e837 100644 --- a/test/122_coorddata_dreo/coorddata_dreo.c +++ b/test/122_coorddata_dreo/coorddata_dreo.c | |||
| @@ -16,6 +16,7 @@ void run(void) { | |||
| 16 | unsigned char *data; | 16 | unsigned char *data; |
| 17 | size_t size; | 17 | size_t size; |
| 18 | cube_t cube; | 18 | cube_t cube; |
| 19 | oriented_cube_t oc; | ||
| 19 | uint64_t coord, coord2; | 20 | uint64_t coord, coord2; |
| 20 | 21 | ||
| 21 | size = coordinate_dreo_gendata(NULL); | 22 | size = coordinate_dreo_gendata(NULL); |
| @@ -25,7 +26,8 @@ void run(void) { | |||
| 25 | for (coord = 0; coord < BOUND; coord++) { | 26 | for (coord = 0; coord < BOUND; coord++) { |
| 26 | cube = coordinate_dreo_cube(coord, data); | 27 | cube = coordinate_dreo_cube(coord, data); |
| 27 | 28 | ||
| 28 | if (!isconsistent(cube)) { | 29 | oc = (oriented_cube_t) { .cube = cube, .orientation = 0 }; |
| 30 | if (!isconsistent(oc)) { | ||
| 29 | printf("Error: invcoord of %" PRId64 | 31 | printf("Error: invcoord of %" PRId64 |
| 30 | " is not consistent\n", coord); | 32 | " is not consistent\n", coord); |
| 31 | goto cleanup; | 33 | goto cleanup; |
| @@ -43,9 +45,10 @@ void run(void) { | |||
| 43 | } | 45 | } |
| 44 | 46 | ||
| 45 | if (!found) { | 47 | if (!found) { |
| 48 | oc = (oriented_cube_t){.cube = cube, .orientation = 0}; | ||
| 46 | printf("Error: invcoord of %" PRId64 " returns %" | 49 | printf("Error: invcoord of %" PRId64 " returns %" |
| 47 | PRId64 " with cube:\n", coord, coord2); | 50 | PRId64 " with cube:\n", coord, coord2); |
| 48 | writecube(cube, STRLENMAX, str); | 51 | writecube(oc, STRLENMAX, str); |
| 49 | printf("%s\n", str); | 52 | printf("%s\n", str); |
| 50 | goto cleanup; | 53 | goto cleanup; |
| 51 | } | 54 | } |
diff --git a/test/test.h b/test/test.h index 78a3fd9..6230f36 100644 --- a/test/test.h +++ b/test/test.h | |||
| @@ -10,6 +10,7 @@ | |||
| 10 | 10 | ||
| 11 | #include "../src/nissy.h" | 11 | #include "../src/nissy.h" |
| 12 | #include "../src/arch/arch.h" | 12 | #include "../src/arch/arch.h" |
| 13 | #include "../src/core/core_types.h" | ||
| 13 | #include "../src/solvers/solutions_types_macros.h" | 14 | #include "../src/solvers/solutions_types_macros.h" |
| 14 | #include "../src/solvers/tables_types_macros.h" | 15 | #include "../src/solvers/tables_types_macros.h" |
| 15 | #include "../src/solvers/h48/coordinate_types_macros.h" | 16 | #include "../src/solvers/h48/coordinate_types_macros.h" |
| @@ -20,13 +21,13 @@ | |||
| 20 | #define STRLENMAX 10000 | 21 | #define STRLENMAX 10000 |
| 21 | 22 | ||
| 22 | /* Basic functions used in most tests */ | 23 | /* Basic functions used in most tests */ |
| 23 | cube_t solvedcube(void); | 24 | oriented_cube_t solvedcube(void); |
| 24 | bool iserror(cube_t); | 25 | bool iserror(oriented_cube_t); |
| 25 | bool isconsistent(cube_t); | 26 | bool isconsistent(oriented_cube_t); |
| 26 | bool issolvable(cube_t); | 27 | bool issolvable(oriented_cube_t); |
| 27 | bool issolved(cube_t); | 28 | bool issolved(oriented_cube_t); |
| 28 | cube_t readcube(char *); | 29 | oriented_cube_t readcube(char *); |
| 29 | int64_t writecube(cube_t, size_t n, char [n]); | 30 | int64_t writecube(oriented_cube_t, size_t n, char [n]); |
| 30 | 31 | ||
| 31 | /* Test function to be implemented by all tests */ | 32 | /* Test function to be implemented by all tests */ |
| 32 | void run(void); | 33 | void run(void); |
