aboutsummaryrefslogtreecommitdiffstats
path: root/common.h
diff options
context:
space:
mode:
Diffstat (limited to 'common.h')
-rw-r--r--common.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/common.h b/common.h
index e70d922..3d0972c 100644
--- a/common.h
+++ b/common.h
@@ -126,9 +126,11 @@ run_tests(const char *name, enum libhashsum_algorithm algorithm, size_t hash_siz
return 2;
}
for (j = 0; j < testcases[i].input_repeat; j++) {
- p = memcpy(p, testcases[i].input, input_string_len);
+ memcpy(p, testcases[i].input, input_string_len);
p = &p[input_string_len];
}
+ if (bits)
+ *p = testcases[i].input[input_string_len];
if (hasher.finalise(&hasher, input, input_total_len, (unsigned)bits, input_size)) {
perror("hasher.finalise");
return 2;
@@ -160,6 +162,12 @@ run_tests(const char *name, enum libhashsum_algorithm algorithm, size_t hash_siz
if (testcases[i].input_repeat == 1)
printf("[\033[1;%s\033[m] %s(\"%s\"%s) = %s\n",
caseok ? "32mPASS" : "31mFAIL", name, input, bitstr, hexsum);
+ else if (!testcases[i].input_repeat && *bitstr)
+ printf("[\033[1;%s\033[m] %s(%s) = %s\n",
+ caseok ? "32mPASS" : "31mFAIL", name, &bitstr[3], hexsum);
+ else if (!testcases[i].input_repeat)
+ printf("[\033[1;%s\033[m] %s(\"\") = %s\n",
+ caseok ? "32mPASS" : "31mFAIL", name, hexsum);
else
printf("[\033[1;%s\033[m] %s(%zu * \"%s\"%s) = %s\n",
caseok ? "32mPASS" : "31mFAIL", name, testcases[i].input_repeat, input, bitstr, hexsum);