ccanlint: handle nested modules when mentioned in examples.
[ccan] / ccan / tal / test / run-steal.c
1 #include <ccan/tal/tal.h>
2 #include <ccan/tal/tal.c>
3 #include <ccan/tap/tap.h>
4
5 int main(void)
6 {
7         char *p[5];
8         unsigned int i;
9
10         plan_tests(9);
11
12         p[0] = NULL;
13         for (i = 1; i < 5; i++)
14                 p[i] = tal(p[i-1], char);
15
16         tal_check(NULL, "check");
17         /* Steal node with no children. */
18         ok1(tal_steal(p[0], p[4]) == p[4]);
19         tal_check(NULL, "check");
20         /* Noop steal. */
21         ok1(tal_steal(p[0], p[4]) == p[4]);
22         tal_check(NULL, "check");
23         /* Steal with children. */
24         ok1(tal_steal(p[0], p[1]) == p[1]);
25         tal_check(NULL, "check");
26         /* Noop steal. */
27         ok1(tal_steal(p[0], p[1]) == p[1]);
28         tal_check(NULL, "check");
29         /* Steal from direct child. */
30         ok1(tal_steal(p[0], p[2]) == p[2]);
31         tal_check(NULL, "check");
32
33         ok1(tal_parent(p[1]) == p[0]);
34         ok1(tal_parent(p[2]) == p[0]);
35         ok1(tal_parent(p[3]) == p[2]);
36         ok1(tal_parent(p[4]) == p[0]);
37         tal_free(p[0]);
38
39         return exit_status();
40 }