diff options
Diffstat (limited to '')
-rw-r--r-- | common.h | 34 |
1 files changed, 26 insertions, 8 deletions
@@ -160,17 +160,17 @@ run_tests(const char *name, enum libhashsum_algorithm algorithm, size_t hash_siz *p = '\0'; } if (testcases[i].input_repeat == 1) - printf("[\033[1;%s\033[m] %s(\"%s\"%s) = %s\n", - caseok ? "32mPASS" : "31mFAIL", name, input, bitstr, hexsum); + fprintf(stderr, "[\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); + fprintf(stderr, "[\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); + fprintf(stderr, "[\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); + fprintf(stderr, "[\033[1;%s\033[m] %s(%zu * \"%s\"%s) = %s\n", + caseok ? "32mPASS" : "31mFAIL", name, testcases[i].input_repeat, input, bitstr, hexsum); free(input); } return !ok; @@ -182,3 +182,21 @@ run_tests(const char *name, enum libhashsum_algorithm algorithm, size_t hash_siz testcases, sizeof(testcases) / sizeof(*testcases), hexsum) #endif + + +#ifdef TEST_UNSUPPORTED +# include <stdio.h> + +# define TEST_MAIN(NAME, ID)\ + struct libhashsum_hasher hasher;\ + if (!libhashsum_init_hasher(&hasher, LIBHASHSUM_##ID)) {\ + fprintf(stderr, "expected libhashsum_init_hasher to fail, but it returned successfully\n");\ + return 2;\ + }\ + if (errno != ENOSYS) {\ + perror("expected libhashsum_init_hasher to set errno to ENOSYS, but got");\ + return 2;\ + }\ + return 0; + +#endif |