summaryrefslogtreecommitdiff
path: root/source/base/base_test.h
diff options
context:
space:
mode:
Diffstat (limited to 'source/base/base_test.h')
-rw-r--r--source/base/base_test.h38
1 files changed, 5 insertions, 33 deletions
diff --git a/source/base/base_test.h b/source/base/base_test.h
index 7619cfb..fd47abc 100644
--- a/source/base/base_test.h
+++ b/source/base/base_test.h
@@ -1,29 +1,10 @@
1// TODO(nasr): metaprogram that takes an expected output and generates a test for that specified
2// function
3/* base library testing framework */
1#ifndef BASE_TEST_H 4#ifndef BASE_TEST_H
2#define BASE_TEST_H 5#define BASE_TEST_H
3 6
4#define RED "\x1b[31m" 7// helper macro
5#define GREEN "\x1b[32m"
6#define RESET "\x1b[0m"
7#define BLUE "\x1b[34m"
8
9#define LEN(s) (sizeof(s) - 1)
10
11internal void
12write_int(s32 num)
13{
14
15 if (num < 0)
16 {
17 write(STDERR_FILENO, "-", 1);
18 num = -num;
19 }
20 if (num >= 10)
21 write_int(num / 10);
22 char digit = '0' + (num % 10);
23
24 write(STDERR_FILENO, &digit, 1);
25}
26
27#define show \ 8#define show \
28 do \ 9 do \
29 { \ 10 { \
@@ -45,7 +26,7 @@ write_int(s32 num)
45 } \ 26 } \
46 } 27 }
47 28
48#define check(expr) \ 29#define verify(expr) \
49 { \ 30 { \
50 if ((expr) != 0) \ 31 if ((expr) != 0) \
51 { \ 32 { \
@@ -62,13 +43,4 @@ write_int(s32 num)
62 } \ 43 } \
63 } 44 }
64 45
65#define checkpoint_output "<<CHECKPOINT>>\n"
66#define checkpoint_end_output "^^^^^^^^^^^^^^\n\n\n"
67#define checkpoint \
68 { \
69 write(STDERR_FILENO, BLUE checkpoint_output, LEN(BLUE checkpoint_output)); \
70 show; \
71 write(STDERR_FILENO, BLUE checkpoint_end_output, LEN(BLUE checkpoint_end_output)); \
72 }
73
74#endif /* BASE_TEST_H */ 46#endif /* BASE_TEST_H */