aboutsummaryrefslogtreecommitdiffstats
path: root/tests/common
diff options
context:
space:
mode:
authorRafael G. Martins <rafael@rafaelmartins.eng.br>2020-05-30 23:36:47 +0200
committerRafael G. Martins <rafael@rafaelmartins.eng.br>2020-05-30 23:36:47 +0200
commit13ea5c3a746378a7cc0ffc4faaa966b5bd635c58 (patch)
treed12ff951d184fbe525cc2aeed8f3b0c04f1fe0e3 /tests/common
parentc3b9af3831762d7548eb1e72cfb62ab95e0d8490 (diff)
downloadblogc-13ea5c3a746378a7cc0ffc4faaa966b5bd635c58.tar.gz
blogc-13ea5c3a746378a7cc0ffc4faaa966b5bd635c58.tar.bz2
blogc-13ea5c3a746378a7cc0ffc4faaa966b5bd635c58.zip
common: improve bc_slist_append_list() tests
Diffstat (limited to 'tests/common')
-rw-r--r--tests/common/check_utils.c41
1 files changed, 28 insertions, 13 deletions
diff --git a/tests/common/check_utils.c b/tests/common/check_utils.c
index 4efc1a5..2a34b65 100644
--- a/tests/common/check_utils.c
+++ b/tests/common/check_utils.c
@@ -56,26 +56,41 @@ test_slist_prepend(void **state)
static void
test_slist_append_list(void **state)
{
+ assert_null(bc_slist_append_list(NULL, NULL));
+
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);
+ assert_non_null(t);
+ assert_string_equal(t->data, "bola");
+ assert_non_null(t->next);
+ assert_string_equal(t->next->data, "guda");
+ assert_null(t->next->next);
+
+ t = bc_slist_append_list(NULL, l);
+ assert_non_null(t);
+ assert_string_equal(t->data, "bola");
+ assert_non_null(t->next);
+ assert_string_equal(t->next->data, "guda");
+ assert_null(t->next->next);
+
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);
+
+ t = bc_slist_append_list(l, n);
+ assert_non_null(t);
+ assert_string_equal(t->data, "bola");
+ assert_non_null(t->next);
+ assert_string_equal(t->next->data, "guda");
+ assert_non_null(t->next->next);
+ assert_string_equal(t->next->next->data, "chunda");
+ assert_non_null(t->next->next->next);
+ assert_string_equal(t->next->next->next->data, "asd");
+ assert_null(t->next->next->next->next);
+ bc_slist_free_full(t, free);
}