From e39267c83a8af189a624891813ebd6014543b01a Mon Sep 17 00:00:00 2001 From: c Date: Sun, 24 Dec 2023 10:28:00 -0500 Subject: Proper tests. --- test/include/test.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 test/include/test.h (limited to 'test/include') 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 */ -- cgit v1.2.3