]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/test/test-strv.c
vxlan: fix assert
[thirdparty/systemd.git] / src / test / test-strv.c
1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2
3 /***
4 This file is part of systemd.
5
6 Copyright 2010 Lennart Poettering
7 Copyright 2013 Thomas H.P. Andersen
8
9 systemd is free software; you can redistribute it and/or modify it
10 under the terms of the GNU Lesser General Public License as published by
11 the Free Software Foundation; either version 2.1 of the License, or
12 (at your option) any later version.
13
14 systemd is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Lesser General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public License
20 along with systemd; If not, see <http://www.gnu.org/licenses/>.
21 ***/
22
23 #include <string.h>
24
25 #include "util.h"
26 #include "specifier.h"
27 #include "strv.h"
28
29 static void test_specifier_printf(void) {
30 static const Specifier table[] = {
31 { 'a', specifier_string, (char*) "AAAA" },
32 { 'b', specifier_string, (char*) "BBBB" },
33 { 'm', specifier_machine_id, NULL },
34 { 'B', specifier_boot_id, NULL },
35 { 'H', specifier_host_name, NULL },
36 { 'v', specifier_kernel_release, NULL },
37 {}
38 };
39
40 _cleanup_free_ char *w = NULL;
41 int r;
42
43 r = specifier_printf("xxx a=%a b=%b yyy", table, NULL, &w);
44 assert_se(r >= 0);
45 assert_se(w);
46
47 puts(w);
48 assert_se(streq(w, "xxx a=AAAA b=BBBB yyy"));
49
50 free(w);
51 r = specifier_printf("machine=%m, boot=%B, host=%H, version=%v", table, NULL, &w);
52 assert_se(r >= 0);
53 assert_se(w);
54 puts(w);
55 }
56
57 static const char* const input_table_multiple[] = {
58 "one",
59 "two",
60 "three",
61 NULL,
62 };
63
64 static const char* const input_table_one[] = {
65 "one",
66 NULL,
67 };
68
69 static const char* const input_table_none[] = {
70 NULL,
71 };
72
73 static const char* const input_table_quotes[] = {
74 "\"",
75 "'",
76 "\"\"",
77 "\\",
78 "\\\\",
79 NULL,
80 };
81 #define QUOTES_STRING \
82 "\"\\\"\" " \
83 "\"\\\'\" " \
84 "\"\\\"\\\"\" " \
85 "\"\\\\\" " \
86 "\"\\\\\\\\\""
87
88 static const char * const input_table_spaces[] = {
89 " ",
90 "' '",
91 "\" ",
92 " \"",
93 " \\\\ ",
94 NULL,
95 };
96 #define SPACES_STRING \
97 "\" \" " \
98 "\"\\' \\'\" " \
99 "\"\\\" \" " \
100 "\" \\\"\" " \
101 "\" \\\\\\\\ \""
102
103 static void test_strv_find(void) {
104 assert_se(strv_find((char **)input_table_multiple, "three"));
105 assert_se(!strv_find((char **)input_table_multiple, "four"));
106 }
107
108 static void test_strv_find_prefix(void) {
109 assert_se(strv_find_prefix((char **)input_table_multiple, "o"));
110 assert_se(strv_find_prefix((char **)input_table_multiple, "one"));
111 assert_se(strv_find_prefix((char **)input_table_multiple, ""));
112 assert_se(!strv_find_prefix((char **)input_table_multiple, "xxx"));
113 assert_se(!strv_find_prefix((char **)input_table_multiple, "onee"));
114 }
115
116 static void test_strv_find_startswith(void) {
117 char *r;
118
119 r = strv_find_startswith((char **)input_table_multiple, "o");
120 assert_se(r && streq(r, "ne"));
121
122 r = strv_find_startswith((char **)input_table_multiple, "one");
123 assert_se(r && streq(r, ""));
124
125 r = strv_find_startswith((char **)input_table_multiple, "");
126 assert_se(r && streq(r, "one"));
127
128 assert_se(!strv_find_startswith((char **)input_table_multiple, "xxx"));
129 assert_se(!strv_find_startswith((char **)input_table_multiple, "onee"));
130 }
131
132 static void test_strv_join(void) {
133 _cleanup_free_ char *p = NULL, *q = NULL, *r = NULL, *s = NULL, *t = NULL;
134
135 p = strv_join((char **)input_table_multiple, ", ");
136 assert_se(p);
137 assert_se(streq(p, "one, two, three"));
138
139 q = strv_join((char **)input_table_multiple, ";");
140 assert_se(q);
141 assert_se(streq(q, "one;two;three"));
142
143 r = strv_join((char **)input_table_multiple, NULL);
144 assert_se(r);
145 assert_se(streq(r, "one two three"));
146
147 s = strv_join((char **)input_table_one, ", ");
148 assert_se(s);
149 assert_se(streq(s, "one"));
150
151 t = strv_join((char **)input_table_none, ", ");
152 assert_se(t);
153 assert_se(streq(t, ""));
154 }
155
156 static void test_strv_quote_unquote(const char* const *split, const char *quoted) {
157 _cleanup_free_ char *p;
158 _cleanup_strv_free_ char **s = NULL;
159 char **t;
160 int r;
161
162 p = strv_join_quoted((char **)split);
163 assert_se(p);
164 printf("-%s- --- -%s-\n", p, quoted); /* fprintf deals with NULL, puts does not */
165 assert_se(p);
166 assert_se(streq(p, quoted));
167
168 r = strv_split_extract(&s, quoted, WHITESPACE, EXTRACT_QUOTES);
169 assert_se(r == (int) strv_length(s));
170 assert_se(s);
171 STRV_FOREACH(t, s) {
172 assert_se(*t);
173 assert_se(streq(*t, *split));
174 split++;
175 }
176 }
177
178 static void test_strv_unquote(const char *quoted, char **list) {
179 _cleanup_strv_free_ char **s;
180 _cleanup_free_ char *j;
181 unsigned i = 0;
182 char **t;
183 int r;
184
185 r = strv_split_extract(&s, quoted, WHITESPACE, EXTRACT_QUOTES);
186 assert_se(r == (int) strv_length(list));
187 assert_se(s);
188 j = strv_join(s, " | ");
189 assert_se(j);
190 puts(j);
191
192 STRV_FOREACH(t, s)
193 assert_se(streq(list[i++], *t));
194
195 assert_se(list[i] == NULL);
196 }
197
198 static void test_invalid_unquote(const char *quoted) {
199 char **s = NULL;
200 int r;
201
202 r = strv_split_extract(&s, quoted, WHITESPACE, EXTRACT_QUOTES);
203 assert_se(s == NULL);
204 assert_se(r == -EINVAL);
205 }
206
207 static void test_strv_split(void) {
208 char **s;
209 unsigned i = 0;
210 _cleanup_strv_free_ char **l = NULL;
211 const char str[] = "one,two,three";
212
213 l = strv_split(str, ",");
214
215 assert_se(l);
216
217 STRV_FOREACH(s, l) {
218 assert_se(streq(*s, input_table_multiple[i++]));
219 }
220 }
221
222 static void test_strv_split_extract(void) {
223 _cleanup_strv_free_ char **l = NULL;
224 const char *str = ":foo\\:bar::waldo:";
225 int r;
226
227 r = strv_split_extract(&l, str, ":", EXTRACT_DONT_COALESCE_SEPARATORS);
228 assert_se(r == (int) strv_length(l));
229 assert_se(streq_ptr(l[0], ""));
230 assert_se(streq_ptr(l[1], "foo:bar"));
231 assert_se(streq_ptr(l[2], ""));
232 assert_se(streq_ptr(l[3], "waldo"));
233 assert_se(streq_ptr(l[4], ""));
234 assert_se(streq_ptr(l[5], NULL));
235 }
236
237 static void test_strv_split_newlines(void) {
238 unsigned i = 0;
239 char **s;
240 _cleanup_strv_free_ char **l = NULL;
241 const char str[] = "one\ntwo\nthree";
242
243 l = strv_split_newlines(str);
244
245 assert_se(l);
246
247 STRV_FOREACH(s, l) {
248 assert_se(streq(*s, input_table_multiple[i++]));
249 }
250 }
251
252 static void test_strv_split_nulstr(void) {
253 _cleanup_strv_free_ char **l = NULL;
254 const char nulstr[] = "str0\0str1\0str2\0str3\0";
255
256 l = strv_split_nulstr (nulstr);
257 assert_se(l);
258
259 assert_se(streq(l[0], "str0"));
260 assert_se(streq(l[1], "str1"));
261 assert_se(streq(l[2], "str2"));
262 assert_se(streq(l[3], "str3"));
263 }
264
265 static void test_strv_parse_nulstr(void) {
266 _cleanup_strv_free_ char **l = NULL;
267 const char nulstr[] = "fuck\0fuck2\0fuck3\0\0fuck5\0\0xxx";
268
269 l = strv_parse_nulstr(nulstr, sizeof(nulstr)-1);
270 assert_se(l);
271 puts("Parse nulstr:");
272 strv_print(l);
273
274 assert_se(streq(l[0], "fuck"));
275 assert_se(streq(l[1], "fuck2"));
276 assert_se(streq(l[2], "fuck3"));
277 assert_se(streq(l[3], ""));
278 assert_se(streq(l[4], "fuck5"));
279 assert_se(streq(l[5], ""));
280 assert_se(streq(l[6], "xxx"));
281 }
282
283 static void test_strv_overlap(void) {
284 const char * const input_table[] = {
285 "one",
286 "two",
287 "three",
288 NULL
289 };
290 const char * const input_table_overlap[] = {
291 "two",
292 NULL
293 };
294 const char * const input_table_unique[] = {
295 "four",
296 "five",
297 "six",
298 NULL
299 };
300
301 assert_se(strv_overlap((char **)input_table, (char**)input_table_overlap));
302 assert_se(!strv_overlap((char **)input_table, (char**)input_table_unique));
303 }
304
305 static void test_strv_sort(void) {
306 const char* input_table[] = {
307 "durian",
308 "apple",
309 "citrus",
310 "CAPITAL LETTERS FIRST",
311 "banana",
312 NULL
313 };
314
315 strv_sort((char **)input_table);
316
317 assert_se(streq(input_table[0], "CAPITAL LETTERS FIRST"));
318 assert_se(streq(input_table[1], "apple"));
319 assert_se(streq(input_table[2], "banana"));
320 assert_se(streq(input_table[3], "citrus"));
321 assert_se(streq(input_table[4], "durian"));
322 }
323
324 static void test_strv_extend_strv_concat(void) {
325 _cleanup_strv_free_ char **a = NULL, **b = NULL;
326
327 a = strv_new("without", "suffix", NULL);
328 b = strv_new("with", "suffix", NULL);
329 assert_se(a);
330 assert_se(b);
331
332 assert_se(strv_extend_strv_concat(&a, b, "_suffix") >= 0);
333
334 assert_se(streq(a[0], "without"));
335 assert_se(streq(a[1], "suffix"));
336 assert_se(streq(a[2], "with_suffix"));
337 assert_se(streq(a[3], "suffix_suffix"));
338 }
339
340 static void test_strv_extend_strv(void) {
341 _cleanup_strv_free_ char **a = NULL, **b = NULL;
342
343 a = strv_new("abc", "def", "ghi", NULL);
344 b = strv_new("jkl", "mno", "abc", "pqr", NULL);
345 assert_se(a);
346 assert_se(b);
347
348 assert_se(strv_extend_strv(&a, b, true) == 3);
349
350 assert_se(streq(a[0], "abc"));
351 assert_se(streq(a[1], "def"));
352 assert_se(streq(a[2], "ghi"));
353 assert_se(streq(a[3], "jkl"));
354 assert_se(streq(a[4], "mno"));
355 assert_se(streq(a[5], "pqr"));
356
357 assert_se(strv_length(a) == 6);
358 }
359
360 static void test_strv_extend(void) {
361 _cleanup_strv_free_ char **a = NULL, **b = NULL;
362
363 a = strv_new("test", "test1", NULL);
364 assert_se(a);
365 assert_se(strv_extend(&a, "test2") >= 0);
366 assert_se(strv_extend(&b, "test3") >= 0);
367
368 assert_se(streq(a[0], "test"));
369 assert_se(streq(a[1], "test1"));
370 assert_se(streq(a[2], "test2"));
371 assert_se(streq(b[0], "test3"));
372 }
373
374 static void test_strv_extendf(void) {
375 _cleanup_strv_free_ char **a = NULL, **b = NULL;
376
377 a = strv_new("test", "test1", NULL);
378 assert_se(a);
379 assert_se(strv_extendf(&a, "test2 %s %d %s", "foo", 128, "bar") >= 0);
380 assert_se(strv_extendf(&b, "test3 %s %s %d", "bar", "foo", 128) >= 0);
381
382 assert_se(streq(a[0], "test"));
383 assert_se(streq(a[1], "test1"));
384 assert_se(streq(a[2], "test2 foo 128 bar"));
385 assert_se(streq(b[0], "test3 bar foo 128"));
386 }
387
388 static void test_strv_foreach(void) {
389 _cleanup_strv_free_ char **a;
390 unsigned i = 0;
391 char **check;
392
393 a = strv_new("one", "two", "three", NULL);
394
395 assert_se(a);
396
397 STRV_FOREACH(check, a) {
398 assert_se(streq(*check, input_table_multiple[i++]));
399 }
400 }
401
402 static void test_strv_foreach_backwards(void) {
403 _cleanup_strv_free_ char **a;
404 unsigned i = 2;
405 char **check;
406
407 a = strv_new("one", "two", "three", NULL);
408
409 assert_se(a);
410
411 STRV_FOREACH_BACKWARDS(check, a) {
412 assert_se(streq_ptr(*check, input_table_multiple[i--]));
413 }
414 }
415
416 static void test_strv_foreach_pair(void) {
417 _cleanup_strv_free_ char **a = NULL;
418 char **x, **y;
419
420 a = strv_new("pair_one", "pair_one",
421 "pair_two", "pair_two",
422 "pair_three", "pair_three",
423 NULL);
424
425 STRV_FOREACH_PAIR(x, y, a) {
426 assert_se(streq(*x, *y));
427 }
428 }
429
430 static void test_strv_from_stdarg_alloca_one(char **l, const char *first, ...) {
431 char **j;
432 unsigned i;
433
434 j = strv_from_stdarg_alloca(first);
435
436 for (i = 0;; i++) {
437 assert_se(streq_ptr(l[i], j[i]));
438
439 if (!l[i])
440 break;
441 }
442 }
443
444 static void test_strv_from_stdarg_alloca(void) {
445 test_strv_from_stdarg_alloca_one(STRV_MAKE("foo", "bar"), "foo", "bar", NULL);
446 test_strv_from_stdarg_alloca_one(STRV_MAKE("foo"), "foo", NULL);
447 test_strv_from_stdarg_alloca_one(STRV_MAKE_EMPTY, NULL);
448 }
449
450 static void test_strv_push_prepend(void) {
451 _cleanup_strv_free_ char **a = NULL;
452
453 a = strv_new("foo", "bar", "three", NULL);
454
455 assert_se(strv_push_prepend(&a, strdup("first")) >= 0);
456 assert_se(streq(a[0], "first"));
457 assert_se(streq(a[1], "foo"));
458 assert_se(streq(a[2], "bar"));
459 assert_se(streq(a[3], "three"));
460 assert_se(!a[4]);
461
462 assert_se(strv_consume_prepend(&a, strdup("first2")) >= 0);
463 assert_se(streq(a[0], "first2"));
464 assert_se(streq(a[1], "first"));
465 assert_se(streq(a[2], "foo"));
466 assert_se(streq(a[3], "bar"));
467 assert_se(streq(a[4], "three"));
468 assert_se(!a[5]);
469 }
470
471 static void test_strv_push(void) {
472 _cleanup_strv_free_ char **a = NULL;
473 char *i, *j;
474
475 assert_se(i = strdup("foo"));
476 assert_se(strv_push(&a, i) >= 0);
477
478 assert_se(i = strdup("a"));
479 assert_se(j = strdup("b"));
480 assert_se(strv_push_pair(&a, i, j) >= 0);
481
482 assert_se(streq_ptr(a[0], "foo"));
483 assert_se(streq_ptr(a[1], "a"));
484 assert_se(streq_ptr(a[2], "b"));
485 assert_se(streq_ptr(a[3], NULL));
486 }
487
488 static void test_strv_equal(void) {
489 _cleanup_strv_free_ char **a = NULL;
490 _cleanup_strv_free_ char **b = NULL;
491 _cleanup_strv_free_ char **c = NULL;
492
493 a = strv_new("one", "two", "three", NULL);
494 assert_se(a);
495 b = strv_new("one", "two", "three", NULL);
496 assert_se(a);
497 c = strv_new("one", "two", "three", "four", NULL);
498 assert_se(a);
499
500 assert_se(strv_equal(a, a));
501 assert_se(strv_equal(a, b));
502 assert_se(strv_equal(NULL, NULL));
503
504 assert_se(!strv_equal(a, c));
505 assert_se(!strv_equal(b, c));
506 assert_se(!strv_equal(b, NULL));
507 }
508
509 static void test_strv_is_uniq(void) {
510 _cleanup_strv_free_ char **a = NULL, **b = NULL, **c = NULL, **d = NULL;
511
512 a = strv_new(NULL, NULL);
513 assert_se(a);
514 assert_se(strv_is_uniq(a));
515
516 b = strv_new("foo", NULL);
517 assert_se(b);
518 assert_se(strv_is_uniq(b));
519
520 c = strv_new("foo", "bar", NULL);
521 assert_se(c);
522 assert_se(strv_is_uniq(c));
523
524 d = strv_new("foo", "bar", "waldo", "bar", "piep", NULL);
525 assert_se(d);
526 assert_se(!strv_is_uniq(d));
527 }
528
529 static void test_strv_reverse(void) {
530 _cleanup_strv_free_ char **a = NULL, **b = NULL, **c = NULL, **d = NULL;
531
532 a = strv_new(NULL, NULL);
533 assert_se(a);
534
535 strv_reverse(a);
536 assert_se(strv_isempty(a));
537
538 b = strv_new("foo", NULL);
539 assert_se(b);
540 strv_reverse(b);
541 assert_se(streq_ptr(b[0], "foo"));
542 assert_se(streq_ptr(b[1], NULL));
543
544 c = strv_new("foo", "bar", NULL);
545 assert_se(c);
546 strv_reverse(c);
547 assert_se(streq_ptr(c[0], "bar"));
548 assert_se(streq_ptr(c[1], "foo"));
549 assert_se(streq_ptr(c[2], NULL));
550
551 d = strv_new("foo", "bar", "waldo", NULL);
552 assert_se(d);
553 strv_reverse(d);
554 assert_se(streq_ptr(d[0], "waldo"));
555 assert_se(streq_ptr(d[1], "bar"));
556 assert_se(streq_ptr(d[2], "foo"));
557 assert_se(streq_ptr(d[3], NULL));
558 }
559
560 static void test_strv_shell_escape(void) {
561 _cleanup_strv_free_ char **v = NULL;
562
563 v = strv_new("foo:bar", "bar,baz", "wal\\do", NULL);
564 assert_se(v);
565 assert_se(strv_shell_escape(v, ",:"));
566 assert_se(streq_ptr(v[0], "foo\\:bar"));
567 assert_se(streq_ptr(v[1], "bar\\,baz"));
568 assert_se(streq_ptr(v[2], "wal\\\\do"));
569 assert_se(streq_ptr(v[3], NULL));
570 }
571
572 static void test_strv_skip_one(char **a, size_t n, char **b) {
573 a = strv_skip(a, n);
574 assert_se(strv_equal(a, b));
575 }
576
577 static void test_strv_skip(void) {
578 test_strv_skip_one(STRV_MAKE("foo", "bar", "baz"), 0, STRV_MAKE("foo", "bar", "baz"));
579 test_strv_skip_one(STRV_MAKE("foo", "bar", "baz"), 1, STRV_MAKE("bar", "baz"));
580 test_strv_skip_one(STRV_MAKE("foo", "bar", "baz"), 2, STRV_MAKE("baz"));
581 test_strv_skip_one(STRV_MAKE("foo", "bar", "baz"), 3, STRV_MAKE(NULL));
582 test_strv_skip_one(STRV_MAKE("foo", "bar", "baz"), 4, STRV_MAKE(NULL));
583 test_strv_skip_one(STRV_MAKE("foo", "bar", "baz"), 55, STRV_MAKE(NULL));
584
585 test_strv_skip_one(STRV_MAKE("quux"), 0, STRV_MAKE("quux"));
586 test_strv_skip_one(STRV_MAKE("quux"), 1, STRV_MAKE(NULL));
587 test_strv_skip_one(STRV_MAKE("quux"), 55, STRV_MAKE(NULL));
588
589 test_strv_skip_one(STRV_MAKE(NULL), 0, STRV_MAKE(NULL));
590 test_strv_skip_one(STRV_MAKE(NULL), 1, STRV_MAKE(NULL));
591 test_strv_skip_one(STRV_MAKE(NULL), 55, STRV_MAKE(NULL));
592 }
593
594 static void test_strv_extend_n(void) {
595 _cleanup_strv_free_ char **v = NULL;
596
597 v = strv_new("foo", "bar", NULL);
598 assert_se(v);
599
600 assert_se(strv_extend_n(&v, "waldo", 3) >= 0);
601 assert_se(strv_extend_n(&v, "piep", 2) >= 0);
602
603 assert_se(streq(v[0], "foo"));
604 assert_se(streq(v[1], "bar"));
605 assert_se(streq(v[2], "waldo"));
606 assert_se(streq(v[3], "waldo"));
607 assert_se(streq(v[4], "waldo"));
608 assert_se(streq(v[5], "piep"));
609 assert_se(streq(v[6], "piep"));
610 assert_se(v[7] == NULL);
611
612 v = strv_free(v);
613
614 assert_se(strv_extend_n(&v, "foo", 1) >= 0);
615 assert_se(strv_extend_n(&v, "bar", 0) >= 0);
616
617 assert_se(streq(v[0], "foo"));
618 assert_se(v[1] == NULL);
619 }
620
621 static void test_strv_make_nulstr_one(char **l) {
622 _cleanup_free_ char *b = NULL, *c = NULL;
623 _cleanup_strv_free_ char **q = NULL;
624 size_t n, m;
625
626 assert_se(strv_make_nulstr(l, &b, &n) >= 0);
627 assert_se(q = strv_parse_nulstr(b, n));
628 assert_se(strv_equal(l, q));
629
630 assert_se(strv_make_nulstr(q, &c, &m) >= 0);
631 assert_se(m == n);
632 assert_se(memcmp(b, c, m) == 0);
633 }
634
635 static void test_strv_make_nulstr(void) {
636 test_strv_make_nulstr_one(NULL);
637 test_strv_make_nulstr_one(STRV_MAKE(NULL));
638 test_strv_make_nulstr_one(STRV_MAKE("foo"));
639 test_strv_make_nulstr_one(STRV_MAKE("foo", "bar"));
640 test_strv_make_nulstr_one(STRV_MAKE("foo", "bar", "quuux"));
641 }
642
643 int main(int argc, char *argv[]) {
644 test_specifier_printf();
645 test_strv_foreach();
646 test_strv_foreach_backwards();
647 test_strv_foreach_pair();
648 test_strv_find();
649 test_strv_find_prefix();
650 test_strv_find_startswith();
651 test_strv_join();
652
653 test_strv_quote_unquote(input_table_multiple, "\"one\" \"two\" \"three\"");
654 test_strv_quote_unquote(input_table_one, "\"one\"");
655 test_strv_quote_unquote(input_table_none, "");
656 test_strv_quote_unquote(input_table_quotes, QUOTES_STRING);
657 test_strv_quote_unquote(input_table_spaces, SPACES_STRING);
658
659 test_strv_unquote(" foo=bar \"waldo\" zzz ", STRV_MAKE("foo=bar", "waldo", "zzz"));
660 test_strv_unquote("", STRV_MAKE_EMPTY);
661 test_strv_unquote(" ", STRV_MAKE_EMPTY);
662 test_strv_unquote(" ", STRV_MAKE_EMPTY);
663 test_strv_unquote(" x", STRV_MAKE("x"));
664 test_strv_unquote("x ", STRV_MAKE("x"));
665 test_strv_unquote(" x ", STRV_MAKE("x"));
666 test_strv_unquote(" \"x\" ", STRV_MAKE("x"));
667 test_strv_unquote(" 'x' ", STRV_MAKE("x"));
668 test_strv_unquote(" 'x\"' ", STRV_MAKE("x\""));
669 test_strv_unquote(" \"x'\" ", STRV_MAKE("x'"));
670 test_strv_unquote("a '--b=c \"d e\"'", STRV_MAKE("a", "--b=c \"d e\""));
671
672 /* trailing backslashes */
673 test_strv_unquote(" x\\\\", STRV_MAKE("x\\"));
674 test_invalid_unquote(" x\\");
675
676 test_invalid_unquote("a --b='c \"d e\"''");
677 test_invalid_unquote("a --b='c \"d e\" '\"");
678 test_invalid_unquote("a --b='c \"d e\"garbage");
679 test_invalid_unquote("'");
680 test_invalid_unquote("\"");
681 test_invalid_unquote("'x'y'g");
682
683 test_strv_split();
684 test_strv_split_extract();
685 test_strv_split_newlines();
686 test_strv_split_nulstr();
687 test_strv_parse_nulstr();
688 test_strv_overlap();
689 test_strv_sort();
690 test_strv_extend_strv();
691 test_strv_extend_strv_concat();
692 test_strv_extend();
693 test_strv_extendf();
694 test_strv_from_stdarg_alloca();
695 test_strv_push_prepend();
696 test_strv_push();
697 test_strv_equal();
698 test_strv_is_uniq();
699 test_strv_reverse();
700 test_strv_shell_escape();
701 test_strv_skip();
702 test_strv_extend_n();
703 test_strv_make_nulstr();
704
705 return 0;
706 }