1
0
mirror of https://github.com/systemd/systemd.git synced 2024-10-30 14:55:37 +03:00

test-env-util: extend the test for strv_env_merge() a bit

This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2021-08-10 16:53:00 +02:00
parent 4ab3d29ff0
commit 43cadb64d4

View File

@ -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) {