aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRafael G. Martins <rafael@rafaelmartins.eng.br>2016-12-22 20:48:33 +0100
committerRafael G. Martins <rafael@rafaelmartins.eng.br>2018-01-28 17:06:02 +0100
commitab6e81997cf8c5bcf7d1778bb32d8e01425b13f1 (patch)
tree76393dc9096d093e9ace8b263924055d3c8a13be /tests
parentd6830301f215e96328fa4f9a5ad9e253830386c3 (diff)
downloadblogc-ab6e81997cf8c5bcf7d1778bb32d8e01425b13f1.tar.gz
blogc-ab6e81997cf8c5bcf7d1778bb32d8e01425b13f1.tar.bz2
blogc-ab6e81997cf8c5bcf7d1778bb32d8e01425b13f1.zip
common: utils: added bc_slist_pop()
Diffstat (limited to 'tests')
-rw-r--r--tests/common/check_utils.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/common/check_utils.c b/tests/common/check_utils.c
index dc1eadd..4a4ee2b 100644
--- a/tests/common/check_utils.c
+++ b/tests/common/check_utils.c
@@ -87,6 +87,38 @@ test_slist_length(void **state)
static void
+test_slist_pop(void **state)
+{
+ bc_slist_t *l = NULL;
+ l = bc_slist_append(l, (void*) bc_strdup("bola"));
+ l = bc_slist_append(l, (void*) bc_strdup("guda"));
+ l = bc_slist_append(l, (void*) bc_strdup("chula"));
+ char *v = NULL;
+ l = bc_slist_pop(l, &v);
+ assert_string_equal(v, "bola");
+ assert_non_null(l);
+ assert_string_equal(l->data, "guda");
+ assert_string_equal(l->next->data, "chula");
+ assert_null(l->next->next);
+ free(v);
+ l = bc_slist_pop(l, &v);
+ assert_string_equal(v, "guda");
+ assert_non_null(l);
+ assert_string_equal(l->data, "chula");
+ assert_null(l->next);
+ free(v);
+ l = bc_slist_pop(l, &v);
+ assert_string_equal(v, "chula");
+ assert_null(l);
+ free(v);
+ v = NULL;
+ l = bc_slist_pop(l, &v);
+ assert_null(v);
+ assert_null(l);
+}
+
+
+static void
test_strdup(void **state)
{
char *str = bc_strdup("bola");
@@ -1026,6 +1058,7 @@ main(void)
unit_test(test_slist_prepend),
unit_test(test_slist_free),
unit_test(test_slist_length),
+ unit_test(test_slist_pop),
// strfuncs
unit_test(test_strdup),