1 #include <ccan/list/list.h>
2 #include <ccan/tap/tap.h>
3 #include <ccan/list/list.c>
8 unsigned int num_children;
9 struct list_head children;
14 struct list_node list;
17 int main(int argc, char *argv[])
20 struct child c1, c2, c3;
23 parent.num_children = 0;
24 list_head_init(&parent.children);
27 list_add(&parent.children, &c1.list);
29 ok1(list_next(&parent.children, &c1, list) == NULL);
30 ok1(list_prev(&parent.children, &c1, list) == NULL);
33 list_add_tail(&parent.children, &c2.list);
35 ok1(list_next(&parent.children, &c1, list) == &c2);
36 ok1(list_prev(&parent.children, &c1, list) == NULL);
37 ok1(list_next(&parent.children, &c2, list) == NULL);
38 ok1(list_prev(&parent.children, &c2, list) == &c1);
41 list_add_tail(&parent.children, &c3.list);
43 ok1(list_next(&parent.children, &c1, list) == &c2);
44 ok1(list_prev(&parent.children, &c1, list) == NULL);
45 ok1(list_next(&parent.children, &c2, list) == &c3);
46 ok1(list_prev(&parent.children, &c2, list) == &c1);
47 ok1(list_next(&parent.children, &c3, list) == NULL);
48 ok1(list_prev(&parent.children, &c3, list) == &c2);