test/list_tests.c

changeset 390
d345541018fa
parent 389
92e482410453
child 391
f094a53c1178
     1.1 --- a/test/list_tests.c	Mon Dec 30 09:54:10 2019 +0100
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,496 +0,0 @@
     1.4 -/*
     1.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
     1.6 - *
     1.7 - * Copyright 2017 Mike Becker, Olaf Wintermann All rights reserved.
     1.8 - *
     1.9 - * Redistribution and use in source and binary forms, with or without
    1.10 - * modification, are permitted provided that the following conditions are met:
    1.11 - *
    1.12 - *   1. Redistributions of source code must retain the above copyright
    1.13 - *      notice, this list of conditions and the following disclaimer.
    1.14 - *
    1.15 - *   2. Redistributions in binary form must reproduce the above copyright
    1.16 - *      notice, this list of conditions and the following disclaimer in the
    1.17 - *      documentation and/or other materials provided with the distribution.
    1.18 - *
    1.19 - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
    1.20 - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    1.21 - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    1.22 - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
    1.23 - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    1.24 - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
    1.25 - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
    1.26 - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
    1.27 - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
    1.28 - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    1.29 - * POSSIBILITY OF SUCH DAMAGE.
    1.30 - */
    1.31 -
    1.32 -#include "list_tests.h"
    1.33 -#include <ucx/utils.h>
    1.34 -
    1.35 -UCX_TEST(test_ucx_list_append) {
    1.36 -    UcxList *list, *first;
    1.37 -    list = first = ucx_list_append(NULL, (void*)"Hello");
    1.38 -    UCX_TEST_BEGIN
    1.39 -    
    1.40 -    UCX_TEST_ASSERT(strncmp((const char*)list->data, "Hello", 5) == 0,
    1.41 -            "failed");
    1.42 -    
    1.43 -    list = ucx_list_append(list, (void*)" World!");
    1.44 -    
    1.45 -    UCX_TEST_ASSERT(list == first, "does not return first element");
    1.46 -    UCX_TEST_ASSERT(strncmp((const char*)list->next->data, " World!", 7) == 0,
    1.47 -            "failed");
    1.48 -    UCX_TEST_ASSERT(list->next->prev == list, "failed");
    1.49 -    UCX_TEST_ASSERT(list->next->next == NULL, "failed");
    1.50 -    UCX_TEST_END
    1.51 -    
    1.52 -    ucx_list_free(list);
    1.53 -}
    1.54 -
    1.55 -UCX_TEST(test_ucx_list_prepend) {
    1.56 -    UcxList *list, *last;
    1.57 -    list = last = ucx_list_prepend(NULL, (void*)" World!");
    1.58 -    UCX_TEST_BEGIN
    1.59 -
    1.60 -    list = ucx_list_prepend(list, (void*)"Hello");
    1.61 -    
    1.62 -    UCX_TEST_ASSERT(strncmp((const char*)list->data, "Hello", 5) == 0,
    1.63 -            "failed");
    1.64 -    UCX_TEST_ASSERT(strncmp((const char*)list->next->data, " World!", 7) == 0,
    1.65 -            "failed");
    1.66 -    UCX_TEST_ASSERT(list == last->prev, "does not return first element");
    1.67 -    UCX_TEST_ASSERT(list->next->next == NULL, "failed");
    1.68 -    UCX_TEST_ASSERT(list->prev == NULL, "failed");
    1.69 -    
    1.70 -    UCX_TEST_END
    1.71 -    ucx_list_free(list);
    1.72 -}
    1.73 -
    1.74 -UCX_TEST(test_ucx_list_equals) {
    1.75 -    const char *hello = "Hello";
    1.76 -    const char *world = " World!";
    1.77 -    UcxList *list = ucx_list_append(NULL, (void*)hello);
    1.78 -    list = ucx_list_append(list, (void*)world);
    1.79 -    UcxList *list2 = ucx_list_prepend(NULL, (void*)world);
    1.80 -    list2 = ucx_list_prepend(list2, (void*)hello);
    1.81 -    UcxList *list3 = ucx_list_prepend(NULL, (void*)" Welt!");
    1.82 -    list3 = ucx_list_prepend(list3, (void*)"Hallo");
    1.83 -    UcxList *list4 = ucx_list_prepend(NULL, (void*)" World!");
    1.84 -    list4 = ucx_list_prepend(list4, (void*)"Hello");
    1.85 -    UCX_TEST_BEGIN
    1.86 -    
    1.87 -    UCX_TEST_ASSERT(ucx_list_equals(list, list4, ucx_cmp_str, NULL), "failed");
    1.88 -    UCX_TEST_ASSERT(!ucx_list_equals(list, list3, ucx_cmp_str, NULL), "failed");
    1.89 -    UCX_TEST_ASSERT(ucx_list_equals(list, list2, NULL, NULL), "failed");
    1.90 -    
    1.91 -    UCX_TEST_END
    1.92 -    ucx_list_free(list4);
    1.93 -    ucx_list_free(list3);
    1.94 -    ucx_list_free(list2);
    1.95 -    ucx_list_free(list);
    1.96 -}
    1.97 -
    1.98 -UCX_TEST(test_ucx_list_concat) {
    1.99 -    UcxList *list = ucx_list_append(NULL, (void*)"Hello");
   1.100 -    list = ucx_list_append(list, (void*)" my ");
   1.101 -    UcxList *list2 = ucx_list_prepend(NULL, (void*)" World!");
   1.102 -    list2 = ucx_list_prepend(list2, (void*)" sweet ");
   1.103 -    UCX_TEST_BEGIN
   1.104 -    
   1.105 -    list = ucx_list_concat(list, list2);
   1.106 -    list = ucx_list_concat(list, NULL);
   1.107 -    list = ucx_list_concat(NULL, list);
   1.108 -    
   1.109 -    UCX_TEST_ASSERT(!strncmp((const char*)list->data, "Hello", 5),
   1.110 -            "failed");
   1.111 -    UCX_TEST_ASSERT(!strncmp((const char*)list->next->data, " my ", 4),
   1.112 -            "failed");
   1.113 -    UCX_TEST_ASSERT(!strncmp((const char*)list->next->next->data, " sweet ", 7),
   1.114 -            "failed");
   1.115 -    UCX_TEST_ASSERT(!strncmp((const char*)ucx_list_last(list)->data,
   1.116 -            " World!", 7), "failed");
   1.117 -
   1.118 -    UCX_TEST_ASSERT(list->prev == NULL, "failed");
   1.119 -    
   1.120 -    UCX_TEST_END
   1.121 -    // don't free list2, as it is freed by freeing list;
   1.122 -    ucx_list_free(list);
   1.123 -}
   1.124 -
   1.125 -UCX_TEST(test_ucx_list_size) {
   1.126 -    UcxList *list = ucx_list_append(NULL, (void*)"This ");
   1.127 -    list = ucx_list_append(list, (void*)"list ");
   1.128 -    list = ucx_list_append(list, (void*)"has ");
   1.129 -    list = ucx_list_append(list, (void*)"size ");
   1.130 -    list = ucx_list_append(list, (void*)"5!");
   1.131 -    
   1.132 -    UCX_TEST_BEGIN
   1.133 -    
   1.134 -    UCX_TEST_ASSERT(ucx_list_size(list) == 5, "failed");
   1.135 -    list = ucx_list_remove(list, ucx_list_get(list, 2));
   1.136 -    UCX_TEST_ASSERT(ucx_list_size(list) == 4, "failed after removal");
   1.137 -    
   1.138 -    UCX_TEST_END
   1.139 -    ucx_list_free(list);
   1.140 -}
   1.141 -
   1.142 -UCX_TEST(test_ucx_list_first) {
   1.143 -    UcxList *list = ucx_list_append(NULL, (void*)"Find ");
   1.144 -    list = ucx_list_append(list, (void*)"the ");
   1.145 -    list = ucx_list_append(list, (void*)"first!");
   1.146 -    
   1.147 -    UCX_TEST_BEGIN
   1.148 -    
   1.149 -    const char* first = (const char*) (ucx_list_first(list)->data);
   1.150 -    
   1.151 -    UCX_TEST_ASSERT(strncmp(first, "Find ", 5) == 0, "failed");
   1.152 -    UCX_TEST_ASSERT(ucx_list_first(list->next->next) == list, "failed");
   1.153 -    UCX_TEST_ASSERT(!ucx_list_first(NULL),
   1.154 -        "does not return NULL on an empty list");
   1.155 -    
   1.156 -    UCX_TEST_END
   1.157 -    ucx_list_free(list);
   1.158 -}
   1.159 -
   1.160 -UCX_TEST(test_ucx_list_last) {
   1.161 -    UcxList *list = ucx_list_append(NULL, (void*)"Find ");
   1.162 -    list = ucx_list_append(list, (void*)"the ");
   1.163 -    list = ucx_list_append(list, (void*)"last!");
   1.164 -    
   1.165 -    UCX_TEST_BEGIN
   1.166 -    
   1.167 -    const char* last = (const char*) (ucx_list_last(list->next->next)->data);
   1.168 -    
   1.169 -    UCX_TEST_ASSERT(strncmp(last, "last!", 5) == 0, "failed");
   1.170 -    UCX_TEST_ASSERT(ucx_list_last(list) == list->next->next, "failed");
   1.171 -    UCX_TEST_ASSERT(!ucx_list_last(NULL),
   1.172 -        "does not return NULL on an empty list");
   1.173 -    
   1.174 -    UCX_TEST_END
   1.175 -    ucx_list_free(list);
   1.176 -}
   1.177 -
   1.178 -UCX_TEST(test_ucx_list_get) {
   1.179 -    UcxList *list = ucx_list_append(NULL, (void*)"Find ");
   1.180 -    list = ucx_list_append(list, (void*)"the ");
   1.181 -    list = ucx_list_append(list, (void*)"mid!");
   1.182 -    
   1.183 -    UCX_TEST_BEGIN
   1.184 -    
   1.185 -    const char* first = (const char*) (ucx_list_get(list, 0)->data);
   1.186 -    const char* mid = (const char*) (ucx_list_get(list, 1)->data);
   1.187 -    const char* last = (const char*) (ucx_list_get(list, 2)->data);
   1.188 -    
   1.189 -    UCX_TEST_ASSERT(strncmp(first, "Find ", 5) == 0, "failed");
   1.190 -    UCX_TEST_ASSERT(strncmp(mid, "the ", 4) == 0, "failed");
   1.191 -    UCX_TEST_ASSERT(strncmp(last, "mid!", 4) == 0, "failed");
   1.192 -    UCX_TEST_ASSERT(!ucx_list_get(list, -1), "out of bounds (neg)");
   1.193 -    UCX_TEST_ASSERT(!ucx_list_get(list, 3), "out of bounds");
   1.194 -    UCX_TEST_ASSERT(!ucx_list_get(NULL, 0), "empty list");
   1.195 -    
   1.196 -    UCX_TEST_END
   1.197 -    ucx_list_free(list);
   1.198 -}
   1.199 -
   1.200 -UCX_TEST(test_ucx_list_indexof) {
   1.201 -    UcxList *list = ucx_list_append(NULL, (void*)"Find ");
   1.202 -    list = ucx_list_append(list, (void*)"the ");
   1.203 -    list = ucx_list_append(list, (void*)"mid!");
   1.204 -    
   1.205 -    UCX_TEST_BEGIN
   1.206 -    
   1.207 -    UCX_TEST_ASSERT(ucx_list_indexof(list, list) == 0, "failed");
   1.208 -    UCX_TEST_ASSERT(ucx_list_indexof(list, list->next) == 1, "failed");
   1.209 -    UCX_TEST_ASSERT(ucx_list_indexof(list, ucx_list_get(list, 2)) == 2,
   1.210 -        "failed");
   1.211 -    
   1.212 -    UcxList *otherlist = ucx_list_append(NULL, (void*) "the ");
   1.213 -    UCX_TEST_ASSERT(ucx_list_indexof(list, otherlist) == -1, "failed");
   1.214 -    UCX_TEST_ASSERT(ucx_list_indexof(NULL, otherlist) == -1, "empty list");
   1.215 -
   1.216 -    ucx_list_free(otherlist);
   1.217 -    
   1.218 -    UCX_TEST_END
   1.219 -    ucx_list_free(list);
   1.220 -}
   1.221 -
   1.222 -UCX_TEST(test_ucx_list_find) {
   1.223 -    const char* teststr = "string!";
   1.224 -    UcxList *l = ucx_list_append(NULL, (void*)"find ");
   1.225 -    l = ucx_list_append(l, (void*)"some ");
   1.226 -    l = ucx_list_append(l, (void*)teststr);
   1.227 -    
   1.228 -    UCX_TEST_BEGIN
   1.229 -    
   1.230 -    UCX_TEST_ASSERT(ucx_list_find(l,(void*)"some ",ucx_cmp_str,NULL) == 1,
   1.231 -        "doesn't find string");
   1.232 -    UCX_TEST_ASSERT(ucx_list_find(l,(void*)"a",ucx_cmp_str,NULL) == -1,
   1.233 -        "finds non-existing string");
   1.234 -    
   1.235 -    UCX_TEST_ASSERT(ucx_list_find(l,(void*)teststr,NULL,NULL) == 2,
   1.236 -        "doesn't find integer without cmp_func");
   1.237 -    
   1.238 -    UCX_TEST_ASSERT(ucx_list_find(NULL, (void*)"some ",ucx_cmp_str,NULL) == -1,
   1.239 -        "empty list");
   1.240 -    
   1.241 -    UCX_TEST_END
   1.242 -    ucx_list_free(l);
   1.243 -}
   1.244 -
   1.245 -UCX_TEST(test_ucx_list_contains) {
   1.246 -    UcxList *l = ucx_list_append(NULL, (void*)"Contains ");
   1.247 -    l = ucx_list_append(l, (void*)"a ");
   1.248 -    l = ucx_list_append(l, (void*)"string!");
   1.249 -    
   1.250 -    UCX_TEST_BEGIN
   1.251 -    
   1.252 -    UCX_TEST_ASSERT(ucx_list_contains(l,(void*)"a ",ucx_cmp_str,NULL),
   1.253 -        "false negative");
   1.254 -    UCX_TEST_ASSERT(!ucx_list_contains(l,(void*)"a",ucx_cmp_str,NULL),
   1.255 -        "false positive");
   1.256 -    
   1.257 -    UCX_TEST_END
   1.258 -    ucx_list_free(l);
   1.259 -}
   1.260 -
   1.261 -UCX_TEST(test_ucx_list_remove) {
   1.262 -    UcxList *list = ucx_list_append(NULL, (void*)"Hello");
   1.263 -    list = ucx_list_append(list, (void*)"fucking");
   1.264 -    list = ucx_list_append(list, (void*)"World!");
   1.265 -    
   1.266 -    UcxList *list2 = ucx_list_append(NULL, (void*)"A");
   1.267 -    list2 = ucx_list_append(list2, (void*)"B");
   1.268 -    list2 = ucx_list_append(list2, (void*)"C");
   1.269 -    list2 = ucx_list_append(list2, (void*)"D");
   1.270 -    list2 = ucx_list_append(list2, (void*)"E");
   1.271 -    list2 = ucx_list_append(list2, (void*)"F");
   1.272 -    list2 = ucx_list_append(list2, (void*)"G");
   1.273 -    
   1.274 -    UCX_TEST_BEGIN
   1.275 -    
   1.276 -    list = ucx_list_remove(list, ucx_list_get(list, 1));
   1.277 -    
   1.278 -    UCX_TEST_ASSERT(strncmp((const char*)list->data, "Hello", 5) == 0,
   1.279 -            "failed");
   1.280 -    UCX_TEST_ASSERT(strncmp((const char*)list->next->data, "World!", 7) == 0,
   1.281 -            "failed");
   1.282 -    UCX_TEST_ASSERT(list->next->next == NULL, "failed");
   1.283 -    
   1.284 -    // remove first element: B, C, D, E, F, G
   1.285 -    list2 = ucx_list_remove(list2, list2);
   1.286 -    
   1.287 -    UCX_TEST_ASSERT(ucx_list_size(list2) == 6, "list2 has wrong size");
   1.288 -    UCX_TEST_ASSERT(strncmp((const char*)list2->data, "B", 1) == 0,
   1.289 -            "wrong first element");
   1.290 -    UCX_TEST_ASSERT(strncmp((const char*)ucx_list_get(list2, 5)->data, "G", 1)
   1.291 -            == 0, "wrong last element");
   1.292 -    
   1.293 -    // remove second element: B, D, E, F, G
   1.294 -    list2 = ucx_list_remove(list2, list2->next);
   1.295 -    
   1.296 -    UCX_TEST_ASSERT(ucx_list_size(list2) == 5, "list2 has wrong size");
   1.297 -    UCX_TEST_ASSERT(strncmp((const char*)list2->next->data, "D", 1) == 0,
   1.298 -            "wrong second element");
   1.299 -    
   1.300 -    UcxList *last = ucx_list_get(list2, 4);
   1.301 -    list2 = ucx_list_remove(list2, last->prev);
   1.302 -    
   1.303 -    UCX_TEST_ASSERT(ucx_list_size(list2) == 4, "list2 has wrong size");
   1.304 -    UCX_TEST_ASSERT(strncmp((const char*)last->prev->data, "E", 1) == 0,
   1.305 -            "wrong element");
   1.306 -    
   1.307 -    // remove last element: B, D, E, F
   1.308 -    list2 = ucx_list_remove(list2, last);
   1.309 -    UCX_TEST_ASSERT(ucx_list_size(list2) == 3, "list2 has wrong size");
   1.310 -    UCX_TEST_ASSERT(strncmp((const char*)ucx_list_get(list2, 2)->data, "E", 1)
   1.311 -            == 0, "wrong last element");
   1.312 -    
   1.313 -    UCX_TEST_ASSERT(strncmp((const char*)list2->data, "B", 1) == 0,
   1.314 -            "wrong element");
   1.315 -    
   1.316 -    list2 = ucx_list_remove(list2, list2);
   1.317 -    UCX_TEST_ASSERT(ucx_list_size(list2) == 2, "list2 has wrong size");
   1.318 -    list2 = ucx_list_remove(list2, list2);
   1.319 -    UCX_TEST_ASSERT(ucx_list_size(list2) == 1, "list2 has wrong size");
   1.320 -    list2 = ucx_list_remove(list2, list2);
   1.321 -    UCX_TEST_ASSERT(list2 == NULL, "list2 is not null");
   1.322 -    
   1.323 -    UCX_TEST_END
   1.324 -    ucx_list_free(list);
   1.325 -}
   1.326 -
   1.327 -UCX_TEST(test_ucx_list_clone) {
   1.328 -   
   1.329 -    char *hello = (char*)malloc(6);
   1.330 -    char *world = (char*)malloc(8);
   1.331 -    
   1.332 -    memcpy(hello, "Hello", 6);
   1.333 -    memcpy(world, " World!", 8);
   1.334 -    
   1.335 -    UcxList *list = ucx_list_append(NULL, hello);
   1.336 -    list = ucx_list_append(list, world);
   1.337 -    
   1.338 -    UcxList *copy = ucx_list_clone(list, ucx_strcpy, NULL);
   1.339 -    UCX_TEST_BEGIN
   1.340 -
   1.341 -    UCX_TEST_ASSERT(ucx_list_equals(list, copy, ucx_cmp_str, NULL), "failed");
   1.342 -    UCX_TEST_ASSERT(hello != copy->data, "first element is no copy");
   1.343 -    UCX_TEST_ASSERT(world != copy->next->data, "second element is no copy");
   1.344 -
   1.345 -    UCX_TEST_END
   1.346 -    
   1.347 -    ucx_list_free_content(copy, free);
   1.348 -
   1.349 -    free(world);
   1.350 -    free(hello);
   1.351 -    ucx_list_free(list);
   1.352 -    ucx_list_free(copy);
   1.353 -}
   1.354 -
   1.355 -UCX_TEST(test_ucx_list_sort) {
   1.356 -    UcxList *list = ucx_list_append(NULL, (void*)"this");
   1.357 -    list = ucx_list_append(list, (void*)"is");
   1.358 -    list = ucx_list_append(list, (void*)"a");
   1.359 -    list = ucx_list_append(list, (void*)"test");
   1.360 -    list = ucx_list_append(list, (void*)"for");
   1.361 -    list = ucx_list_append(list, (void*)"partial");
   1.362 -    list = ucx_list_append(list, (void*)"correctness");
   1.363 -    list = ucx_list_append(list, (void*)"of");
   1.364 -    list = ucx_list_append(list, (void*)"the");
   1.365 -    list = ucx_list_append(list, (void*)"sort");
   1.366 -    list = ucx_list_append(list, (void*)"function");
   1.367 -    list = ucx_list_append(list, (void*)"that");
   1.368 -    list = ucx_list_append(list, (void*)"shall");
   1.369 -    list = ucx_list_append(list, (void*)"pass");
   1.370 -    list = ucx_list_append(list, (void*)"this");
   1.371 -    list = ucx_list_append(list, (void*)"test");
   1.372 -
   1.373 -    UcxList *expected = ucx_list_append(NULL, (void*)"a");
   1.374 -    expected = ucx_list_append(expected, (void*)"correctness");
   1.375 -    expected = ucx_list_append(expected, (void*)"for");
   1.376 -    expected = ucx_list_append(expected, (void*)"function");
   1.377 -    expected = ucx_list_append(expected, (void*)"is");
   1.378 -    expected = ucx_list_append(expected, (void*)"of");
   1.379 -    expected = ucx_list_append(expected, (void*)"partial");
   1.380 -    expected = ucx_list_append(expected, (void*)"pass");
   1.381 -    expected = ucx_list_append(expected, (void*)"shall");
   1.382 -    expected = ucx_list_append(expected, (void*)"sort");
   1.383 -    expected = ucx_list_append(expected, (void*)"test");
   1.384 -    expected = ucx_list_append(expected, (void*)"test");
   1.385 -    expected = ucx_list_append(expected, (void*)"that");
   1.386 -    expected = ucx_list_append(expected, (void*)"the");
   1.387 -    expected = ucx_list_append(expected, (void*)"this");
   1.388 -    expected = ucx_list_append(expected, (void*)"this");
   1.389 -
   1.390 -    list = ucx_list_sort(list, ucx_cmp_str, NULL);
   1.391 -
   1.392 -    UCX_TEST_BEGIN
   1.393 -    UCX_TEST_ASSERT(
   1.394 -            ucx_list_equals(list, expected, ucx_cmp_str, NULL), "failed");
   1.395 -    UCX_TEST_ASSERT(ucx_list_size(list) == 16, "list has now a wrong size");
   1.396 -    UcxList *l = list;
   1.397 -    UCX_TEST_ASSERT(l->prev == NULL, "prev field of first entry is not null");
   1.398 -    while (l->next != NULL) {
   1.399 -        UCX_TEST_ASSERT(l->next->prev == l, "next or prev pointer corrupted");
   1.400 -        l = l->next;
   1.401 -    }
   1.402 -    UCX_TEST_ASSERT(!ucx_list_sort(NULL, ucx_cmp_str, NULL),
   1.403 -        "failed to sort empty list");
   1.404 -    UCX_TEST_END
   1.405 -
   1.406 -    ucx_list_free(expected);
   1.407 -    ucx_list_free(list);
   1.408 -}
   1.409 -
   1.410 -UCX_TEST(test_ucx_list_union) {
   1.411 -    UcxList *left = ucx_list_append(NULL, (void*)"this");
   1.412 -    left = ucx_list_append(left, (void*)"is");
   1.413 -    left = ucx_list_append(left, (void*)"a");
   1.414 -    left = ucx_list_append(left, (void*)"test");
   1.415 -
   1.416 -    UcxList *right = ucx_list_append(NULL, (void*)"to");
   1.417 -    right = ucx_list_append(right, (void*)"test");
   1.418 -    right = ucx_list_append(right, (void*)"set");
   1.419 -    right = ucx_list_append(right, (void*)"operations");
   1.420 -    
   1.421 -    UcxList *expected = ucx_list_append(NULL, (void*)"this");
   1.422 -    expected = ucx_list_append(expected, (void*)"is");
   1.423 -    expected = ucx_list_append(expected, (void*)"a");
   1.424 -    expected = ucx_list_append(expected, (void*)"test");
   1.425 -    expected = ucx_list_append(expected, (void*)"to");
   1.426 -    expected = ucx_list_append(expected, (void*)"set");
   1.427 -    expected = ucx_list_append(expected, (void*)"operations");
   1.428 -
   1.429 -    UcxList* result = ucx_list_union(left, right, ucx_cmp_str,
   1.430 -            NULL, NULL, NULL);
   1.431 -
   1.432 -    UCX_TEST_BEGIN
   1.433 -    UCX_TEST_ASSERT(ucx_list_equals(result, expected,
   1.434 -            ucx_cmp_str, NULL), "failed");
   1.435 -    UCX_TEST_END
   1.436 -
   1.437 -    ucx_list_free(result);
   1.438 -    ucx_list_free(expected);
   1.439 -    ucx_list_free(right);
   1.440 -    ucx_list_free(left);
   1.441 -}
   1.442 -
   1.443 -UCX_TEST(test_ucx_list_intersection) {
   1.444 -    UcxList *left = ucx_list_append(NULL, (void*)"this");
   1.445 -    left = ucx_list_append(left, (void*)"is");
   1.446 -    left = ucx_list_append(left, (void*)"a");
   1.447 -    left = ucx_list_append(left, (void*)"test");
   1.448 -
   1.449 -    UcxList *right = ucx_list_append(NULL, (void*)"to");
   1.450 -    right = ucx_list_append(right, (void*)"test");
   1.451 -    right = ucx_list_append(right, (void*)"a");
   1.452 -    right = ucx_list_append(right, (void*)"set");
   1.453 -    right = ucx_list_append(right, (void*)"operation");
   1.454 -    
   1.455 -    UcxList *expected = ucx_list_append(NULL, (void*)"a");
   1.456 -    expected = ucx_list_append(expected, (void*)"test");
   1.457 -
   1.458 -    UcxList* result = ucx_list_intersection(left, right, ucx_cmp_str,
   1.459 -            NULL, NULL, NULL);
   1.460 -
   1.461 -    UCX_TEST_BEGIN
   1.462 -    UCX_TEST_ASSERT(ucx_list_equals(result, expected,
   1.463 -            ucx_cmp_str, NULL), "failed");
   1.464 -    UCX_TEST_END
   1.465 -
   1.466 -    ucx_list_free(result);
   1.467 -    ucx_list_free(expected);
   1.468 -    ucx_list_free(right);
   1.469 -    ucx_list_free(left);
   1.470 -}
   1.471 -
   1.472 -UCX_TEST(test_ucx_list_difference) {
   1.473 -    UcxList *left = ucx_list_append(NULL, (void*)"this");
   1.474 -    left = ucx_list_append(left, (void*)"is");
   1.475 -    left = ucx_list_append(left, (void*)"a");
   1.476 -    left = ucx_list_append(left, (void*)"test");
   1.477 -
   1.478 -    UcxList *right = ucx_list_append(NULL, (void*)"to");
   1.479 -    right = ucx_list_append(right, (void*)"test");
   1.480 -    right = ucx_list_append(right, (void*)"this");
   1.481 -    right = ucx_list_append(right, (void*)"set");
   1.482 -    right = ucx_list_append(right, (void*)"operations");
   1.483 -    
   1.484 -    UcxList *expected = ucx_list_append(NULL, (void*)"is");
   1.485 -    expected = ucx_list_append(expected, (void*)"a");
   1.486 -    
   1.487 -    UcxList* result = ucx_list_difference(left, right, ucx_cmp_str,
   1.488 -            NULL, NULL, NULL);
   1.489 -
   1.490 -    UCX_TEST_BEGIN
   1.491 -    UCX_TEST_ASSERT(ucx_list_equals(result, expected,
   1.492 -            ucx_cmp_str, NULL), "failed");
   1.493 -    UCX_TEST_END
   1.494 -
   1.495 -    ucx_list_free(result);
   1.496 -    ucx_list_free(expected);
   1.497 -    ucx_list_free(right);
   1.498 -    ucx_list_free(left);
   1.499 -}

mercurial