aboutsummaryrefslogtreecommitdiff
path: root/test/112_gendata_h48short
diff options
context:
space:
mode:
Diffstat (limited to 'test/112_gendata_h48short')
-rw-r--r--test/112_gendata_h48short/00_depth_1.in28
-rw-r--r--test/112_gendata_h48short/00_depth_1.out3
-rw-r--r--test/112_gendata_h48short/01_depth_3.in3
-rw-r--r--test/112_gendata_h48short/01_depth_3.out40
-rw-r--r--test/112_gendata_h48short/gendata_h48short_tests.c88
5 files changed, 162 insertions, 0 deletions
diff --git a/test/112_gendata_h48short/00_depth_1.in b/test/112_gendata_h48short/00_depth_1.in
new file mode 100644
index 0000000..c86f15b
--- /dev/null
+++ b/test/112_gendata_h48short/00_depth_1.in
@@ -0,0 +1,28 @@
173
2157
31
4
5For longer test:
6
720000003
820000023
98
10
11Short h48: generating depth 0
12found 1
13Short h48: generating depth 1
14found 1
15Short h48: generating depth 2
16found 4
17Short h48: generating depth 3
18found 34
19Short h48: generating depth 4
20found 333
21Short h48: generating depth 5
22found 3815
23Short h48: generating depth 6
24found 45382
25Short h48: generating depth 7
26found 548562
27Short h48: generating depth 8
28found 6839723
diff --git a/test/112_gendata_h48short/00_depth_1.out b/test/112_gendata_h48short/00_depth_1.out
new file mode 100644
index 0000000..b0dba31
--- /dev/null
+++ b/test/112_gendata_h48short/00_depth_1.out
@@ -0,0 +1,3 @@
12
20 0
371075840 1
diff --git a/test/112_gendata_h48short/01_depth_3.in b/test/112_gendata_h48short/01_depth_3.in
new file mode 100644
index 0000000..920e70a
--- /dev/null
+++ b/test/112_gendata_h48short/01_depth_3.in
@@ -0,0 +1,3 @@
173
2157
33
diff --git a/test/112_gendata_h48short/01_depth_3.out b/test/112_gendata_h48short/01_depth_3.out
new file mode 100644
index 0000000..dbce376
--- /dev/null
+++ b/test/112_gendata_h48short/01_depth_3.out
@@ -0,0 +1,40 @@
140
20 0
370981632 3
471075840 1
571086080 3
6142067712 2
7218789888 3
8218884096 2
9283879424 2
10283899904 3
11283953152 3
12283973632 2
13360548808 3
14360835072 3
15473668032 3
16473956352 3
17499869696 3
18500011008 3
19598679552 3
20599109185 3
21662171648 3
22662601226 3
23724818316 3
24725106688 3
25790513664 3
26790607872 3
27904991108 3
28926726144 3
29928729088 3
301009662340 3
311088755203 3
321171758595 3
331206452224 3
341206480896 3
351277360128 3
361277454336 3
371403695492 3
381403697540 3
391403736452 3
401403738500 3
diff --git a/test/112_gendata_h48short/gendata_h48short_tests.c b/test/112_gendata_h48short/gendata_h48short_tests.c
new file mode 100644
index 0000000..fb432d3
--- /dev/null
+++ b/test/112_gendata_h48short/gendata_h48short_tests.c
@@ -0,0 +1,88 @@
1#include "../test.h"
2
3#define COCSEP_CLASSES 3393
4#define INFOSIZE 512
5#define MAXPOS 200
6
7typedef struct {
8 uint64_t n;
9 uint64_t capacity;
10 uint64_t randomizer;
11 uint64_t *table;
12 uint32_t *info;
13 uint32_t *cocsepdata;
14 uint32_t *h48data;
15 uint64_t selfsim[COCSEP_CLASSES];
16 cube_t crep[COCSEP_CLASSES];
17} h48map_t;
18
19typedef struct {
20 uint64_t key;
21 uint64_t val;
22} kvpair_t;
23
24typedef struct {
25 uint8_t maxdepth;
26 const uint32_t *cocsepdata;
27 const cube_t *crep;
28 const uint64_t *selfsim;
29 h48map_t *map;
30} gendata_h48short_arg_t;
31
32void h48map_create(h48map_t *, uint64_t, uint64_t);
33void h48map_destroy(h48map_t *);
34kvpair_t h48map_nextkvpair(h48map_t *, uint64_t *);
35size_t gendata_cocsep(void *, uint64_t *, cube_t *);
36uint64_t gendata_h48short(gendata_h48short_arg_t *);
37
38char str[STRLENMAX];
39
40int compare(const void *x, const void *y) {
41 uint64_t a = ((kvpair_t *)x)->key;
42 uint64_t b = ((kvpair_t *)y)->key;
43
44 if (a > b) return 1;
45 if (a == b) return 0;
46 return -1;
47}
48
49uint64_t readl(void) {
50 fgets(str, STRLENMAX, stdin);
51 return atoll(str);
52}
53
54void run(void) {
55 char buf[2000000];
56 h48map_t map;
57 uint64_t i, j, capacity, randomizer, selfsim[COCSEP_CLASSES];
58 kvpair_t kv, b[MAXPOS];
59 gendata_h48short_arg_t arg;
60 cube_t crep[COCSEP_CLASSES];
61
62 capacity = readl();
63 randomizer = readl();
64 arg.maxdepth = readl();
65 arg.crep = crep;
66 arg.selfsim = selfsim;
67 arg.map = ↦
68
69 h48map_create(&map, capacity, randomizer);
70 gendata_cocsep(buf, selfsim, crep);
71 arg.cocsepdata = (uint32_t *)((char *)buf + INFOSIZE);
72 gendata_h48short(&arg);
73
74 i = 0;
75 for (kv = h48map_nextkvpair(&map, &i), j = 0;
76 i != map.capacity && j < MAXPOS;
77 kv = h48map_nextkvpair(&map, &i)
78 ) {
79 b[j++] = kv;
80 }
81 qsort(b, j, sizeof(kvpair_t), compare);
82
83 printf("%" PRIu64 "\n", map.n);
84 for (i = 0; i < j; i++)
85 printf("%" PRIu64 " %" PRIu64 "\n", b[i].key, b[i].val);
86
87 h48map_destroy(&map);
88}

Generated with cgit - Back to sebastiano.tronto.net