blob: 710915cff6f551fb75f9978d4af4278d7ae5a8dc (
plain)
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# Testing
---
## Macros
```c
TEST(NAME) {
// TEST BODY
}
ASSERT(CONDITION, FAIL_STRING)
FAIL(FAIL_STRING)
```
## Object Definitions
```c
typedef struct {
const char *name;
kpl_error *error;
} kpl_test;
// TODO STORE ERRORS FOR PRINT AT END
#define _TEST_FN(NAME) static void kpl_test_fn_##NAME(__attribute__(unused)) kpl_test *_test)
#define TEST(NAME) \
_TEST_FN(NAME); \
static void __attribute__((constructor)) _kpl_test_constructor_##NAME(void) { \
kpl_test _test = { .name = #NAME; .error = NULL }; \
kpl_test_fn_##NAME(&test); \
if (_test.error) { \
/* TODO STORE ERROR */ \
} \
/* TODO PRINT STATUS */ \
} \
_TEST_FN(NAME)
// TODO ASSERT
// TODO FAIL
```
## `make test`
Bundle all tests into a single executable
## `TEST_FILES="$NAMES..." make test`
Only build specified file(s)
|