401 UCX_TEST_END |
401 UCX_TEST_END |
402 |
402 |
403 ucx_list_free(expected); |
403 ucx_list_free(expected); |
404 ucx_list_free(list); |
404 ucx_list_free(list); |
405 } |
405 } |
|
406 |
|
407 UCX_TEST(test_ucx_list_union) { |
|
408 UcxList *left = ucx_list_append(NULL, (void*)"this"); |
|
409 left = ucx_list_append(left, (void*)"is"); |
|
410 left = ucx_list_append(left, (void*)"a"); |
|
411 left = ucx_list_append(left, (void*)"test"); |
|
412 |
|
413 UcxList *right = ucx_list_append(NULL, (void*)"to"); |
|
414 right = ucx_list_append(right, (void*)"test"); |
|
415 right = ucx_list_append(right, (void*)"set"); |
|
416 right = ucx_list_append(right, (void*)"operations"); |
|
417 |
|
418 UcxList *expected = ucx_list_append(NULL, (void*)"this"); |
|
419 expected = ucx_list_append(expected, (void*)"is"); |
|
420 expected = ucx_list_append(expected, (void*)"a"); |
|
421 expected = ucx_list_append(expected, (void*)"test"); |
|
422 expected = ucx_list_append(expected, (void*)"to"); |
|
423 expected = ucx_list_append(expected, (void*)"set"); |
|
424 expected = ucx_list_append(expected, (void*)"operations"); |
|
425 |
|
426 UcxList* result = ucx_list_union(left, right, ucx_cmp_str, |
|
427 NULL, NULL, NULL); |
|
428 |
|
429 UCX_TEST_BEGIN |
|
430 UCX_TEST_ASSERT(ucx_list_equals(result, expected, |
|
431 ucx_cmp_str, NULL), "failed"); |
|
432 UCX_TEST_END |
|
433 |
|
434 ucx_list_free(result); |
|
435 ucx_list_free(expected); |
|
436 ucx_list_free(right); |
|
437 ucx_list_free(left); |
|
438 } |
|
439 |
|
440 UCX_TEST(test_ucx_list_intersection) { |
|
441 UcxList *left = ucx_list_append(NULL, (void*)"this"); |
|
442 left = ucx_list_append(left, (void*)"is"); |
|
443 left = ucx_list_append(left, (void*)"a"); |
|
444 left = ucx_list_append(left, (void*)"test"); |
|
445 |
|
446 UcxList *right = ucx_list_append(NULL, (void*)"to"); |
|
447 right = ucx_list_append(right, (void*)"test"); |
|
448 right = ucx_list_append(right, (void*)"a"); |
|
449 right = ucx_list_append(right, (void*)"set"); |
|
450 right = ucx_list_append(right, (void*)"operation"); |
|
451 |
|
452 UcxList *expected = ucx_list_append(NULL, (void*)"a"); |
|
453 expected = ucx_list_append(expected, (void*)"test"); |
|
454 |
|
455 UcxList* result = ucx_list_intersection(left, right, ucx_cmp_str, |
|
456 NULL, NULL, NULL); |
|
457 |
|
458 UCX_TEST_BEGIN |
|
459 UCX_TEST_ASSERT(ucx_list_equals(result, expected, |
|
460 ucx_cmp_str, NULL), "failed"); |
|
461 UCX_TEST_END |
|
462 |
|
463 ucx_list_free(result); |
|
464 ucx_list_free(expected); |
|
465 ucx_list_free(right); |
|
466 ucx_list_free(left); |
|
467 } |
|
468 |
|
469 UCX_TEST(test_ucx_list_difference) { |
|
470 UcxList *left = ucx_list_append(NULL, (void*)"this"); |
|
471 left = ucx_list_append(left, (void*)"is"); |
|
472 left = ucx_list_append(left, (void*)"a"); |
|
473 left = ucx_list_append(left, (void*)"test"); |
|
474 |
|
475 UcxList *right = ucx_list_append(NULL, (void*)"to"); |
|
476 right = ucx_list_append(right, (void*)"test"); |
|
477 right = ucx_list_append(right, (void*)"this"); |
|
478 right = ucx_list_append(right, (void*)"set"); |
|
479 right = ucx_list_append(right, (void*)"operations"); |
|
480 |
|
481 UcxList *expected = ucx_list_append(NULL, (void*)"is"); |
|
482 expected = ucx_list_append(expected, (void*)"a"); |
|
483 |
|
484 UcxList* result = ucx_list_difference(left, right, ucx_cmp_str, |
|
485 NULL, NULL, NULL); |
|
486 |
|
487 UCX_TEST_BEGIN |
|
488 UCX_TEST_ASSERT(ucx_list_equals(result, expected, |
|
489 ucx_cmp_str, NULL), "failed"); |
|
490 UCX_TEST_END |
|
491 |
|
492 ucx_list_free(result); |
|
493 ucx_list_free(expected); |
|
494 ucx_list_free(right); |
|
495 ucx_list_free(left); |
|
496 } |