diff options
| author | 0scar <qgt268@alumni.ku.dk> | 2022-08-30 14:36:40 +0000 |
|---|---|---|
| committer | 0scar <qgt268@alumni.ku.dk> | 2022-08-30 14:36:40 +0000 |
| commit | 856e859c5c6ec9e6033adc733fda902824c6d675 (patch) | |
| tree | c1b039268febee151130e106834f007d4b6c9a04 /tests/test.h | |
| parent | 577b4bd33c81abed97878779e5fc7a7f32754a01 (diff) | |
Add testing framework
Diffstat (limited to 'tests/test.h')
| -rw-r--r-- | tests/test.h | 22 |
1 files changed, 22 insertions, 0 deletions
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 <stdio.h> + +#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 |
