assert(s);
+ s += strspn(s, separator);
+ if (isempty(s))
+ return new0(char*, 1);
+
n = 0;
FOREACH_WORD_SEPARATOR(word, l, s, separator, state)
n++;
const char str[] = "one,two,three";
l = strv_split(str, ",");
-
assert_se(l);
+ STRV_FOREACH(s, l)
+ assert_se(streq(*s, input_table_multiple[i++]));
- STRV_FOREACH(s, l) {
+ i = 0;
+ strv_free(l);
+
+ l = strv_split(" one two\t three", WHITESPACE);
+ assert_se(l);
+ STRV_FOREACH(s, l)
assert_se(streq(*s, input_table_multiple[i++]));
- }
+}
+
+static void test_strv_split_empty(void) {
+ _cleanup_strv_free_ char **l = NULL;
+
+ l = strv_split("", WHITESPACE);
+ assert_se(l);
+ assert_se(strv_isempty(l));
+
+ strv_free(l);
+ l = strv_split(" ", WHITESPACE);
+ assert_se(l);
+ assert_se(strv_isempty(l));
+
}
static void test_strv_split_extract(void) {
test_invalid_unquote("'x'y'g");
test_strv_split();
+ test_strv_split_empty();
test_strv_split_extract();
test_strv_split_newlines();
test_strv_split_nulstr();