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/test35.c | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)
 create mode 100644 tests/test35.c

(limited to 'tests/test35.c')

diff --git a/tests/test35.c b/tests/test35.c
new file mode 100644
index 000000000..a9c82b9c5
--- /dev/null
+++ b/tests/test35.c
@@ -0,0 +1,37 @@
+#include "uthash.h"
+#include <string.h>   /* strcpy */
+#include <stdlib.h>   /* malloc */
+#include <stdio.h>    /* printf */
+
+typedef struct elt {
+    char *s;
+    UT_hash_handle hh;
+} elt;
+
+int main()
+{
+    int i;
+    elt *head = NULL;
+    elt elts[10];
+    char label[6] = "hello";
+    for(i=0; i<10; i++) {
+        elts[i].s = (char*)malloc(6UL);
+        strcpy(elts[i].s, "hello");
+        elts[i].s[0] = 'a' + i;
+        printf("%d: %s\n", i, elts[i].s);
+        HASH_ADD_KEYPTR(hh, head, elts[i].s, 6UL, &elts[i]);
+    }
+
+    /* look up each element and verify the result pointer */
+    for(i=0; i<10; i++) {
+        elt *e;
+        label[0] = 'a' + i;
+        HASH_FIND(hh,head,label,6UL,e);
+        if (e != NULL) {
+            printf( "found %s\n", e->s);
+            printf( "right address? %s\n", (e == &elts[i]) ? "yes" : "no");
+        }
+    }
+
+    return 0;
+}
-- 
cgit v1.2.3