diff options
author | Mattias Andrée <maandree@kth.se> | 2024-09-04 17:41:55 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2024-09-04 17:41:55 +0200 |
commit | 99d71e6cd149414dd97f521cae418b49087334bb (patch) | |
tree | 6e6a086284779110f7b4bd2bce0f4dcf398ee22e /common.h | |
parent | Move test files into t/ (diff) | |
download | libhashsum-99d71e6cd149414dd97f521cae418b49087334bb.tar.gz libhashsum-99d71e6cd149414dd97f521cae418b49087334bb.tar.bz2 libhashsum-99d71e6cd149414dd97f521cae418b49087334bb.tar.xz |
tests: check .supports_non_whole_bytes
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'common.h')
-rw-r--r-- | common.h | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -109,7 +109,8 @@ escape(const char *s, size_t n) static int run_tests(const char *name, enum libhashsum_algorithm algorithm, size_t hash_size, - struct testcase *testcases, size_t ntestcases, char hexsum[]) + struct testcase *testcases, size_t ntestcases, char hexsum[], + unsigned char supports_non_whole_bytes) { struct libhashsum_hasher hasher, hasher2; unsigned char custom_hashbuffer[2048]; @@ -161,6 +162,10 @@ run_tests(const char *name, enum libhashsum_algorithm algorithm, size_t hash_siz fprintf(stderr, "libhashsum_init_hasher returned non-NULL pointer in .stretch\n"); return 2; } + if (hasher.supports_non_whole_bytes != supports_non_whole_bytes) { + fprintf(stderr, "libhashsum_init_hasher returned unexpected value in .supports_non_whole_bytes\n"); + return 2; + } input_string_len = strlen(testcases[i].input); bits = testcases[i].extra_bits; if (bits) { @@ -260,10 +265,11 @@ run_tests(const char *name, enum libhashsum_algorithm algorithm, size_t hash_siz return !ok; } -# define TEST_MAIN(NAME, ID)\ +# define TEST_MAIN(NAME, ID, SUPPORTS_NON_WHOLE_BYTES)\ char hexsum[LIBHASHSUM_##ID##_HASH_SIZE * 2 + 1];\ return run_tests(NAME, LIBHASHSUM_##ID, LIBHASHSUM_##ID##_HASH_SIZE,\ - testcases, sizeof(testcases) / sizeof(*testcases), hexsum) + testcases, sizeof(testcases) / sizeof(*testcases), hexsum,\ + (SUPPORTS_NON_WHOLE_BYTES)) # define ASSERT(ASSERTION)\ do {\ |