3 #include <ccan/lstack/lstack.h>
4 #include <ccan/tap/tap.h>
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 ok1(lstack_top(&s, struct stacker, sl) == NULL);
25 lstack_push(&s, &a, sl);
27 ok1(!lstack_empty(&s));
28 ok1(lstack_top(&s, struct stacker, sl) == &a);
30 lstack_push(&s, &b, sl);
32 ok1(!lstack_empty(&s));
33 ok1(lstack_top(&s, struct stacker, sl) == &b);
35 lstack_push(&s, &c, sl);
37 ok1(!lstack_empty(&s));
38 ok1(lstack_top(&s, struct stacker, sl) == &c);
40 stacker = lstack_pop(&s, struct stacker, sl);
43 ok1(!lstack_empty(&s));
44 ok1(lstack_top(&s, struct stacker, sl) == &b);
46 stacker = lstack_pop(&s, struct stacker, sl);
49 ok1(!lstack_empty(&s));
50 ok1(lstack_top(&s, struct stacker, sl) == &a);
52 stacker = lstack_pop(&s, struct stacker, sl);
55 ok1(lstack_empty(&s));
56 ok1(lstack_top(&s, struct stacker, sl) == NULL);
58 ok1(lstack_pop(&s, struct stacker, sl) == NULL);
60 /* This exits depending on whether all tests passed */