diff options
Diffstat (limited to 'tests/pke-test.c')
| -rw-r--r-- | tests/pke-test.c | 57 |
1 files changed, 0 insertions, 57 deletions
diff --git a/tests/pke-test.c b/tests/pke-test.c deleted file mode 100644 index 4f88dbf..0000000 --- a/tests/pke-test.c +++ /dev/null @@ -1,57 +0,0 @@ - -#include "./pke-test-types.h" - -#include "./pke-test-dummy.h" - -#include "unistd.h" -#include <stdio.h> - -#define CLR_WHITE "\033[0m" -#define CLR_GREEN "\033[92m" -#define CLR_RED "\033[31m" - -// https://stackoverflow.com/questions/64190847/how-to-catch-a-call-to-exit-for-unit-testing -struct pke_test_long_jump lj; -void exit(int code) { - if (lj.expected_exit) { - lj.caught = 1; - longjmp(lj.jump_env, 1); - } - _exit(code); -} - -int main(int argc, char *argv[]) -{ - (void)argc; - (void)argv; - int i = 0; - uint32_t k, pass_count; - - pke_test_get_group *group_fns[] = { - pke_test_dummy_get_group, - NULL, - }; - - pke_test_get_group *fn = group_fns[i]; - while (fn != NULL) { - pass_count = 0; - struct pke_test_group *group = (fn)(); - fprintf(stdout, "[pke-test]:[%s] Begin.\n", group->title); - for (k = 0; k < group->n_tests; ++k) { - fprintf(stdout, "[pke-test]:[%s]:[%s] Begin.\n", group->title, group->tests[k].title); - lj.expected_exit = 0; - lj.caught = 0; - if (group->tests[k].expected_result == (group->tests[k].func)()){ - pass_count += 1; - fprintf(stdout, "[pke-test]:[%s]:[%s] %sPassed.%s\n", group->title, group->tests[k].title, CLR_GREEN, CLR_WHITE); - } else { - fprintf(stdout, "[pke-test]:[%s]:[%s] %sFailed.%s\n", group->title, group->tests[k].title, CLR_RED, CLR_WHITE); - } - } - fprintf(stdout, "[pke-test]:[%s] End. ( %s%03d%s / %03d ) Tests Completed.\n\n", group->title, pass_count == group->n_tests ? CLR_GREEN : CLR_RED, pass_count, CLR_WHITE, group->n_tests); - i += 1; - fn = group_fns[i]; - } - - return 0; -} |
