From: Luca Boccassi Date: Tue, 7 Jul 2020 16:10:47 +0000 (+0100) Subject: test: add another test case for extract_many_words X-Git-Tag: v247-rc1~446^2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=866fdcceb484e4b3bffcbf5ab0ea490f06d98e9c;p=thirdparty%2Fsystemd.git test: add another test case for extract_many_words Covers some functionality that we want to use for config tuples --- diff --git a/src/test/test-extract-word.c b/src/test/test-extract-word.c index 4ca57555f1d..43ad1b7d82f 100644 --- a/src/test/test-extract-word.c +++ b/src/test/test-extract-word.c @@ -489,7 +489,7 @@ static void test_extract_first_word_and_warn(void) { static void test_extract_many_words(void) { const char *p, *original; - char *a, *b, *c; + char *a, *b, *c, *d, *e, *f; p = original = "foobar waldi piep"; assert_se(extract_many_words(&p, NULL, 0, &a, &b, &c, NULL) == 3); @@ -501,6 +501,24 @@ static void test_extract_many_words(void) { free(b); free(c); + p = original = "foobar:waldi:piep ba1:ba2"; + assert_se(extract_many_words(&p, ":" WHITESPACE, 0, &a, &b, &c, NULL) == 3); + assert_se(!isempty(p)); + assert_se(streq_ptr(a, "foobar")); + assert_se(streq_ptr(b, "waldi")); + assert_se(streq_ptr(c, "piep")); + assert_se(extract_many_words(&p, ":" WHITESPACE, 0, &d, &e, &f, NULL) == 2); + assert_se(isempty(p)); + assert_se(streq_ptr(d, "ba1")); + assert_se(streq_ptr(e, "ba2")); + assert_se(isempty(f)); + free(a); + free(b); + free(c); + free(d); + free(e); + free(f); + p = original = "'foobar' wa\"ld\"i "; assert_se(extract_many_words(&p, NULL, 0, &a, &b, &c, NULL) == 2); assert_se(isempty(p));