diff options
author | c | 2023-12-24 10:28:00 -0500 |
---|---|---|
committer | c | 2023-12-24 10:28:00 -0500 |
commit | e39267c83a8af189a624891813ebd6014543b01a (patch) | |
tree | c6ad5a39246e4560f6efd77b9d2e4383394bbbf9 /test/include | |
parent | 1494ecaeba2307e489b1df210abb3c63415419ed (diff) |
Proper tests.
Diffstat (limited to 'test/include')
-rw-r--r-- | test/include/test.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/test/include/test.h b/test/include/test.h new file mode 100644 index 0000000..4638a1e --- /dev/null +++ b/test/include/test.h @@ -0,0 +1,22 @@ +#ifndef TEST_H +#define TEST_H + +#include "../../src/include/util.h" + +extern unsigned int TESTS_RUN; +extern unsigned int TESTS_PASSED; + +#define HIDE(THE) do { THE } while ( 0 ); + +#define ASSERT(EXPR) \ + TESTS_RUN++; \ + (EXPR && ++TESTS_PASSED) ? \ + log_inf("%s:%d: Assertion passed!", __FILE__, __LINE__) : \ + log_err("%s:%d: Assertion failed:\n\t%s", __FILE__, __LINE__, #EXPR); + +#define TEST_REPORT \ + (TESTS_RUN == TESTS_PASSED) ? \ + log_yay("%s: All %d tests passed!", __FILE__, TESTS_RUN) : \ + log_err("%d/%d tests failed.", TESTS_RUN - TESTS_PASSED, TESTS_RUN); + +#endif /* ifndef TEST_H */ |