X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Ftlist%2Ftest%2Frun.c;h=d36cd8bcd41b456e0c399ce685dc67bdf099f7ff;hb=03f100b281441a953d4ec858389f82e25a95c043;hp=027028e602401f899e0035f5f61281e4dda11748;hpb=6a906358d922800c7358c5c46c34bf4a5e6863ad;p=ccan diff --git a/ccan/tlist/test/run.c b/ccan/tlist/test/run.c index 027028e6..d36cd8bc 100644 --- a/ccan/tlist/test/run.c +++ b/ccan/tlist/test/run.c @@ -6,8 +6,8 @@ TLIST_TYPE(children, struct child); struct parent { const char *name; - struct tlist_children children; unsigned int num_children; + struct tlist_children children; }; struct child { @@ -22,7 +22,7 @@ int main(int argc, char *argv[]) unsigned int i; struct tlist_children tlist = TLIST_INIT(tlist); - plan_tests(48); + plan_tests(60); /* Test TLIST_INIT, and tlist_empty */ ok1(tlist_empty(&tlist)); ok1(tlist_check(&tlist, NULL)); @@ -41,6 +41,8 @@ int main(int argc, char *argv[]) ok1(c2.list.prev == &parent.children.raw.n); ok1(parent.children.raw.n.next == &c2.list); ok1(parent.children.raw.n.prev == &c2.list); + ok1(tlist_next(&parent.children, &c2, list) == NULL); + ok1(tlist_prev(&parent.children, &c2, list) == NULL); /* Test tlist_check */ ok1(tlist_check(&parent.children, NULL)); @@ -54,6 +56,10 @@ int main(int argc, char *argv[]) ok1(parent.children.raw.n.prev == &c2.list); ok1(c1.list.next == &c2.list); ok1(c1.list.prev == &parent.children.raw.n); + ok1(tlist_next(&parent.children, &c1, list) == &c2); + ok1(tlist_next(&parent.children, &c2, list) == NULL); + ok1(tlist_prev(&parent.children, &c2, list) == &c1); + ok1(tlist_prev(&parent.children, &c1, list) == NULL); /* Test tlist_check */ ok1(tlist_check(&parent.children, NULL)); @@ -69,14 +75,20 @@ int main(int argc, char *argv[]) ok1(c2.list.prev == &c1.list); ok1(c3.list.next == &parent.children.raw.n); ok1(c3.list.prev == &c2.list); + ok1(tlist_next(&parent.children, &c1, list) == &c2); + ok1(tlist_next(&parent.children, &c2, list) == &c3); + ok1(tlist_next(&parent.children, &c3, list) == NULL); + ok1(tlist_prev(&parent.children, &c3, list) == &c2); + ok1(tlist_prev(&parent.children, &c2, list) == &c1); + ok1(tlist_prev(&parent.children, &c1, list) == NULL); /* Test tlist_check */ ok1(tlist_check(&parent.children, NULL)); /* Test tlist_top */ - ok1(tlist_top(&parent.children, struct child, list) == &c1); + ok1(tlist_top(&parent.children, list) == &c1); /* Test list_tail */ - ok1(tlist_tail(&parent.children, struct child, list) == &c3); + ok1(tlist_tail(&parent.children, list) == &c3); /* Test tlist_for_each. */ i = 0; @@ -141,7 +153,7 @@ int main(int argc, char *argv[]) ok1(tlist_empty(&parent.children)); /* Test list_top/list_tail on empty list. */ - ok1(tlist_top(&parent.children, struct child, list) == NULL); - ok1(tlist_tail(&parent.children, struct child, list) == NULL); + ok1(tlist_top(&parent.children, list) == (struct child *)NULL); + ok1(tlist_tail(&parent.children, list) == (struct child *)NULL); return exit_status(); }