From 856e859c5c6ec9e6033adc733fda902824c6d675 Mon Sep 17 00:00:00 2001 From: 0scar Date: Tue, 30 Aug 2022 16:36:40 +0200 Subject: Add testing framework --- tests/test.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 tests/test.h (limited to 'tests/test.h') diff --git a/tests/test.h b/tests/test.h new file mode 100644 index 0000000..1d60ca8 --- /dev/null +++ b/tests/test.h @@ -0,0 +1,22 @@ +#ifndef TEST_H +#define TEST_H + +#include + +#define TEST_CASE(__case_name__, __case__) int __case_name__(){ \ + const char* testname = #__case_name__;\ + int fail_counter = 0;\ + __case__\ + return fail_counter;\ +} + +#define CHECK(__assertion__) {\ + total_assertions += 1; \ + if (!(__assertion__)) {\ + printf("Test failed: %s in %s:%d\n> " #__assertion__ "\n", testname, __FILE__, __LINE__);\ + fail_counter += 1;\ +}} + +extern int total_assertions; + +#endif -- cgit v1.3