mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-03-07 16:58:21 +03:00
test: add another test case for extract_many_words
Covers some functionality that we want to use for config tuples
This commit is contained in:
parent
28365e88d0
commit
866fdcceb4
@ -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));
|
||||
|
Loading…
x
Reference in New Issue
Block a user