[systemd-devel] [PATCH 2/3] test-strv.c: added strv_split_newline

Daniel Buch boogiewasthere at gmail.com
Thu Oct 31 10:03:09 CET 2013


---
 src/test/test-strv.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/src/test/test-strv.c b/src/test/test-strv.c
index e96200e..9b51d82 100644
--- a/src/test/test-strv.c
+++ b/src/test/test-strv.c
@@ -171,6 +171,21 @@ static void test_strv_split(void) {
         }
 }
 
+static void test_strv_split_newlines(void) {
+        unsigned i = 0;
+        char **s;
+        _cleanup_strv_free_ char **l = NULL;
+        const char str[] = "one\ntwo\nthree";
+
+        l = strv_split_newlines(str);
+
+        assert(l);
+
+        STRV_FOREACH(s, l) {
+                assert_se(streq(*s, input_table_multiple[i++]));
+        }
+}
+
 static void test_strv_split_nulstr(void) {
         _cleanup_strv_free_ char **l = NULL;
         const char nulstr[] = "str0\0str1\0str2\0str3\0";
@@ -375,6 +390,7 @@ int main(int argc, char *argv[]) {
         test_strv_quote_unquote(input_table_spaces, SPACES_STRING);
 
         test_strv_split();
+        test_strv_split_newlines();
         test_strv_split_nulstr();
         test_strv_parse_nulstr();
         test_strv_overlap();
-- 
1.8.4.2



More information about the systemd-devel mailing list