From c8bf38e5fb717d40635a2a89b22ed71b0de4266b Mon Sep 17 00:00:00 2001
From: Toni Uhlig <matzeton@googlemail.com>
Date: Tue, 1 Dec 2020 13:33:34 +0100
Subject: Squashed 'dependencies/uthash/' content from commit 8e67ced

git-subtree-dir: dependencies/uthash
git-subtree-split: 8e67ced1d1c5bd8141c542a22630e6de78aa6b90
---
 tests/test41.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 72 insertions(+)
 create mode 100644 tests/test41.c

(limited to 'tests/test41.c')

diff --git a/tests/test41.c b/tests/test41.c
new file mode 100644
index 000000000..88a1a96eb
--- /dev/null
+++ b/tests/test41.c
@@ -0,0 +1,72 @@
+#include <stdio.h>
+#include "utlist.h"
+
+typedef struct el {
+    int id;
+    struct el *next, *prev;
+} el;
+
+int main()
+{
+    int i;
+    el *head = NULL;
+    el els[10], *e, *tmp, *tmp2;
+    for(i=0; i<10; i++) {
+        els[i].id=(int)'a'+i;
+    }
+
+    /* test CDL macros */
+    printf("CDL macros\n");
+    CDL_PREPEND(head,&els[0]);
+    CDL_PREPEND(head,&els[1]);
+    CDL_PREPEND(head,&els[2]);
+    CDL_FOREACH(head,e) {
+        printf("%c ", e->id);
+    }
+
+    /* point head to head->next */
+    CDL_FOREACH_SAFE(head,e,tmp,tmp2) {
+        printf("deleting %c ", e->id);
+        CDL_DELETE(head,e);
+    }
+    printf("\n");
+    if (head != NULL) {
+        printf("non-null head\n");
+    }
+
+    /* test DL macros */
+    printf("DL macros\n");
+    DL_APPEND(head,&els[0]);
+    DL_APPEND(head,&els[1]);
+    DL_APPEND(head,&els[2]);
+    DL_FOREACH(head,e) {
+        printf("%c ", e->id);
+    }
+    DL_FOREACH_SAFE(head,e,tmp) {
+        printf("deleting %c ", e->id);
+        DL_DELETE(head,e);
+    }
+    printf("\n");
+    if (head != NULL) {
+        printf("non-null head\n");
+    }
+
+    /* test LL macros */
+    printf("LL macros\n");
+    LL_APPEND(head,&els[0]);
+    LL_APPEND(head,&els[1]);
+    LL_APPEND(head,&els[2]);
+    LL_FOREACH(head,e) {
+        printf("%c ", e->id);
+    }
+    LL_FOREACH_SAFE(head,e,tmp) {
+        printf("deleting %c ", e->id);
+        LL_DELETE(head,e);
+    }
+    printf("\n");
+    if (head != NULL) {
+        printf("non-null head\n");
+    }
+
+    return 0;
+}
-- 
cgit v1.2.3