Write test framework
This commit is contained in:
21
tests/testing.c
Normal file
21
tests/testing.c
Normal file
@@ -0,0 +1,21 @@
|
||||
#include "testing.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
test_run_t test_run;
|
||||
|
||||
void testing_fail_msg(const char *func, const char *file, int line)
|
||||
{
|
||||
printf("%s: failed assert @ %s:%d\n", func, file, line);
|
||||
}
|
||||
|
||||
void testing_end_msg(void)
|
||||
{
|
||||
const double success_rate
|
||||
= 1 - (double)test_run.fail_count / (double)test_run.test_count;
|
||||
printf(
|
||||
"%d tests ran (%d assertions), "
|
||||
"%0.2f%% successful (%d failures)\n",
|
||||
test_run.test_count, test_run.assertion_count, 100 * success_rate,
|
||||
test_run.fail_count);
|
||||
}
|
||||
Reference in New Issue
Block a user