aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2025-03-28 20:57:04 +0100
committerSebastiano Tronto <sebastiano@tronto.net>2025-03-28 20:57:04 +0100
commit0f23987edbbabdf88fbe175f695b4fdb727586fd (patch)
tree00e523aa0b714698768e62070e7bda09f2bdad3b /test
parent50fedbdbf98bcf01bcd95259ac5a93ae108b3c68 (diff)
downloadnissy-core-0f23987edbbabdf88fbe175f695b4fdb727586fd.tar.gz
nissy-core-0f23987edbbabdf88fbe175f695b4fdb727586fd.zip
DR coordinate solver
Diffstat (limited to '')
-rw-r--r--test/121_coorddata_dr/00_all.in0
-rw-r--r--test/121_coorddata_dr/00_all.out1
-rw-r--r--test/121_coorddata_dr/coorddata_dr.c59
-rw-r--r--test/test.h2
4 files changed, 61 insertions, 1 deletions
diff --git a/test/121_coorddata_dr/00_all.in b/test/121_coorddata_dr/00_all.in
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/121_coorddata_dr/00_all.in
diff --git a/test/121_coorddata_dr/00_all.out b/test/121_coorddata_dr/00_all.out
new file mode 100644
index 0000000..d6109db
--- /dev/null
+++ b/test/121_coorddata_dr/00_all.out
@@ -0,0 +1 @@
All good
diff --git a/test/121_coorddata_dr/coorddata_dr.c b/test/121_coorddata_dr/coorddata_dr.c
new file mode 100644
index 0000000..92e7c2a
--- /dev/null
+++ b/test/121_coorddata_dr/coorddata_dr.c
@@ -0,0 +1,59 @@
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 void *);
9cube_t coordinate_dr_cube(uint64_t, const void *);
10uint64_t coordinate_dr_gendata(void *);
11
12void run(void) {
13 bool found;
14 uint64_t t;
15 char str[STRLENMAX];
16 void *data;
17 size_t size;
18 cube_t cube;
19 uint64_t coord, coord2;
20
21 size = coordinate_dr_gendata(NULL);
22 data = malloc(size);
23 coordinate_dr_gendata(data);
24
25 /* Test all possible values for CO coordinate */
26 for (coord = 0; coord < BOUND; coord++) {
27 cube = coordinate_dr_cube(coord, data);
28
29 if (!isconsistent(cube)) {
30 printf("Error: invcoord of %" PRId64
31 " is not consistent\n", coord);
32 goto cleanup;
33 }
34
35 for (t = 0, found = false; t < 48; t++) {
36 if (!((UINT64_C(1) << t) & TGROUP))
37 continue;
38
39 coord2 = coordinate_dr_coord(transform(cube, t), data);
40 if (coord == coord2) {
41 found = true;
42 break;
43 }
44 }
45
46 if (!found) {
47 printf("Error: invcoord of %" PRId64 " returns %"
48 PRId64 " with cube:\n", coord, coord2);
49 writecube("H48", cube, STRLENMAX, str);
50 printf("%s\n", str);
51 goto cleanup;
52 }
53 }
54
55 printf("All good\n");
56
57cleanup:
58 free(data);
59}
diff --git a/test/test.h b/test/test.h
index e753977..615402b 100644
--- a/test/test.h
+++ b/test/test.h
@@ -26,7 +26,7 @@ bool isconsistent(cube_t);
26bool issolvable(cube_t); 26bool issolvable(cube_t);
27bool issolved(cube_t); 27bool issolved(cube_t);
28cube_t readcube(char *, char *); 28cube_t readcube(char *, char *);
29int64_t writecube(char *, cube_t, size_t n, char [n]); 29int64_t writecube(const char *, cube_t, size_t n, char [n]);
30 30
31/* Test function to be implemented by all tests */ 31/* Test function to be implemented by all tests */
32void run(void); 32void run(void);

Generated with cgit - Back to sebastiano.tronto.net