summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-07-28 20:01:56 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-07-31 04:00:31 -0400
commit73381fcf54e38456067f0e87b8611a21eff99169 (patch)
tree9df3c96b5dc3836d4f01adcb2a856324d13c7907 /src/test
parent2b49732c3d511007ae2c413997e56c40f678d79a (diff)
test-strv: add test which shows access to random memory
Diffstat (limited to 'src/test')
-rw-r--r--src/test/test-strv.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/src/test/test-strv.c b/src/test/test-strv.c
index 24ed681482..370219121b 100644
--- a/src/test/test-strv.c
+++ b/src/test/test-strv.c
@@ -157,13 +157,14 @@ static void test_strv_quote_unquote(const char* const *split, const char *quoted
}
}
-static void test_strv_quote_unquote2(const char *quoted, const char ** list) {
+static void test_strv_unquote(const char *quoted, const char **list) {
_cleanup_strv_free_ char **s;
unsigned i = 0;
char **t;
s = strv_split_quoted(quoted);
assert_se(s);
+ strv_print(s);
STRV_FOREACH(t, s)
assert_se(streq(list[i++], *t));
@@ -414,17 +415,20 @@ int main(int argc, char *argv[]) {
test_strv_quote_unquote(input_table_quotes, QUOTES_STRING);
test_strv_quote_unquote(input_table_spaces, SPACES_STRING);
- test_strv_quote_unquote2(" foo=bar \"waldo\" zzz ", (const char*[]) { "foo=bar", "waldo", "zzz", NULL });
- test_strv_quote_unquote2("", (const char*[]) { NULL });
- test_strv_quote_unquote2(" ", (const char*[]) { NULL });
- test_strv_quote_unquote2(" ", (const char*[]) { NULL });
- test_strv_quote_unquote2(" x", (const char*[]) { "x", NULL });
- test_strv_quote_unquote2("x ", (const char*[]) { "x", NULL });
- test_strv_quote_unquote2(" x ", (const char*[]) { "x", NULL });
- test_strv_quote_unquote2(" \"x\" ", (const char*[]) { "x", NULL });
- test_strv_quote_unquote2(" \'x\' ", (const char*[]) { "x", NULL });
- test_strv_quote_unquote2(" \'x\"\' ", (const char*[]) { "x\"", NULL });
- test_strv_quote_unquote2(" \"x\'\" ", (const char*[]) { "x\'", NULL });
+ test_strv_unquote(" foo=bar \"waldo\" zzz ", (const char*[]) { "foo=bar", "waldo", "zzz", NULL });
+ test_strv_unquote("", (const char*[]) { NULL });
+ test_strv_unquote(" ", (const char*[]) { NULL });
+ test_strv_unquote(" ", (const char*[]) { NULL });
+ test_strv_unquote(" x", (const char*[]) { "x", NULL });
+ test_strv_unquote("x ", (const char*[]) { "x", NULL });
+ test_strv_unquote(" x ", (const char*[]) { "x", NULL });
+ test_strv_unquote(" \"x\" ", (const char*[]) { "x", NULL });
+ test_strv_unquote(" 'x' ", (const char*[]) { "x", NULL });
+ test_strv_unquote(" 'x\"' ", (const char*[]) { "x\"", NULL });
+ test_strv_unquote(" \"x'\" ", (const char*[]) { "x'", NULL });
+ test_strv_unquote("a '--b=c \"d e\"'", (const char*[]) { "a", "--b=c \"d e\"", NULL });
+
+ test_strv_unquote("a --b='c \"d e\"'", (const char*[]) { "a", "--b='c", "\"d", "e\"'", NULL });
test_strv_split();
test_strv_split_newlines();