From 43cadb64d47ffc1d72571b2a2e494f383d8df83a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 10 Aug 2021 16:53:00 +0200 Subject: [PATCH] test-env-util: extend the test for strv_env_merge() a bit --- src/test/test-env-util.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/test/test-env-util.c b/src/test/test-env-util.c index 5bf130ed86b..91c3c252de4 100644 --- a/src/test/test-env-util.c +++ b/src/test/test-env-util.c @@ -73,31 +73,28 @@ static void test_strv_env_unset(void) { static void test_strv_env_merge(void) { log_info("/* %s */", __func__); - _cleanup_strv_free_ char **a = NULL, **b = NULL, **r = NULL; + char **a = STRV_MAKE("FOO=BAR", "WALDO=WALDO", "WALDO=", "PIEP", "SCHLUMPF=SMURF", "EQ==="); + char **b = STRV_MAKE("FOO=KKK", "FOO=", "PIEP=", "SCHLUMPF=SMURFF", "NANANANA=YES"); - a = strv_new("FOO=BAR", "WALDO=WALDO", "WALDO=", "PIEP", "SCHLUMPF=SMURF"); - assert_se(a); - - b = strv_new("FOO=KKK", "FOO=", "PIEP=", "SCHLUMPF=SMURFF", "NANANANA=YES"); - assert_se(b); - - r = strv_env_merge(a, b); + _cleanup_strv_free_ char **r = strv_env_merge(NULL, a, NULL, b, NULL, a, b, b, NULL); assert_se(r); assert_se(streq(r[0], "FOO=")); assert_se(streq(r[1], "WALDO=")); assert_se(streq(r[2], "PIEP")); assert_se(streq(r[3], "SCHLUMPF=SMURFF")); - assert_se(streq(r[4], "PIEP=")); - assert_se(streq(r[5], "NANANANA=YES")); - assert_se(strv_length(r) == 6); + assert_se(streq(r[4], "EQ===")); + assert_se(streq(r[5], "PIEP=")); + assert_se(streq(r[6], "NANANANA=YES")); + assert_se(strv_length(r) == 7); assert_se(strv_env_clean(r) == r); assert_se(streq(r[0], "FOO=")); assert_se(streq(r[1], "WALDO=")); assert_se(streq(r[2], "SCHLUMPF=SMURFF")); - assert_se(streq(r[3], "PIEP=")); - assert_se(streq(r[4], "NANANANA=YES")); - assert_se(strv_length(r) == 5); + assert_se(streq(r[3], "EQ===")); + assert_se(streq(r[4], "PIEP=")); + assert_se(streq(r[5], "NANANANA=YES")); + assert_se(strv_length(r) == 6); } static void test_strv_env_replace_strdup(void) {