summaryrefslogtreecommitdiff
path: root/docs/application/testing.md
blob: bbc7028edf92a642535e846233c5c4572196871b (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
# Testing

---

## Macros

```c
TEST(NAME) {
    // TEST BODY
}

ASSERT(CONDITION, FAIL_STRING)

FAIL(FAIL_STRING)
```

## Object Definitions

```c
typedef struct {
    const char *name;
    // TODO ERROR
} kpl_test;

// TODO STORE ERRORS FOR PRINT AT END

#define _TEST_FN(NAME) static void kpl_test_fn_##NAME([[gnu::constructor]] kpl_test *_test)

#define TEST(NAME) \
    [[gnu::constructor]] _TEST_FN(NAME);
        static void _kpl_test_constructor_##NAME(void) { \
        kpl_test _test = { .name = #NAME; /* TODO ERROR */ }; \
        kpl_test_fn_##NAME(&test); \
        / * TODO CHECK FOR ERROR */ \
    } \
    _TEST_FN(NAME)

// TODO ASSERT

// TODO FAIL
```