3 #include <ccan/lstack/lstack.h>
4 #include <ccan/tap/tap.h>
13 LSTACK(struct stacker, sl) s = LSTACK_INIT;
14 struct stacker a = { "Alice" };
15 struct stacker b = { "Bob" };
16 struct stacker c = { "Carol" };
17 struct stacker *stacker;
19 /* This is how many tests you plan to run */
22 ok1(lstack_empty(&s));
23 diag("top = %p\n", lstack_top(&s));
24 ok1(lstack_top(&s) == NULL);
28 ok1(!lstack_empty(&s));
29 ok1(lstack_top(&s) == &a);
33 ok1(!lstack_empty(&s));
34 ok1(lstack_top(&s) == &b);
38 ok1(!lstack_empty(&s));
39 ok1(lstack_top(&s) == &c);
41 stacker = lstack_pop(&s);
44 ok1(!lstack_empty(&s));
45 ok1(lstack_top(&s) == &b);
47 stacker = lstack_pop(&s);
50 ok1(!lstack_empty(&s));
51 ok1(lstack_top(&s) == &a);
53 stacker = lstack_pop(&s);
56 ok1(lstack_empty(&s));
57 ok1(lstack_top(&s) == NULL);
59 ok1(lstack_pop(&s) == NULL);
61 /* This exits depending on whether all tests passed */