3 #include <ccan/lqueue/lqueue.h>
4 #include <ccan/tap/tap.h>
14 struct waiter a = { "Alice" };
15 struct waiter b = { "Bob" };
16 struct waiter c = { "Carol" };
17 struct waiter *waiter;
19 /* This is how many tests you plan to run */
22 ok1(lqueue_empty(&q));
23 ok1(lqueue_front(&q, struct waiter, ql) == NULL);
24 ok1(lqueue_back(&q, struct waiter, ql) == NULL);
26 lqueue_enqueue(&q, &a, ql);
28 ok1(!lqueue_empty(&q));
29 ok1(lqueue_front(&q, struct waiter, ql) == &a);
30 ok1(lqueue_back(&q, struct waiter, ql) == &a);
32 lqueue_enqueue(&q, &b, ql);
34 ok1(!lqueue_empty(&q));
35 ok1(lqueue_front(&q, struct waiter, ql) == &a);
36 ok1(lqueue_back(&q, struct waiter, ql) == &b);
38 lqueue_enqueue(&q, &c, ql);
40 ok1(!lqueue_empty(&q));
41 ok1(lqueue_front(&q, struct waiter, ql) == &a);
42 ok1(lqueue_back(&q, struct waiter, ql) == &c);
44 waiter = lqueue_dequeue(&q, struct waiter, ql);
47 ok1(!lqueue_empty(&q));
48 ok1(lqueue_front(&q, struct waiter, ql) == &b);
49 ok1(lqueue_back(&q, struct waiter, ql) == &c);
51 waiter = lqueue_dequeue(&q, struct waiter, ql);
54 ok1(!lqueue_empty(&q));
55 ok1(lqueue_front(&q, struct waiter, ql) == &c);
56 ok1(lqueue_back(&q, struct waiter, ql) == &c);
58 waiter = lqueue_dequeue(&q, struct waiter, ql);
61 ok1(lqueue_empty(&q));
62 ok1(lqueue_front(&q, struct waiter, ql) == NULL);
63 ok1(lqueue_back(&q, struct waiter, ql) == NULL);
65 ok1(lqueue_dequeue(&q, struct waiter, ql) == NULL);
67 /* This exits depending on whether all tests passed */