]> git.ozlabs.org Git - ccan/blob - ccan/cppmagic/test/run.c
0ed830d8d0f7faead3c9ec9153911abcd0da1d26
[ccan] / ccan / cppmagic / test / run.c
1 #include "config.h"
2
3 #include <string.h>
4
5 #include <ccan/cppmagic/cppmagic.h>
6 #include <ccan/tap/tap.h>
7
8 static inline void check1(const char *orig, const char *expand,
9                           const char *match)
10 {
11         ok(strcmp(expand, match) == 0,
12            "%s => %s : %s", orig, expand, match);
13 }
14
15 #define CHECK1(orig, match) \
16         check1(#orig, CPPMAGIC_STRINGIFY(orig), match)
17
18 int main(void)
19 {
20         plan_tests(7);
21
22         CHECK1(CPPMAGIC_NOTHING(), "");
23         CHECK1(CPPMAGIC_GLUE2(a, b), "ab");
24
25         CHECK1(CPPMAGIC_1ST(a), "a");
26         CHECK1(CPPMAGIC_1ST(a, b), "a");
27         CHECK1(CPPMAGIC_1ST(a, b, c), "a");
28
29         CHECK1(CPPMAGIC_2ND(a, b), "b");
30         CHECK1(CPPMAGIC_2ND(a, b, c), "b");
31
32         /* This exits depending on whether all tests passed */
33         return exit_status();
34 }