test/list_tests.c

changeset 22
76cdd8209f1f
parent 19
cdd7a3173249
child 24
e04822101291
--- a/test/list_tests.c	Sat Jan 14 13:07:18 2012 +0100
+++ b/test/list_tests.c	Sun Jan 15 14:12:34 2012 +0100
@@ -119,6 +119,34 @@
     
     printf("   TODO: test clone with copy\n");
 
+    ucx_dlist_free(dl);
+
+    dl = NULL;
+    printf("   Test ucx_dlist_remove\n");
+    dl = ucx_dlist_append(dl, &v[4]);
+    dl = ucx_dlist_append(dl, &v[0]);
+    dl = ucx_dlist_append(dl, &v[3]);
+    dl = ucx_dlist_remove(dl, dl->next);
+    if (ucx_dlist_size(dl) == 2) {
+        if ((*((int*)(dl->data)) != 4) || (*((int*)(dl->next->data)) != 3)) {
+            fprintf(stderr, "ucx_dlist_remove failed (wrong data)\n");
+            r--;
+        }
+    } else {
+        fprintf(stderr, "ucx_dlist_remove failed (wrong size)\n");
+        r--;
+    }
+    dl = ucx_dlist_remove(dl, dl);
+    if (ucx_dlist_size(dl) == 1) {
+        if ((*((int*)(dl->data)) != 3)) {
+            fprintf(stderr, "ucx_dlist_remove first failed (wrong data)\n");
+            r--;
+        }
+    } else {
+        fprintf(stderr, "ucx_dlist_remove first failed (wrong size)\n");
+        r--;
+    }
+
     return r;
 }
 

mercurial