summaryrefslogtreecommitdiff
path: root/lichen.test.c
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2025-10-24 12:44:06 -0500
committersanine <sanine.not@pm.me>2025-10-24 12:44:06 -0500
commit30efa292790dfdc9eedefa97a9f82e1cac2aeaa0 (patch)
tree8c8f10e92489de9bfe37dc2698d32c8f210897ef /lichen.test.c
parent54430e64cbb9577ee69de40bc92040428c73e097 (diff)
add alloc/dealloc functions for generic linked list
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()