From 270e5b0444f67781856bf80db51650af9cb89b0c Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Thu, 17 Jul 2025 08:54:44 +0200 Subject: Renamed tests to make space for more coordinate tests --- test/100_tables_readwrite/00_table.in | 35 ++++++++++ test/100_tables_readwrite/00_table.out | 35 ++++++++++ test/100_tables_readwrite/tables_readwrite_tests.c | 76 ++++++++++++++++++++++ 3 files changed, 146 insertions(+) create mode 100644 test/100_tables_readwrite/00_table.in create mode 100644 test/100_tables_readwrite/00_table.out create mode 100644 test/100_tables_readwrite/tables_readwrite_tests.c (limited to 'test/100_tables_readwrite') 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 @@ +Test solver + +0 +512 +512 +12345678912345 +399999999998 +3393 +11 +2 +0 +20 +100000000512 + +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 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 @@ +Test solver + +0 +512 +512 +12345678912345 +399999999998 +3393 +11 +2 +0 +20 +100000000512 + +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 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 @@ +#include "../test.h" + +int64_t readtableinfo(size_t, const unsigned char *, tableinfo_t *); +int64_t writetableinfo(const tableinfo_t *, size_t, unsigned char *); + +uint64_t readn(void) { + char str[STRLENMAX]; + + fgets(str, STRLENMAX, stdin); + return atoll(str); +} + +tableinfo_t test_readinfo(void) { + int i; + tableinfo_t ret; + char emptyline[2]; + + fgets(ret.solver, INFO_SOLVER_STRLEN, stdin); + for (i = 0; i < INFO_SOLVER_STRLEN; i++) + if (ret.solver[i] == '\n') + ret.solver[i] = 0; + + fgets(emptyline, 2, stdin); + + ret.type = readn(); + ret.infosize = readn(); + ret.fullsize = readn(); + ret.hash = readn(); + ret.entries = readn(); + ret.classes = readn(); + ret.h48h = (uint8_t)readn(); + ret.bits = (uint8_t)readn(); + ret.base = (uint8_t)readn(); + ret.maxvalue = (uint8_t)readn(); + ret.next = readn(); + + fgets(emptyline, 2, stdin); + + for (i = 0; i < INFO_DISTRIBUTION_LEN; i++) + ret.distribution[i] = readn(); + + return ret; +} + +void test_writeinfo(tableinfo_t info) { + int i; + + printf("%s\n", info.solver); + printf("\n"); + + printf("%" PRIu64 "\n", info.type); + printf("%" PRIu64 "\n", info.infosize); + printf("%" PRIu64 "\n", info.fullsize); + printf("%" PRIu64 "\n", info.hash); + printf("%" PRIu64 "\n", info.entries); + printf("%" PRIu64 "\n", info.classes); + printf("%" PRIu8 "\n", info.h48h); + printf("%" PRIu8 "\n", info.bits); + printf("%" PRIu8 "\n", info.base); + printf("%" PRIu8 "\n", info.maxvalue); + printf("%" PRIu64 "\n", info.next); + printf("\n"); + + for (i = 0; i < INFO_DISTRIBUTION_LEN; i++) + printf("%" PRIu64 "\n", info.distribution[i]); +} + +void run(void) { + unsigned char buf[INFOSIZE]; + tableinfo_t expected, actual; + + expected = test_readinfo(); + writetableinfo(&expected, INFOSIZE, buf); + readtableinfo(INFOSIZE, buf, &actual); + test_writeinfo(actual); +} -- cgit v1.3