]> git.ozlabs.org Git - ccan/blob - ccan/cdump/test/run-enum-comma.c
cdump: handle , at end of enums.
[ccan] / ccan / cdump / test / run-enum-comma.c
1 #include <ccan/cdump/cdump.h>
2 /* Include the C files directly. */
3 #include <ccan/cdump/cdump.c>
4 #include <ccan/tap/tap.h>
5
6 int main(void)
7 {
8         struct cdump_definitions *defs;
9         const struct cdump_type *t;
10         char *problems;
11
12         /* This is how many tests you plan to run */
13         plan_tests(12);
14
15         defs = cdump_extract(NULL, "enum foo { BAR, BAZ, };", &problems);
16         ok1(defs);
17         ok1(!problems);
18
19         ok1(strmap_empty(&defs->structs));
20         ok1(strmap_empty(&defs->unions));
21         t = strmap_get(&defs->enums, "foo");
22         ok1(t);
23         ok1(t->kind == CDUMP_ENUM);
24         ok1(streq(t->name, "foo"));
25         ok1(tal_count(t->u.enum_vals) == 2);
26         ok1(streq(t->u.enum_vals[0].name, "BAR"));
27         ok1(!t->u.enum_vals[0].value);
28         ok1(streq(t->u.enum_vals[1].name, "BAZ"));
29         ok1(!t->u.enum_vals[1].value);
30         tal_free(defs);
31
32         /* This exits depending on whether all tests passed */
33         return exit_status();
34 }