From 49b9c4a516f72e03d53277075f4580e2df8f0e63 Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Mon, 27 May 2024 12:04:53 +0200 Subject: Some type fixes and some cleanup --- test/075_set_eo/set_eo_tests.c | 6 ++-- test/100_gendata_cocsep/gendata_cocsep_tests.c | 2 +- test/101_cocsep_selfsim/cocsep_selfsim_tests.c | 8 ++--- test/101_coord_invcoord_h48/00_all.in | 8 ----- test/101_coord_invcoord_h48/00_all.out | 8 ----- .../coord_invcoord_h48_tests.c | 40 ---------------------- test/102_coord_invcoord_h48/00_all.in | 8 +++++ test/102_coord_invcoord_h48/00_all.out | 8 +++++ .../coord_invcoord_h48_tests.c | 40 ++++++++++++++++++++++ test/102_gendata_h48/00_h_0.in | 1 - test/102_gendata_h48/00_h_0.out | 23 ------------- test/102_gendata_h48/01_h_1.in | 1 - test/102_gendata_h48/01_h_1.out | 23 ------------- test/102_gendata_h48/gendata_h48_tests.c | 35 ------------------- test/103_gendata_h48/00_h_0.in | 1 + test/103_gendata_h48/00_h_0.out | 23 +++++++++++++ test/103_gendata_h48/01_h_1.in | 1 + test/103_gendata_h48/01_h_1.out | 23 +++++++++++++ test/103_gendata_h48/gendata_h48_tests.c | 35 +++++++++++++++++++ 19 files changed, 148 insertions(+), 146 deletions(-) delete mode 100644 test/101_coord_invcoord_h48/00_all.in delete mode 100644 test/101_coord_invcoord_h48/00_all.out delete mode 100644 test/101_coord_invcoord_h48/coord_invcoord_h48_tests.c create mode 100644 test/102_coord_invcoord_h48/00_all.in create mode 100644 test/102_coord_invcoord_h48/00_all.out create mode 100644 test/102_coord_invcoord_h48/coord_invcoord_h48_tests.c delete mode 100644 test/102_gendata_h48/00_h_0.in delete mode 100644 test/102_gendata_h48/00_h_0.out delete mode 100644 test/102_gendata_h48/01_h_1.in delete mode 100644 test/102_gendata_h48/01_h_1.out delete mode 100644 test/102_gendata_h48/gendata_h48_tests.c create mode 100644 test/103_gendata_h48/00_h_0.in create mode 100644 test/103_gendata_h48/00_h_0.out create mode 100644 test/103_gendata_h48/01_h_1.in create mode 100644 test/103_gendata_h48/01_h_1.out create mode 100644 test/103_gendata_h48/gendata_h48_tests.c (limited to 'test') diff --git a/test/075_set_eo/set_eo_tests.c b/test/075_set_eo/set_eo_tests.c index 08c8ae8..cd4868c 100644 --- a/test/075_set_eo/set_eo_tests.c +++ b/test/075_set_eo/set_eo_tests.c @@ -22,9 +22,11 @@ int main(void) { printf("Error setting EO\n"); } else if (!isconsistent(cube)) { fprintf(stderr, "edges: "); - for (int i = 0; i < 12; i++) fprintf(stderr, "%d ", cube.edge[i]); + for (int i = 0; i < 12; i++) + fprintf(stderr, "%d ", cube.edge[i]); fprintf(stderr, "\n"); - for (int i = 0; i < 8; i++) fprintf(stderr, "%d ", cube.corner[i]); + for (int i = 0; i < 8; i++) + fprintf(stderr, "%d ", cube.corner[i]); fprintf(stderr, "\n"); printf("Setting EO resulted in inconsistent cube\n"); } else { diff --git a/test/100_gendata_cocsep/gendata_cocsep_tests.c b/test/100_gendata_cocsep/gendata_cocsep_tests.c index 4e0dce5..bba261b 100644 --- a/test/100_gendata_cocsep/gendata_cocsep_tests.c +++ b/test/100_gendata_cocsep/gendata_cocsep_tests.c @@ -1,6 +1,6 @@ #include "../test.h" -#define COCSEP_CLASSES 3393U +#define COCSEP_CLASSES 3393 size_t gendata_cocsep(void *, uint64_t *, cube_fast_t *); diff --git a/test/101_cocsep_selfsim/cocsep_selfsim_tests.c b/test/101_cocsep_selfsim/cocsep_selfsim_tests.c index 3fc7a60..02b5377 100644 --- a/test/101_cocsep_selfsim/cocsep_selfsim_tests.c +++ b/test/101_cocsep_selfsim/cocsep_selfsim_tests.c @@ -7,7 +7,7 @@ */ #include "../test.h" -#define COCSEP_CLASSES 3393U +#define COCSEP_CLASSES 3393 size_t gendata_cocsep(void *, uint64_t *, cube_fast_t *); int64_t coord_fast_cocsep(cube_fast_t); @@ -27,10 +27,10 @@ int main(void) { fast = cubetofast(readcube("H48", str)); coord = coord_fast_cocsep(fast); data = buf[coord]; - coclass = (data & (0xFFFU << 16U)) >> 16U; + coclass = (data & (0xFFFU << 16)) >> 16; sim = selfsim[coclass]; - for (t = 0; t < 48 && sim; t++, sim >>= 1ULL) { - if (sim & 1ULL) + for (t = 0; t < 48 && sim; t++, sim >>= 1) { + if (sim & 1) printf("%" PRId64 " ", t); } printf("\n"); diff --git a/test/101_coord_invcoord_h48/00_all.in b/test/101_coord_invcoord_h48/00_all.in deleted file mode 100644 index a2f9540..0000000 --- a/test/101_coord_invcoord_h48/00_all.in +++ /dev/null @@ -1,8 +0,0 @@ -UB0 DF0 DB0 UF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 -UF0 UB0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 -UB0 UF0 DB0 DF0 UL0 UR0 DL0 DR0 FR0 FL0 BL0 BR0 UBL0 UFR0 DFL0 DBR0 UBR0 UFL0 DFR0 DBL0 -UL0 BL0 BR1 DL0 FR0 DF0 DB1 DR1 UB0 FL0 UF0 UR1 DFL0 UFR1 DBR1 UBR2 DBL2 DFR0 UFL1 UBL2 -UF0 UB0 DB0 DF0 FR0 UL0 DL0 BR0 DR0 FL0 BL0 UR0 DFR2 UBL0 DFL0 UBR2 UFL0 UFR1 DBR1 DBL0 -FL1 UB0 DB0 FR1 UR0 UL0 DL0 DR0 UF1 DF1 BL0 BR0 UFL1 UBL0 DFR1 DBR0 DFL2 UBR0 UFR2 DBL0 -FR0 BR0 BL0 FL0 UR0 UL0 DL0 DR0 DF0 UF0 UB0 DB0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 -UR0 UL0 DL0 DR0 UB0 UF0 DF0 DB0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 diff --git a/test/101_coord_invcoord_h48/00_all.out b/test/101_coord_invcoord_h48/00_all.out deleted file mode 100644 index e84be4b..0000000 --- a/test/101_coord_invcoord_h48/00_all.out +++ /dev/null @@ -1,8 +0,0 @@ -1 ok -2 ok -3 ok -4 ok -5 ok -6 ok -7 ok -8 ok diff --git a/test/101_coord_invcoord_h48/coord_invcoord_h48_tests.c b/test/101_coord_invcoord_h48/coord_invcoord_h48_tests.c deleted file mode 100644 index e7858df..0000000 --- a/test/101_coord_invcoord_h48/coord_invcoord_h48_tests.c +++ /dev/null @@ -1,40 +0,0 @@ -#include "../test.h" - -#define COCSEP_CLASSES 3393U - -size_t gendata_cocsep(void *, uint64_t *, cube_fast_t *); -int64_t coord_h48(cube_fast_t, const uint32_t *, uint8_t); -cube_fast_t invcoord_h48(int64_t, const cube_fast_t *, uint8_t); -cube_fast_t transform(cube_fast_t, uint8_t); - -int main(void) { - char str[STRLENMAX]; - int i; - bool found; - uint8_t h, t; - uint32_t cocsepdata[300000]; - uint64_t selfsim[COCSEP_CLASSES]; - int64_t c, cc; - cube_t cube; - cube_fast_t fast, invc, rep[COCSEP_CLASSES]; - - gendata_cocsep(cocsepdata, selfsim, rep); - - i = 1; - h = 11; - while (fgets(str, STRLENMAX, stdin) != NULL) { - cube = readcube("H48", str); - fast = cubetofast(cube); - c = coord_h48(fast, cocsepdata, h); - invc = invcoord_h48(c, rep, h); - for (t = 0, found = false; t < 48; t++) { - fast = transform(invc, t); - cc = coord_h48(fast, cocsepdata, h); - found = found || cc == c; - } - printf("%d %s\n", i, found ? "ok" : "ERROR"); - i++; - } - - return 0; -} diff --git a/test/102_coord_invcoord_h48/00_all.in b/test/102_coord_invcoord_h48/00_all.in new file mode 100644 index 0000000..a2f9540 --- /dev/null +++ b/test/102_coord_invcoord_h48/00_all.in @@ -0,0 +1,8 @@ +UB0 DF0 DB0 UF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 +UF0 UB0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 +UB0 UF0 DB0 DF0 UL0 UR0 DL0 DR0 FR0 FL0 BL0 BR0 UBL0 UFR0 DFL0 DBR0 UBR0 UFL0 DFR0 DBL0 +UL0 BL0 BR1 DL0 FR0 DF0 DB1 DR1 UB0 FL0 UF0 UR1 DFL0 UFR1 DBR1 UBR2 DBL2 DFR0 UFL1 UBL2 +UF0 UB0 DB0 DF0 FR0 UL0 DL0 BR0 DR0 FL0 BL0 UR0 DFR2 UBL0 DFL0 UBR2 UFL0 UFR1 DBR1 DBL0 +FL1 UB0 DB0 FR1 UR0 UL0 DL0 DR0 UF1 DF1 BL0 BR0 UFL1 UBL0 DFR1 DBR0 DFL2 UBR0 UFR2 DBL0 +FR0 BR0 BL0 FL0 UR0 UL0 DL0 DR0 DF0 UF0 UB0 DB0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 +UR0 UL0 DL0 DR0 UB0 UF0 DF0 DB0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 diff --git a/test/102_coord_invcoord_h48/00_all.out b/test/102_coord_invcoord_h48/00_all.out new file mode 100644 index 0000000..e84be4b --- /dev/null +++ b/test/102_coord_invcoord_h48/00_all.out @@ -0,0 +1,8 @@ +1 ok +2 ok +3 ok +4 ok +5 ok +6 ok +7 ok +8 ok diff --git a/test/102_coord_invcoord_h48/coord_invcoord_h48_tests.c b/test/102_coord_invcoord_h48/coord_invcoord_h48_tests.c new file mode 100644 index 0000000..5022608 --- /dev/null +++ b/test/102_coord_invcoord_h48/coord_invcoord_h48_tests.c @@ -0,0 +1,40 @@ +#include "../test.h" + +#define COCSEP_CLASSES 3393 + +size_t gendata_cocsep(void *, uint64_t *, cube_fast_t *); +int64_t coord_h48(cube_fast_t, const uint32_t *, uint8_t); +cube_fast_t invcoord_h48(int64_t, const cube_fast_t *, uint8_t); +cube_fast_t transform(cube_fast_t, uint8_t); + +int main(void) { + char str[STRLENMAX]; + int i; + bool found; + uint8_t h, t; + uint32_t cocsepdata[300000]; + uint64_t selfsim[COCSEP_CLASSES]; + int64_t c, cc; + cube_t cube; + cube_fast_t fast, invc, rep[COCSEP_CLASSES]; + + gendata_cocsep(cocsepdata, selfsim, rep); + + i = 1; + h = 11; + while (fgets(str, STRLENMAX, stdin) != NULL) { + cube = readcube("H48", str); + fast = cubetofast(cube); + c = coord_h48(fast, cocsepdata, h); + invc = invcoord_h48(c, rep, h); + for (t = 0, found = false; t < 48; t++) { + fast = transform(invc, t); + cc = coord_h48(fast, cocsepdata, h); + found = found || cc == c; + } + printf("%d %s\n", i, found ? "ok" : "ERROR"); + i++; + } + + return 0; +} diff --git a/test/102_gendata_h48/00_h_0.in b/test/102_gendata_h48/00_h_0.in deleted file mode 100644 index 573541a..0000000 --- a/test/102_gendata_h48/00_h_0.in +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/test/102_gendata_h48/00_h_0.out b/test/102_gendata_h48/00_h_0.out deleted file mode 100644 index db6e121..0000000 --- a/test/102_gendata_h48/00_h_0.out +++ /dev/null @@ -1,23 +0,0 @@ -59903545 - -cocsepdata: -Classes: 3393 -Max value: 9 -0: 1 -1: 6 -2: 63 -3: 468 -4: 3068 -5: 15438 -6: 53814 -7: 71352 -8: 8784 -9: 96 - -h48: -0: 1 -1: 1 -2: 4 -3: 34 -4: 329 -5: 3587 diff --git a/test/102_gendata_h48/01_h_1.in b/test/102_gendata_h48/01_h_1.in deleted file mode 100644 index d00491f..0000000 --- a/test/102_gendata_h48/01_h_1.in +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/test/102_gendata_h48/01_h_1.out b/test/102_gendata_h48/01_h_1.out deleted file mode 100644 index 456305d..0000000 --- a/test/102_gendata_h48/01_h_1.out +++ /dev/null @@ -1,23 +0,0 @@ -118687270 - -cocsepdata: -Classes: 3393 -Max value: 9 -0: 1 -1: 6 -2: 63 -3: 468 -4: 3068 -5: 15438 -6: 53814 -7: 71352 -8: 8784 -9: 96 - -h48: -0: 1 -1: 1 -2: 4 -3: 34 -4: 375 -5: 4078 diff --git a/test/102_gendata_h48/gendata_h48_tests.c b/test/102_gendata_h48/gendata_h48_tests.c deleted file mode 100644 index 9d96e75..0000000 --- a/test/102_gendata_h48/gendata_h48_tests.c +++ /dev/null @@ -1,35 +0,0 @@ -#include "../test.h" - -#define MAXDEPTH 5 -#define COCSEPSIZE 1119792 -#define ETABLESIZE(h) (((3393 * 495 * 70) >> 1) << (h)) - -size_t gendata_h48(void *, uint8_t, uint8_t); - -int main(void) { - char str[STRLENMAX]; - uint8_t h, i; - uint32_t *buf, *h48info; - size_t result; - - fgets(str, STRLENMAX, stdin); - h = atoi(str); - buf = (uint32_t *)malloc(sizeof(uint32_t) * (60000000 << h)); - result = gendata_h48(buf, h, MAXDEPTH); - h48info = buf + (ETABLESIZE(h) + COCSEPSIZE) / 4; - - printf("%zu\n\n", result); - - printf("cocsepdata:\n"); - printf("Classes: %" PRIu32 "\n", buf[COCSEPSIZE/4-12]); - printf("Max value: %" PRIu32 "\n", buf[COCSEPSIZE/4-11]); - for (i = 0; i < 10; i++) - printf("%" PRIu32 ": %" PRIu32 "\n", i, buf[COCSEPSIZE/4-10+i]); - - printf("\nh48:\n"); - for (i = 0; i < MAXDEPTH+1; i++) - printf("%" PRIu32 ": %" PRIu32 "\n", i, h48info[i+1]); - - free(buf); - return 0; -} diff --git a/test/103_gendata_h48/00_h_0.in b/test/103_gendata_h48/00_h_0.in new file mode 100644 index 0000000..573541a --- /dev/null +++ b/test/103_gendata_h48/00_h_0.in @@ -0,0 +1 @@ +0 diff --git a/test/103_gendata_h48/00_h_0.out b/test/103_gendata_h48/00_h_0.out new file mode 100644 index 0000000..db6e121 --- /dev/null +++ b/test/103_gendata_h48/00_h_0.out @@ -0,0 +1,23 @@ +59903545 + +cocsepdata: +Classes: 3393 +Max value: 9 +0: 1 +1: 6 +2: 63 +3: 468 +4: 3068 +5: 15438 +6: 53814 +7: 71352 +8: 8784 +9: 96 + +h48: +0: 1 +1: 1 +2: 4 +3: 34 +4: 329 +5: 3587 diff --git a/test/103_gendata_h48/01_h_1.in b/test/103_gendata_h48/01_h_1.in new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/test/103_gendata_h48/01_h_1.in @@ -0,0 +1 @@ +1 diff --git a/test/103_gendata_h48/01_h_1.out b/test/103_gendata_h48/01_h_1.out new file mode 100644 index 0000000..456305d --- /dev/null +++ b/test/103_gendata_h48/01_h_1.out @@ -0,0 +1,23 @@ +118687270 + +cocsepdata: +Classes: 3393 +Max value: 9 +0: 1 +1: 6 +2: 63 +3: 468 +4: 3068 +5: 15438 +6: 53814 +7: 71352 +8: 8784 +9: 96 + +h48: +0: 1 +1: 1 +2: 4 +3: 34 +4: 375 +5: 4078 diff --git a/test/103_gendata_h48/gendata_h48_tests.c b/test/103_gendata_h48/gendata_h48_tests.c new file mode 100644 index 0000000..f0910cc --- /dev/null +++ b/test/103_gendata_h48/gendata_h48_tests.c @@ -0,0 +1,35 @@ +#include "../test.h" + +#define MAXDEPTH 5 +#define COCSEPSIZE 1119792 +#define ETABLESIZE(h) (((3393 * 495 * 70) >> 1) << (size_t)(h)) + +size_t gendata_h48(void *, uint8_t, uint8_t); + +int main(void) { + char str[STRLENMAX]; + uint8_t h, i; + uint32_t *buf, *h48info; + size_t result; + + fgets(str, STRLENMAX, stdin); + h = atoi(str); + buf = (uint32_t *)malloc(sizeof(uint32_t) * (60000000 << h)); + result = gendata_h48(buf, h, MAXDEPTH); + h48info = buf + (ETABLESIZE(h) + COCSEPSIZE) / 4; + + printf("%zu\n\n", result); + + printf("cocsepdata:\n"); + printf("Classes: %" PRIu32 "\n", buf[COCSEPSIZE/4-12]); + printf("Max value: %" PRIu32 "\n", buf[COCSEPSIZE/4-11]); + for (i = 0; i < 10; i++) + printf("%" PRIu32 ": %" PRIu32 "\n", i, buf[COCSEPSIZE/4-10+i]); + + printf("\nh48:\n"); + for (i = 0; i < MAXDEPTH+1; i++) + printf("%" PRIu32 ": %" PRIu32 "\n", i, h48info[i+1]); + + free(buf); + return 0; +} -- cgit v1.3