aboutsummaryrefslogtreecommitdiff
path: root/test/131_coorddata_dr
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2025-07-17 08:54:44 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2025-07-17 08:54:44 +0200
commit270e5b0444f67781856bf80db51650af9cb89b0c (patch)
tree1f895ca8fdbf256dcdf550dd0a28ca99993efc08 /test/131_coorddata_dr
parent2d0ab15ac1f81c76cb6bb31bbdad3d2ee339e062 (diff)
downloadnissy-core-270e5b0444f67781856bf80db51650af9cb89b0c.tar.gz
nissy-core-270e5b0444f67781856bf80db51650af9cb89b0c.zip
Renamed tests to make space for more coordinate tests
Diffstat (limited to 'test/131_coorddata_dr')
-rw-r--r--test/131_coorddata_dr/00_all.in0
-rw-r--r--test/131_coorddata_dr/00_all.out1
-rw-r--r--test/131_coorddata_dr/coorddata_dr.c61
3 files changed, 62 insertions, 0 deletions
diff --git a/test/131_coorddata_dr/00_all.in b/test/131_coorddata_dr/00_all.in
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/131_coorddata_dr/00_all.in
diff --git a/test/131_coorddata_dr/00_all.out b/test/131_coorddata_dr/00_all.out
new file mode 100644
index 0000000..d6109db
--- /dev/null
+++ b/test/131_coorddata_dr/00_all.out
@@ -0,0 +1 @@
All good
diff --git a/test/131_coorddata_dr/coorddata_dr.c b/test/131_coorddata_dr/coorddata_dr.c
new file mode 100644
index 0000000..d8ac94a
--- /dev/null
+++ b/test/131_coorddata_dr/coorddata_dr.c
@@ -0,0 +1,61 @@
1#include "../test.h"
2
3#define POW_3_7 2187
4#define BOUND (64430 * POW_3_7 / 100)
5#define TGROUP UINT64_C(4278190335)
6
7cube_t transform(cube_t, uint8_t);
8uint64_t coordinate_dr_coord(cube_t, const unsigned char *);
9cube_t coordinate_dr_cube(uint64_t, const unsigned char *);
10size_t coordinate_dr_gendata(unsigned char *);
11
12void run(void) {
13 bool found;
14 uint64_t t;
15 char str[STRLENMAX];
16 unsigned char *data;
17 size_t size;
18 cube_t cube;
19 oriented_cube_t oc;
20 uint64_t coord, coord2;
21
22 size = coordinate_dr_gendata(NULL);
23 data = malloc(size);
24 coordinate_dr_gendata(data);
25
26 for (coord = 0; coord < BOUND; coord++) {
27 cube = coordinate_dr_cube(coord, data);
28
29 oc = (oriented_cube_t) { .cube = cube, .orientation = 0 };
30 if (!isconsistent(oc)) {
31 printf("Error: invcoord of %" PRId64
32 " is not consistent\n", coord);
33 goto cleanup;
34 }
35
36 for (t = 0, found = false; t < 48; t++) {
37 if (!((UINT64_C(1) << t) & TGROUP))
38 continue;
39
40 coord2 = coordinate_dr_coord(transform(cube, t), data);
41 if (coord == coord2) {
42 found = true;
43 break;
44 }
45 }
46
47 if (!found) {
48 oc = (oriented_cube_t){.cube = cube, .orientation = 0};
49 printf("Error: invcoord of %" PRId64 " returns %"
50 PRId64 " with cube:\n", coord, coord2);
51 writecube(oc, STRLENMAX, str);
52 printf("%s\n", str);
53 goto cleanup;
54 }
55 }
56
57 printf("All good\n");
58
59cleanup:
60 free(data);
61}

Generated with cgit - Back to sebastiano.tronto.net