tal_stack
[ccan] / ccan / tal / stack / test / run-stack.c
1 #include <ccan/tal/stack/stack.h>
2 #include <ccan/tal/stack/stack.c>
3 #include <ccan/tap/tap.h>
4
5 int main(void)
6 {
7         tal_t *parent, *cur;
8
9         plan_tests(8);
10
11         /* initial frame is NULL */
12         ok1(tal_curframe() == NULL);
13
14         /* create new frame and make sure all is OK */
15         cur = tal_newframe();
16         ok1(tal_curframe() == cur);
17         ok1(tal_parent(cur) == NULL);
18
19         /* create another frame */
20         parent = cur;
21         cur = tal_newframe();
22         ok1(tal_curframe() == cur);
23         ok1(tal_parent(cur) == parent);
24
25         /* unwind */
26         tal_free(cur);
27         ok1(tal_curframe() == parent);
28         cur = tal_curframe();
29         ok1(tal_parent(cur) == NULL);
30         tal_free(cur);
31         ok1(tal_curframe() == NULL);
32
33         tal_cleanup();
34         return exit_status();
35 }