1 #include <ccan/cdump/cdump.h>
2 /* Include the C files directly. */
3 #include <ccan/cdump/cdump.c>
4 #include <ccan/tap/tap.h>
8 struct cdump_definitions *defs;
9 const struct cdump_type *t;
10 char *ctx = tal(NULL, char), *problems;
12 /* This is how many tests you plan to run */
15 /* unions and comments. */
16 defs = cdump_extract(ctx,
18 " int x[5 */* Comment */7];\n"
19 " int y[5// Comment\n"
29 ok1(tal_parent(defs) == ctx);
31 t = strmap_get(&defs->structs, "foo");
33 ok1(tal_count(t->u.members) == 3);
34 ok1(streq(t->u.members[0].name, "x"));
35 ok1(t->u.members[0].type->kind == CDUMP_ARRAY);
36 ok1(streq(t->u.members[0].type->u.arr.size, "5 * 7"));
37 ok1(t->u.members[0].type->u.arr.type->kind == CDUMP_UNKNOWN);
38 ok1(streq(t->u.members[0].type->u.arr.type->name, "int"));
40 ok1(streq(t->u.members[1].name, "y"));
41 ok1(t->u.members[1].type->kind == CDUMP_ARRAY);
42 ok1(streq(t->u.members[1].type->u.arr.size, "5 * 7"));
43 ok1(t->u.members[1].type->u.arr.type->kind == CDUMP_UNKNOWN);
44 ok1(streq(t->u.members[1].type->u.arr.type->name, "int"));
46 ok1(streq(t->u.members[2].name, "z"));
47 ok1(t->u.members[2].type->kind == CDUMP_ARRAY);
48 ok1(streq(t->u.members[2].type->u.arr.size, "5 * 7"));
49 ok1(t->u.members[2].type->u.arr.type->kind == CDUMP_UNKNOWN);
50 ok1(streq(t->u.members[2].type->u.arr.type->name, "int"));
52 /* This exits depending on whether all tests passed */