Write test framework

This commit is contained in:
2024-10-24 12:29:18 +01:00
parent 64c3aaf077
commit 3d0008b496
3 changed files with 84 additions and 0 deletions

21
tests/testing.c Normal file
View 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);
}