blob: 3193c52d6b49c51908dd03b67b8123e8f9ff5394 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
#ifndef TEST_H
#define TEST_H
#include "../../src/include/util.h"
/*
This is probably how it's supposed to work. In what other cases would you
need `extern`?
*/
extern unsigned int TESTS_RUN;
extern unsigned int TESTS_PASSED;
#define TEST_INIT unsigned int TESTS_RUN = 0, TESTS_PASSED = 0;
#define ASSERT(EXPR) \
TESTS_RUN++; \
(EXPR && ++TESTS_PASSED) ? \
log_inf("%s:%s:%d: Assertion passed!", __FILE__, __func__, __LINE__) : \
log_err("%s:%s:%d: Assertion failed:\n\t%s", __FILE__, __func__, __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
|