aboutsummaryrefslogtreecommitdiff
path: root/test/100_tables_readwrite
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/100_tables_readwrite
parent2d0ab15ac1f81c76cb6bb31bbdad3d2ee339e062 (diff)
downloadnissy-core-270e5b0444f67781856bf80db51650af9cb89b0c.tar.gz
nissy-core-270e5b0444f67781856bf80db51650af9cb89b0c.zip
Renamed tests to make space for more coordinate tests
Diffstat (limited to 'test/100_tables_readwrite')
-rw-r--r--test/100_tables_readwrite/00_table.in35
-rw-r--r--test/100_tables_readwrite/00_table.out35
-rw-r--r--test/100_tables_readwrite/tables_readwrite_tests.c76
3 files changed, 146 insertions, 0 deletions
diff --git a/test/100_tables_readwrite/00_table.in b/test/100_tables_readwrite/00_table.in
new file mode 100644
index 0000000..3c2da46
--- /dev/null
+++ b/test/100_tables_readwrite/00_table.in
@@ -0,0 +1,35 @@
1Test solver
2
30
4512
5512
612345678912345
7399999999998
83393
911
102
110
1220
13100000000512
14
15100
16101
17102
18103
19104
20105
21106
22107
23108
24109
25110
26111
27112
28113
29114
30115
31116
32117
33118
34119
35120
diff --git a/test/100_tables_readwrite/00_table.out b/test/100_tables_readwrite/00_table.out
new file mode 100644
index 0000000..3c2da46
--- /dev/null
+++ b/test/100_tables_readwrite/00_table.out
@@ -0,0 +1,35 @@
1Test solver
2
30
4512
5512
612345678912345
7399999999998
83393
911
102
110
1220
13100000000512
14
15100
16101
17102
18103
19104
20105
21106
22107
23108
24109
25110
26111
27112
28113
29114
30115
31116
32117
33118
34119
35120
diff --git a/test/100_tables_readwrite/tables_readwrite_tests.c b/test/100_tables_readwrite/tables_readwrite_tests.c
new file mode 100644
index 0000000..96a60bb
--- /dev/null
+++ b/test/100_tables_readwrite/tables_readwrite_tests.c
@@ -0,0 +1,76 @@
1#include "../test.h"
2
3int64_t readtableinfo(size_t, const unsigned char *, tableinfo_t *);
4int64_t writetableinfo(const tableinfo_t *, size_t, unsigned char *);
5
6uint64_t readn(void) {
7 char str[STRLENMAX];
8
9 fgets(str, STRLENMAX, stdin);
10 return atoll(str);
11}
12
13tableinfo_t test_readinfo(void) {
14 int i;
15 tableinfo_t ret;
16 char emptyline[2];
17
18 fgets(ret.solver, INFO_SOLVER_STRLEN, stdin);
19 for (i = 0; i < INFO_SOLVER_STRLEN; i++)
20 if (ret.solver[i] == '\n')
21 ret.solver[i] = 0;
22
23 fgets(emptyline, 2, stdin);
24
25 ret.type = readn();
26 ret.infosize = readn();
27 ret.fullsize = readn();
28 ret.hash = readn();
29 ret.entries = readn();
30 ret.classes = readn();
31 ret.h48h = (uint8_t)readn();
32 ret.bits = (uint8_t)readn();
33 ret.base = (uint8_t)readn();
34 ret.maxvalue = (uint8_t)readn();
35 ret.next = readn();
36
37 fgets(emptyline, 2, stdin);
38
39 for (i = 0; i < INFO_DISTRIBUTION_LEN; i++)
40 ret.distribution[i] = readn();
41
42 return ret;
43}
44
45void test_writeinfo(tableinfo_t info) {
46 int i;
47
48 printf("%s\n", info.solver);
49 printf("\n");
50
51 printf("%" PRIu64 "\n", info.type);
52 printf("%" PRIu64 "\n", info.infosize);
53 printf("%" PRIu64 "\n", info.fullsize);
54 printf("%" PRIu64 "\n", info.hash);
55 printf("%" PRIu64 "\n", info.entries);
56 printf("%" PRIu64 "\n", info.classes);
57 printf("%" PRIu8 "\n", info.h48h);
58 printf("%" PRIu8 "\n", info.bits);
59 printf("%" PRIu8 "\n", info.base);
60 printf("%" PRIu8 "\n", info.maxvalue);
61 printf("%" PRIu64 "\n", info.next);
62 printf("\n");
63
64 for (i = 0; i < INFO_DISTRIBUTION_LEN; i++)
65 printf("%" PRIu64 "\n", info.distribution[i]);
66}
67
68void run(void) {
69 unsigned char buf[INFOSIZE];
70 tableinfo_t expected, actual;
71
72 expected = test_readinfo();
73 writetableinfo(&expected, INFOSIZE, buf);
74 readtableinfo(INFOSIZE, buf, &actual);
75 test_writeinfo(actual);
76}

Generated with cgit - Back to sebastiano.tronto.net