chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
927be00
)
tests: add tests for strv_extendf
author
Ronny Chevalier
<chevalier.ronny@gmail.com>
Thu, 19 Jun 2014 22:25:58 +0000
(
00:25
+0200)
committer
Zbigniew Jędrzejewski-Szmek
<zbyszek@in.waw.pl>
Thu, 19 Jun 2014 23:59:57 +0000
(19:59 -0400)
src/test/test-strv.c
patch
|
blob
|
history
diff --git
a/src/test/test-strv.c
b/src/test/test-strv.c
index c8c5fc97a8bb8447785a6c10b6d740fddc753cd4..24ed681482ec240c8eb0a9c9c687a92853ee49bc 100644
(file)
--- 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"));
}
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;
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_extend_strv();
test_strv_extend_strv_concat();
test_strv_extend();
+ test_strv_extendf();
test_strv_from_stdarg_alloca();
return 0;
test_strv_from_stdarg_alloca();
return 0;