aboutsummaryrefslogtreecommitdiffstats
path: root/common.h
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2024-09-04 17:41:55 +0200
committerMattias Andrée <maandree@kth.se>2024-09-04 17:41:55 +0200
commit99d71e6cd149414dd97f521cae418b49087334bb (patch)
tree6e6a086284779110f7b4bd2bce0f4dcf398ee22e /common.h
parentMove test files into t/ (diff)
downloadlibhashsum-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 '')
-rw-r--r--common.h12
1 files changed, 9 insertions, 3 deletions
diff --git a/common.h b/common.h
index 18d817c..c784f1b 100644
--- a/common.h
+++ b/common.h
@@ -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 {\