summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Hindoe Paaboel Andersen <phomes@gmail.com>2013-02-08 00:22:26 +0100
committerThomas Hindoe Paaboel Andersen <phomes@gmail.com>2013-02-08 00:25:37 +0100
commit940bd4738b16503d903689e50eeb22645463fc16 (patch)
tree2f60c5818c8459d2a7d1177a2c50dfebd7f252d0
parent9d6cbf7871f5ff69e5835caef1b46673af51e000 (diff)
tests: add more tests
Adds tests of: strv_env_delete strv_env_unset strv_env_set
-rw-r--r--src/test/test-env-replace.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/test/test-env-replace.c b/src/test/test-env-replace.c
index 70a28cd0c6..2da3845354 100644
--- a/src/test/test-env-replace.c
+++ b/src/test/test-env-replace.c
@@ -25,6 +25,46 @@
#include "util.h"
#include "strv.h"
+static void test_strv_env_delete(void) {
+ _cleanup_strv_free_ char **a = NULL, **b = NULL, **c = NULL, **d = NULL;
+
+ a = strv_new("FOO=BAR", "WALDO=WALDO", "WALDO=", "PIEP", "SCHLUMPF=SMURF", NULL);
+ b = strv_new("PIEP", "FOO", NULL);
+ c = strv_new("SCHLUMPF", NULL);
+
+ d = strv_env_delete(a, 2, b, c);
+
+ assert(streq(d[0], "WALDO=WALDO"));
+ assert(streq(d[1], "WALDO="));
+ assert(strv_length(d) == 2);
+}
+
+static void test_strv_env_unset(void) {
+ _cleanup_strv_free_ char **l = NULL;
+
+ l = strv_new("PIEP", "SCHLUMPF=SMURFF", "NANANANA=YES", NULL);
+
+ strv_env_unset(l, "SCHLUMPF");
+
+ assert(streq(l[0], "PIEP"));
+ assert(streq(l[1], "NANANANA=YES"));
+ assert(strv_length(l) == 2);
+}
+
+static void test_strv_env_set(void) {
+ _cleanup_strv_free_ char **l = NULL, **r = NULL;
+
+ l = strv_new("PIEP", "SCHLUMPF=SMURFF", "NANANANA=YES", NULL);
+
+ r = strv_env_set(l, "WALDO=WALDO");
+
+ assert(streq(r[0], "PIEP"));
+ assert(streq(r[1], "SCHLUMPF=SMURFF"));
+ assert(streq(r[2], "NANANANA=YES"));
+ assert(streq(r[3], "WALDO=WALDO"));
+ assert(strv_length(r) == 4);
+}
+
static void test_strv_env_merge(void) {
_cleanup_strv_free_ char **a = NULL, **b = NULL, **r = NULL;
@@ -106,6 +146,9 @@ static void test_normalize_env_assignment(void) {
}
int main(int argc, char *argv[]) {
+ test_strv_env_delete();
+ test_strv_env_unset();
+ test_strv_env_set();
test_strv_env_merge();
test_replace_env_arg();
test_normalize_env_assignment();