summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorRonny Chevalier <chevalier.ronny@gmail.com>2014-06-20 00:25:58 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-06-19 19:59:57 -0400
commit4a336a69fdfbe48d18b65c3e20ca6a007be253c5 (patch)
tree9079250eca289bfd15db9c71e176538fc985ae91 /src/test
parent927be00cb3dd09a911a6a4a29b5b7486c3c4c776 (diff)
tests: add tests for strv_extendf
Diffstat (limited to 'src/test')
-rw-r--r--src/test/test-strv.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/test/test-strv.c b/src/test/test-strv.c
index c8c5fc97a8..24ed681482 100644
--- a/src/test/test-strv.c
+++ b/src/test/test-strv.c
@@ -323,6 +323,20 @@ static void test_strv_extend(void) {
assert_se(streq(b[0], "test3"));
}
+static void test_strv_extendf(void) {
+ _cleanup_strv_free_ char **a = NULL, **b = NULL;
+
+ a = strv_new("test", "test1", NULL);
+ assert_se(a);
+ assert_se(strv_extendf(&a, "test2 %s %d %s", "foo", 128, "bar") >= 0);
+ assert_se(strv_extendf(&b, "test3 %s %s %d", "bar", "foo", 128) >= 0);
+
+ assert_se(streq(a[0], "test"));
+ assert_se(streq(a[1], "test1"));
+ assert_se(streq(a[2], "test2 foo 128 bar"));
+ assert_se(streq(b[0], "test3 bar foo 128"));
+}
+
static void test_strv_foreach(void) {
_cleanup_strv_free_ char **a;
unsigned i = 0;
@@ -421,6 +435,7 @@ int main(int argc, char *argv[]) {
test_strv_extend_strv();
test_strv_extend_strv_concat();
test_strv_extend();
+ test_strv_extendf();
test_strv_from_stdarg_alloca();
return 0;