Added SILC Thread Queue API
[silc.git] / lib / silcutil / tests / test_silclist.c
index d8ba271525bfc5b641d3771d6564a0cd32deffa5..f0783f37473774c858a1b01a22332c6bd07a14b2 100644 (file)
@@ -1,6 +1,6 @@
 /* SilcList tests */
 
-#include "silcincludes.h"
+#include "silc.h"
 
 struct foo {
   int i;
@@ -10,14 +10,14 @@ struct foo {
 
 int main(int argc, char **argv)
 {
-  bool success = FALSE;
+  SilcBool success = FALSE;
   SilcList list;
   struct foo *f, *f1, *f2, *f3, *f4;
 
   if (argc > 1 && !strcmp(argv[1], "-d")) {
     silc_log_debug(TRUE);
     silc_log_debug_hexdump(TRUE);
-    silc_log_set_debug_string("*list*");
+    silc_log_set_debug_string("*list*,*errno*");
   }
 
   silc_list_init_prev(list, struct foo, next, prev);
@@ -38,6 +38,32 @@ int main(int argc, char **argv)
     goto err;
   f4->i = 4;
 
+  SILC_LOG_DEBUG(("Add one entry"));
+  silc_list_add(list, f1);
+  silc_list_start(list);
+  while ((f = silc_list_get(list)) != SILC_LIST_END) {
+    SILC_LOG_DEBUG(("entry %d, %p, next=%p, prev=%p", f->i, f, f->next, 
+                  f->prev));
+  }
+  SILC_LOG_DEBUG(("Delete the entry"));
+  silc_list_del(list, f1);  
+  silc_list_start(list);
+  while ((f = silc_list_get(list)) != SILC_LIST_END)
+    goto err;
+  SILC_LOG_DEBUG(("head=%p", list.head));
+  SILC_LOG_DEBUG(("Re-add the entry"));
+  silc_list_add(list, f1);
+  silc_list_start(list);
+  while ((f = silc_list_get(list)) != SILC_LIST_END) {
+    SILC_LOG_DEBUG(("entry %d, %p, next=%p, prev=%p", f->i, f, f->next, 
+                  f->prev));
+  }
+  SILC_LOG_DEBUG(("Delete the entry"));
+  silc_list_del(list, f1);  
+  silc_list_start(list);
+  while ((f = silc_list_get(list)) != SILC_LIST_END)
+    goto err;
+
   SILC_LOG_DEBUG(("insert f4=%p at head"));
   silc_list_insert(list, NULL, f4);
   silc_list_start(list);