diff -r 07ac32b385e4 -r 365b24f20f98 test/list_tests.c --- a/test/list_tests.c Thu Nov 07 10:43:31 2019 +0100 +++ b/test/list_tests.c Sun Nov 24 17:57:25 2019 +0100 @@ -403,3 +403,94 @@ ucx_list_free(expected); ucx_list_free(list); } + +UCX_TEST(test_ucx_list_union) { + UcxList *left = ucx_list_append(NULL, (void*)"this"); + left = ucx_list_append(left, (void*)"is"); + left = ucx_list_append(left, (void*)"a"); + left = ucx_list_append(left, (void*)"test"); + + UcxList *right = ucx_list_append(NULL, (void*)"to"); + right = ucx_list_append(right, (void*)"test"); + right = ucx_list_append(right, (void*)"set"); + right = ucx_list_append(right, (void*)"operations"); + + UcxList *expected = ucx_list_append(NULL, (void*)"this"); + expected = ucx_list_append(expected, (void*)"is"); + expected = ucx_list_append(expected, (void*)"a"); + expected = ucx_list_append(expected, (void*)"test"); + expected = ucx_list_append(expected, (void*)"to"); + expected = ucx_list_append(expected, (void*)"set"); + expected = ucx_list_append(expected, (void*)"operations"); + + UcxList* result = ucx_list_union(left, right, ucx_cmp_str, + NULL, NULL, NULL); + + UCX_TEST_BEGIN + UCX_TEST_ASSERT(ucx_list_equals(result, expected, + ucx_cmp_str, NULL), "failed"); + UCX_TEST_END + + ucx_list_free(result); + ucx_list_free(expected); + ucx_list_free(right); + ucx_list_free(left); +} + +UCX_TEST(test_ucx_list_intersection) { + UcxList *left = ucx_list_append(NULL, (void*)"this"); + left = ucx_list_append(left, (void*)"is"); + left = ucx_list_append(left, (void*)"a"); + left = ucx_list_append(left, (void*)"test"); + + UcxList *right = ucx_list_append(NULL, (void*)"to"); + right = ucx_list_append(right, (void*)"test"); + right = ucx_list_append(right, (void*)"a"); + right = ucx_list_append(right, (void*)"set"); + right = ucx_list_append(right, (void*)"operation"); + + UcxList *expected = ucx_list_append(NULL, (void*)"a"); + expected = ucx_list_append(expected, (void*)"test"); + + UcxList* result = ucx_list_intersection(left, right, ucx_cmp_str, + NULL, NULL, NULL); + + UCX_TEST_BEGIN + UCX_TEST_ASSERT(ucx_list_equals(result, expected, + ucx_cmp_str, NULL), "failed"); + UCX_TEST_END + + ucx_list_free(result); + ucx_list_free(expected); + ucx_list_free(right); + ucx_list_free(left); +} + +UCX_TEST(test_ucx_list_difference) { + UcxList *left = ucx_list_append(NULL, (void*)"this"); + left = ucx_list_append(left, (void*)"is"); + left = ucx_list_append(left, (void*)"a"); + left = ucx_list_append(left, (void*)"test"); + + UcxList *right = ucx_list_append(NULL, (void*)"to"); + right = ucx_list_append(right, (void*)"test"); + right = ucx_list_append(right, (void*)"this"); + right = ucx_list_append(right, (void*)"set"); + right = ucx_list_append(right, (void*)"operations"); + + UcxList *expected = ucx_list_append(NULL, (void*)"is"); + expected = ucx_list_append(expected, (void*)"a"); + + UcxList* result = ucx_list_difference(left, right, ucx_cmp_str, + NULL, NULL, NULL); + + UCX_TEST_BEGIN + UCX_TEST_ASSERT(ucx_list_equals(result, expected, + ucx_cmp_str, NULL), "failed"); + UCX_TEST_END + + ucx_list_free(result); + ucx_list_free(expected); + ucx_list_free(right); + ucx_list_free(left); +}