3 #include <ccan/lqueue/lqueue.h>
4 #include <ccan/tap/tap.h>
13 LQUEUE(struct waiter, ql) q = LQUEUE_INIT;
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) == NULL);
24 ok1(lqueue_back(&q) == NULL);
26 lqueue_enqueue(&q, &a);
28 ok1(!lqueue_empty(&q));
29 ok1(lqueue_front(&q) == &a);
30 ok1(lqueue_back(&q) == &a);
32 lqueue_enqueue(&q, &b);
34 ok1(!lqueue_empty(&q));
35 ok1(lqueue_front(&q) == &a);
36 ok1(lqueue_back(&q) == &b);
38 lqueue_enqueue(&q, &c);
40 ok1(!lqueue_empty(&q));
41 ok1(lqueue_front(&q) == &a);
42 ok1(lqueue_back(&q) == &c);
44 waiter = lqueue_dequeue(&q);
47 ok1(!lqueue_empty(&q));
48 ok1(lqueue_front(&q) == &b);
49 ok1(lqueue_back(&q) == &c);
51 waiter = lqueue_dequeue(&q);
54 ok1(!lqueue_empty(&q));
55 ok1(lqueue_front(&q) == &c);
56 ok1(lqueue_back(&q) == &c);
58 waiter = lqueue_dequeue(&q);
61 ok1(lqueue_empty(&q));
62 ok1(lqueue_front(&q) == NULL);
63 ok1(lqueue_back(&q) == NULL);
65 ok1(lqueue_dequeue(&q) == NULL);
67 /* This exits depending on whether all tests passed */