added tests for ucx_(d)list_contains

Wed, 27 Feb 2013 10:28:02 +0100

author
Mike Becker <universe@uap-core.de>
date
Wed, 27 Feb 2013 10:28:02 +0100
changeset 90
ef3163857e88
parent 89
47f7fdbddb62
child 91
91595a45fad6

added tests for ucx_(d)list_contains

test/dlist_tests.c file | annotate | diff | comparison | revisions
test/dlist_tests.h file | annotate | diff | comparison | revisions
test/list_tests.c file | annotate | diff | comparison | revisions
test/list_tests.h file | annotate | diff | comparison | revisions
test/main.c file | annotate | diff | comparison | revisions
--- a/test/dlist_tests.c	Wed Feb 27 10:09:23 2013 +0100
+++ b/test/dlist_tests.c	Wed Feb 27 10:28:02 2013 +0100
@@ -129,6 +129,19 @@
     ucx_dlist_free(list);
 }
 
+UCX_TEST_IMPLEMENT(test_ucx_dlist_contains) {
+    UcxDlist *l = ucx_dlist_append(NULL, (void*)"Contains ");
+    UCX_TEST_BEGIN
+    l = ucx_dlist_append(l, (void*)"a ");
+    l = ucx_dlist_append(l, (void*)"string!");
+    
+    UCX_TEST_ASSERT(ucx_dlist_contains(l,(void*)"a ",ucx_strcmp,NULL),"failed");
+    UCX_TEST_ASSERT(!ucx_dlist_contains(l,(void*)"a",ucx_strcmp,NULL),"failed");
+    
+    UCX_TEST_END
+    ucx_dlist_free(l);
+}
+
 UCX_TEST_IMPLEMENT(test_ucx_dlist_remove) {
     UcxDlist *list = ucx_dlist_append(NULL, (void*)"Hello");
     UCX_TEST_BEGIN
--- a/test/dlist_tests.h	Wed Feb 27 10:09:23 2013 +0100
+++ b/test/dlist_tests.h	Wed Feb 27 10:28:02 2013 +0100
@@ -30,6 +30,7 @@
 UCX_TEST_DECLARE(test_ucx_dlist_first);
 UCX_TEST_DECLARE(test_ucx_dlist_last);
 UCX_TEST_DECLARE(test_ucx_dlist_get);
+UCX_TEST_DECLARE(test_ucx_dlist_contains);
 UCX_TEST_DECLARE(test_ucx_dlist_remove);
 UCX_TEST_DECLARE(test_ucx_dlist_clone);
 UCX_TEST_DECLARE(test_ucx_dlist_sort);
--- a/test/list_tests.c	Wed Feb 27 10:09:23 2013 +0100
+++ b/test/list_tests.c	Wed Feb 27 10:28:02 2013 +0100
@@ -117,6 +117,19 @@
     ucx_list_free(list);
 }
 
+UCX_TEST_IMPLEMENT(test_ucx_list_contains) {
+    UcxList *l = ucx_list_append(NULL, (void*)"Contains ");
+    UCX_TEST_BEGIN
+    l = ucx_list_append(l, (void*)"a ");
+    l = ucx_list_append(l, (void*)"string!");
+    
+    UCX_TEST_ASSERT(ucx_list_contains(l,(void*)"a ",ucx_strcmp,NULL), "failed");
+    UCX_TEST_ASSERT(!ucx_list_contains(l,(void*)"a",ucx_strcmp,NULL), "failed");
+    
+    UCX_TEST_END
+    ucx_list_free(l);
+}
+
 UCX_TEST_IMPLEMENT(test_ucx_list_remove) {
     UcxList *list = ucx_list_append(NULL, (void*)"Hello");
     UCX_TEST_BEGIN
--- a/test/list_tests.h	Wed Feb 27 10:09:23 2013 +0100
+++ b/test/list_tests.h	Wed Feb 27 10:28:02 2013 +0100
@@ -29,6 +29,7 @@
 UCX_TEST_DECLARE(test_ucx_list_size);
 UCX_TEST_DECLARE(test_ucx_list_last);
 UCX_TEST_DECLARE(test_ucx_list_get);
+UCX_TEST_DECLARE(test_ucx_list_contains);
 UCX_TEST_DECLARE(test_ucx_list_remove);
 UCX_TEST_DECLARE(test_ucx_list_clone);
 UCX_TEST_DECLARE(test_ucx_list_sort);
--- a/test/main.c	Wed Feb 27 10:09:23 2013 +0100
+++ b/test/main.c	Wed Feb 27 10:28:02 2013 +0100
@@ -130,6 +130,7 @@
         ucx_test_register(suite, test_ucx_list_size);
         ucx_test_register(suite, test_ucx_list_last);
         ucx_test_register(suite, test_ucx_list_get);
+        ucx_test_register(suite, test_ucx_list_contains);
         ucx_test_register(suite, test_ucx_list_remove);
         ucx_test_register(suite, test_ucx_list_clone);
         ucx_test_register(suite, test_ucx_list_sort);
@@ -143,6 +144,7 @@
         ucx_test_register(suite, test_ucx_dlist_first);
         ucx_test_register(suite, test_ucx_dlist_last);
         ucx_test_register(suite, test_ucx_dlist_get);
+        ucx_test_register(suite, test_ucx_dlist_contains);
         ucx_test_register(suite, test_ucx_dlist_remove);
         ucx_test_register(suite, test_ucx_dlist_clone);
         ucx_test_register(suite, test_ucx_dlist_sort);

mercurial