From bec4fd31fd9f36dbcdad9d443a0c609adde1af67 Mon Sep 17 00:00:00 2001 From: "Rafael G. Martins" Date: Fri, 29 May 2020 01:23:08 +0200 Subject: common: utils: added bc_slist_append_list --- tests/common/check_utils.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'tests') diff --git a/tests/common/check_utils.c b/tests/common/check_utils.c index 471cd77..4efc1a5 100644 --- a/tests/common/check_utils.c +++ b/tests/common/check_utils.c @@ -53,6 +53,32 @@ test_slist_prepend(void **state) } +static void +test_slist_append_list(void **state) +{ + bc_slist_t *l = NULL; + assert_null(bc_slist_append_list(l, NULL)); + l = bc_slist_append(l, (void*) bc_strdup("bola")); + l = bc_slist_append(l, (void*) bc_strdup("guda")); + bc_slist_t *t = bc_slist_append_list(l, NULL); + assert_true(l == t); + bc_slist_t *n = NULL; + n = bc_slist_append(n, (void*) bc_strdup("chunda")); + n = bc_slist_append(n, (void*) bc_strdup("asd")); + l = bc_slist_append_list(l, n); + assert_non_null(l); + assert_string_equal(l->data, "bola"); + assert_non_null(l->next); + assert_string_equal(l->next->data, "guda"); + assert_non_null(l->next->next); + assert_string_equal(l->next->next->data, "chunda"); + assert_non_null(l->next->next->next); + assert_string_equal(l->next->next->next->data, "asd"); + assert_null(l->next->next->next->next); + bc_slist_free_full(l, free); +} + + static void test_slist_free(void **state) { @@ -1053,6 +1079,7 @@ main(void) // slist unit_test(test_slist_append), unit_test(test_slist_prepend), + unit_test(test_slist_append_list), unit_test(test_slist_free), unit_test(test_slist_length), -- cgit v1.2.3-18-g5258