summaryrefslogtreecommitdiff
path: root/lichen.test.c
diff options
context:
space:
mode:
Diffstat (limited to 'lichen.test.c')
-rw-r--r--lichen.test.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/lichen.test.c b/lichen.test.c
index 77ff067..68d26d0 100644
--- a/lichen.test.c
+++ b/lichen.test.c
@@ -24,6 +24,33 @@ LILY_TEST("xorshift output") {
}
#include LILY_PUSH_TEST()
+
+
+void do_nothing(void *k) {
+ k = k;
+}
+void free_data(void *m) {
+ li_free_llnode(m, do_nothing);
+}
+
+LILY_TEST("allocate, copy, and destroy llnode") {
+ li_llnode_t *n = li_alloc_llnode();
+ REQUIRE_NEQ(n, NULL, "%p");
+ CHECK_EQ(n->next, NULL, "%p");
+ int k = 0;
+ n->tag = 4;
+ n->data = &k;
+ li_llnode_t *m = li_copy_llnode(n);
+ REQUIRE_NEQ(m, NULL, "%p");
+ CHECK_EQ(m->tag, 4, "%d");
+ CHECK_EQ(m->data, &k, "%p");
+ CHECK_EQ(m->next, n->next, "%p");
+ n->data = m;
+ li_free_llnode(n, free_data);
+}
+#include LILY_PUSH_TEST()
+
+
#define LILY_FILE_END
#include LILY_REGISTER_TESTS()