test: add test to ensure we can use non-const lists via check.
authorRusty Russell <rusty@rustcorp.com.au>
Mon, 26 May 2014 02:16:00 +0000 (11:46 +0930)
committerRusty Russell <rusty@rustcorp.com.au>
Tue, 27 May 2014 03:49:09 +0000 (13:19 +0930)
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ccan/list/test/run-check-nonconst.c [new file with mode: 0644]

diff --git a/ccan/list/test/run-check-nonconst.c b/ccan/list/test/run-check-nonconst.c
new file mode 100644 (file)
index 0000000..b006a8a
--- /dev/null
@@ -0,0 +1,27 @@
+#include <ccan/list/list.h>
+#include <ccan/tap/tap.h>
+#include <ccan/list/list.c>
+#include "helper.h"
+
+struct child {
+       const char *name;
+       struct list_node list;
+};
+
+int main(int argc, char *argv[])
+{
+       struct child c1, c2;
+       struct list_head list = LIST_HEAD_INIT(list);
+
+       plan_tests(1);
+
+       list_add(&list, &c1.list);
+       list_add_tail(list_check(&list, "Bad list!"), &c2.list);
+       list_del_from(list_check(&list, "Bad list!"),
+                     list_check_node(&c2.list, "Bad node!"));
+       list_del_from(list_check(&list, "Bad list!"),
+                     list_check_node(&c1.list, "Bad node!"));
+       ok1(list_empty(list_check(&list, "Bad emptied list")));
+
+       return exit_status();
+}