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, *t2;
10 char *ctx = tal(NULL, char), *problems;
12 /* This is how many tests you plan to run */
15 defs = cdump_extract(ctx, "struct foo { struct bar *bar; };\n"
16 "struct bar { int x; };", &problems);
18 ok1(tal_parent(defs) == ctx);
21 t = strmap_get(&defs->structs, "foo");
23 t2 = strmap_get(&defs->structs, "bar");
26 ok1(t2->kind == CDUMP_STRUCT);
27 ok1(streq(t2->name, "bar"));
28 ok1(tal_count(t2->u.members) == 1);
29 ok1(t2->u.members[0].type->kind == CDUMP_UNKNOWN);
30 ok1(streq(t2->u.members[0].type->name, "int"));
32 ok1(t->kind == CDUMP_STRUCT);
33 ok1(streq(t->name, "foo"));
34 ok1(tal_count(t->u.members) == 1);
35 ok1(streq(t->u.members[0].name, "bar"));
36 ok1(t->u.members[0].type->kind == CDUMP_POINTER);
37 ok1(t->u.members[0].type->u.ptr == t2);
41 /* This exits depending on whether all tests passed */