# HG changeset patch # User Mike Becker # Date 1361957282 -3600 # Node ID ef3163857e882be7480ae06bfe20974c219cea9d # Parent 47f7fdbddb622518bfb8a951c0f7367c6bd56ba0 added tests for ucx_(d)list_contains diff -r 47f7fdbddb62 -r ef3163857e88 test/dlist_tests.c --- 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 diff -r 47f7fdbddb62 -r ef3163857e88 test/dlist_tests.h --- 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); diff -r 47f7fdbddb62 -r ef3163857e88 test/list_tests.c --- 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 diff -r 47f7fdbddb62 -r ef3163857e88 test/list_tests.h --- 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); diff -r 47f7fdbddb62 -r ef3163857e88 test/main.c --- 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);