2 * This file is part of DisOrder.
3 * Copyright (C) 2005, 2007, 2008 Richard Kettlewell
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 static void test_split(void) {
24 insist(split("\"misquoted", &nv, SPLIT_COMMENTS|SPLIT_QUOTES, 0, 0) == 0);
25 insist(split("\'misquoted", &nv, SPLIT_COMMENTS|SPLIT_QUOTES, 0, 0) == 0);
26 insist(split("\'misquoted\\", &nv, SPLIT_COMMENTS|SPLIT_QUOTES, 0, 0) == 0);
27 insist(split("\'misquoted\\\"", &nv, SPLIT_COMMENTS|SPLIT_QUOTES, 0, 0) == 0);
28 insist(split("\'mis\\escaped\'", &nv, SPLIT_COMMENTS|SPLIT_QUOTES, 0, 0) == 0);
30 insist((v = split("", &nv, SPLIT_COMMENTS|SPLIT_QUOTES, 0, 0)));
34 insist((v = split("wibble", &nv, SPLIT_COMMENTS|SPLIT_QUOTES, 0, 0)));
36 check_string(v[0], "wibble");
39 insist((v = split(" wibble \t\r\n wobble ", &nv,
40 SPLIT_COMMENTS|SPLIT_QUOTES, 0, 0)));
42 check_string(v[0], "wibble");
43 check_string(v[1], "wobble");
46 insist((v = split("wibble wobble #splat", &nv,
47 SPLIT_COMMENTS|SPLIT_QUOTES, 0, 0)));
49 check_string(v[0], "wibble");
50 check_string(v[1], "wobble");
53 insist((v = split("\"wibble wobble\" #splat", &nv,
54 SPLIT_COMMENTS|SPLIT_QUOTES, 0, 0)));
56 check_string(v[0], "wibble wobble");
59 insist((v = split("\"wibble \\\"\\nwobble\"", &nv,
60 SPLIT_COMMENTS|SPLIT_QUOTES, 0, 0)));
62 check_string(v[0], "wibble \"\nwobble");
65 insist((v = split("\"wibble wobble\" #splat", &nv,
66 SPLIT_QUOTES, 0, 0)));
68 check_string(v[0], "wibble wobble");
69 check_string(v[1], "#splat");
72 insist((v = split("\"wibble wobble\" #splat", &nv,
73 SPLIT_COMMENTS, 0, 0)));
75 check_string(v[0], "\"wibble");
76 check_string(v[1], "wobble\"");
79 check_string(quoteutf8("wibble"), "wibble");
80 check_string(quoteutf8(" wibble "), "\" wibble \"");
81 check_string(quoteutf8("wibble wobble"), "\"wibble wobble\"");
82 check_string(quoteutf8("wibble\"wobble"), "\"wibble\\\"wobble\"");
83 check_string(quoteutf8("wibble\nwobble"), "\"wibble\\nwobble\"");
84 check_string(quoteutf8("wibble\\wobble"), "\"wibble\\\\wobble\"");
85 check_string(quoteutf8("wibble'wobble"), "\"wibble'wobble\"");