summaryrefslogtreecommitdiff
path: root/src/test/test-string-util.c
diff options
context:
space:
mode:
authorMartin Pitt <martin.pitt@ubuntu.com>2016-11-08 09:41:51 +0100
committerGitHub <noreply@github.com>2016-11-08 09:41:51 +0100
commitca91fd2acac007f0096fea47b2cc8931baa3af57 (patch)
tree4da5222881a4b3ec7e3b55dfa18fb8b7f764daa7 /src/test/test-string-util.c
parented7fd549d0a1bfebe4e17a3f0e92879eb986d4a9 (diff)
parentbc8ec170d2bc3e294f24ff8bb255436a685ac14a (diff)
Merge pull request #4509 from keszybz/foreach-word-quoted
Remove FOREACH_WORD_QUOTED
Diffstat (limited to 'src/test/test-string-util.c')
-rw-r--r--src/test/test-string-util.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/test/test-string-util.c b/src/test/test-string-util.c
index d0f84d70bc..e43373b0f5 100644
--- a/src/test/test-string-util.c
+++ b/src/test/test-string-util.c
@@ -232,21 +232,25 @@ static void test_foreach_word(void) {
}
static void check(const char *test, char** expected, bool trailing) {
- const char *word, *state;
- size_t l;
- int i = 0;
+ int i = 0, r;
printf("<<<%s>>>\n", test);
- FOREACH_WORD_QUOTED(word, l, test, state) {
- _cleanup_free_ char *t = NULL;
-
- assert_se(t = strndup(word, l));
- assert_se(strneq(expected[i++], word, l));
- printf("<%s>\n", t);
+ for (;;) {
+ _cleanup_free_ char *word = NULL;
+
+ r = extract_first_word(&test, &word, NULL, EXTRACT_QUOTES);
+ if (r == 0) {
+ assert_se(!trailing);
+ break;
+ } else if (r < 0) {
+ assert_se(trailing);
+ break;
+ }
+
+ assert_se(streq(word, expected[i++]));
+ printf("<%s>\n", word);
}
- printf("<<<%s>>>\n", state);
assert_se(expected[i] == NULL);
- assert_se(isempty(state) == !trailing);
}
static void test_foreach_word_quoted(void) {