diff options
Diffstat (limited to 'test/090_tables_readwrite')
| -rw-r--r-- | test/090_tables_readwrite/00_table.in | 31 | ||||
| -rw-r--r-- | test/090_tables_readwrite/00_table.out | 31 | ||||
| -rw-r--r-- | test/090_tables_readwrite/tables_readwrite_tests.c | 84 |
3 files changed, 146 insertions, 0 deletions
diff --git a/test/090_tables_readwrite/00_table.in b/test/090_tables_readwrite/00_table.in new file mode 100644 index 0000000..1816242 --- /dev/null +++ b/test/090_tables_readwrite/00_table.in | |||
| @@ -0,0 +1,31 @@ | |||
| 1 | Test solver | ||
| 2 | |||
| 3 | 512 | ||
| 4 | 100000000000 | ||
| 5 | 12345678912345 | ||
| 6 | 399999999998 | ||
| 7 | 2 | ||
| 8 | 0 | ||
| 9 | 20 | ||
| 10 | |||
| 11 | 100 | ||
| 12 | 101 | ||
| 13 | 102 | ||
| 14 | 103 | ||
| 15 | 104 | ||
| 16 | 105 | ||
| 17 | 106 | ||
| 18 | 107 | ||
| 19 | 108 | ||
| 20 | 109 | ||
| 21 | 110 | ||
| 22 | 111 | ||
| 23 | 112 | ||
| 24 | 113 | ||
| 25 | 114 | ||
| 26 | 115 | ||
| 27 | 116 | ||
| 28 | 117 | ||
| 29 | 118 | ||
| 30 | 119 | ||
| 31 | 120 | ||
diff --git a/test/090_tables_readwrite/00_table.out b/test/090_tables_readwrite/00_table.out new file mode 100644 index 0000000..1816242 --- /dev/null +++ b/test/090_tables_readwrite/00_table.out | |||
| @@ -0,0 +1,31 @@ | |||
| 1 | Test solver | ||
| 2 | |||
| 3 | 512 | ||
| 4 | 100000000000 | ||
| 5 | 12345678912345 | ||
| 6 | 399999999998 | ||
| 7 | 2 | ||
| 8 | 0 | ||
| 9 | 20 | ||
| 10 | |||
| 11 | 100 | ||
| 12 | 101 | ||
| 13 | 102 | ||
| 14 | 103 | ||
| 15 | 104 | ||
| 16 | 105 | ||
| 17 | 106 | ||
| 18 | 107 | ||
| 19 | 108 | ||
| 20 | 109 | ||
| 21 | 110 | ||
| 22 | 111 | ||
| 23 | 112 | ||
| 24 | 113 | ||
| 25 | 114 | ||
| 26 | 115 | ||
| 27 | 116 | ||
| 28 | 117 | ||
| 29 | 118 | ||
| 30 | 119 | ||
| 31 | 120 | ||
diff --git a/test/090_tables_readwrite/tables_readwrite_tests.c b/test/090_tables_readwrite/tables_readwrite_tests.c new file mode 100644 index 0000000..97b8ab7 --- /dev/null +++ b/test/090_tables_readwrite/tables_readwrite_tests.c | |||
| @@ -0,0 +1,84 @@ | |||
| 1 | #include "../test.h" | ||
| 2 | |||
| 3 | #define INFOSIZE 512 | ||
| 4 | #define INFO_SOLVER_STRLEN 20 | ||
| 5 | #define INFO_DISTRIBUTION_LEN 21 | ||
| 6 | |||
| 7 | typedef struct { | ||
| 8 | char solver[INFO_SOLVER_STRLEN]; | ||
| 9 | uint64_t infosize; | ||
| 10 | uint64_t fullsize; | ||
| 11 | uint64_t hash; | ||
| 12 | uint64_t entries; | ||
| 13 | uint8_t bits; | ||
| 14 | uint8_t base; | ||
| 15 | uint8_t maxvalue; | ||
| 16 | uint64_t distribution[INFO_DISTRIBUTION_LEN]; | ||
| 17 | } tableinfo_t; | ||
| 18 | |||
| 19 | bool readtableinfo(const void *, tableinfo_t *); | ||
| 20 | bool writetableinfo(const tableinfo_t *, void *); | ||
| 21 | |||
| 22 | uint64_t readn(void) { | ||
| 23 | char str[STRLENMAX]; | ||
| 24 | |||
| 25 | fgets(str, STRLENMAX, stdin); | ||
| 26 | return atoll(str); | ||
| 27 | } | ||
| 28 | |||
| 29 | tableinfo_t test_readinfo(void) { | ||
| 30 | int i; | ||
| 31 | tableinfo_t ret; | ||
| 32 | char emptyline[2]; | ||
| 33 | |||
| 34 | fgets(ret.solver, INFO_SOLVER_STRLEN, stdin); | ||
| 35 | for (i = 0; i < INFO_SOLVER_STRLEN; i++) | ||
| 36 | if (ret.solver[i] == '\n') | ||
| 37 | ret.solver[i] = 0; | ||
| 38 | |||
| 39 | fgets(emptyline, 2, stdin); | ||
| 40 | |||
| 41 | ret.infosize = readn(); | ||
| 42 | ret.fullsize = readn(); | ||
| 43 | ret.hash = readn(); | ||
| 44 | ret.entries = readn(); | ||
| 45 | ret.bits = (uint8_t)readn(); | ||
| 46 | ret.base = (uint8_t)readn(); | ||
| 47 | ret.maxvalue = (uint8_t)readn(); | ||
| 48 | |||
| 49 | fgets(emptyline, 2, stdin); | ||
| 50 | |||
| 51 | for (i = 0; i < INFO_DISTRIBUTION_LEN; i++) | ||
| 52 | ret.distribution[i] = readn(); | ||
| 53 | |||
| 54 | return ret; | ||
| 55 | } | ||
| 56 | |||
| 57 | void test_writeinfo(tableinfo_t info) { | ||
| 58 | int i; | ||
| 59 | |||
| 60 | printf("%s\n", info.solver); | ||
| 61 | printf("\n"); | ||
| 62 | |||
| 63 | printf("%" PRIu64 "\n", info.infosize); | ||
| 64 | printf("%" PRIu64 "\n", info.fullsize); | ||
| 65 | printf("%" PRIu64 "\n", info.hash); | ||
| 66 | printf("%" PRIu64 "\n", info.entries); | ||
| 67 | printf("%" PRIu8 "\n", info.bits); | ||
| 68 | printf("%" PRIu8 "\n", info.base); | ||
| 69 | printf("%" PRIu8 "\n", info.maxvalue); | ||
| 70 | printf("\n"); | ||
| 71 | |||
| 72 | for (i = 0; i < INFO_DISTRIBUTION_LEN; i++) | ||
| 73 | printf("%" PRIu64 "\n", info.distribution[i]); | ||
| 74 | } | ||
| 75 | |||
| 76 | void run(void) { | ||
| 77 | char buf[INFOSIZE]; | ||
| 78 | tableinfo_t expected, actual; | ||
| 79 | |||
| 80 | expected = test_readinfo(); | ||
| 81 | writetableinfo(&expected, buf); | ||
| 82 | readtableinfo(buf, &actual); | ||
| 83 | test_writeinfo(actual); | ||
| 84 | } | ||
