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 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * 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, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22 static void test_split(void) {
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("\'misquoted\\", &nv, SPLIT_COMMENTS|SPLIT_QUOTES, 0, 0) == 0);
29 insist(split("\'misquoted\\\"", &nv, SPLIT_COMMENTS|SPLIT_QUOTES, 0, 0) == 0);
30 insist(split("\'mis\\escaped\'", &nv, SPLIT_COMMENTS|SPLIT_QUOTES, 0, 0) == 0);
32 insist((v = split("", &nv, SPLIT_COMMENTS|SPLIT_QUOTES, 0, 0)));
36 insist((v = split("wibble", &nv, SPLIT_COMMENTS|SPLIT_QUOTES, 0, 0)));
38 check_string(v[0], "wibble");
41 insist((v = split(" wibble \t\r\n wobble ", &nv,
42 SPLIT_COMMENTS|SPLIT_QUOTES, 0, 0)));
44 check_string(v[0], "wibble");
45 check_string(v[1], "wobble");
48 insist((v = split("wibble wobble #splat", &nv,
49 SPLIT_COMMENTS|SPLIT_QUOTES, 0, 0)));
51 check_string(v[0], "wibble");
52 check_string(v[1], "wobble");
55 insist((v = split("\"wibble wobble\" #splat", &nv,
56 SPLIT_COMMENTS|SPLIT_QUOTES, 0, 0)));
58 check_string(v[0], "wibble wobble");
61 insist((v = split("\"wibble \\\"\\nwobble\"", &nv,
62 SPLIT_COMMENTS|SPLIT_QUOTES, 0, 0)));
64 check_string(v[0], "wibble \"\nwobble");
67 insist((v = split("\"wibble wobble\" #splat", &nv,
68 SPLIT_QUOTES, 0, 0)));
70 check_string(v[0], "wibble wobble");
71 check_string(v[1], "#splat");
74 insist((v = split("\"wibble wobble\" #splat", &nv,
75 SPLIT_COMMENTS, 0, 0)));
77 check_string(v[0], "\"wibble");
78 check_string(v[1], "wobble\"");
81 check_string(quoteutf8("wibble"), "wibble");
82 check_string(quoteutf8(" wibble "), "\" wibble \"");
83 check_string(quoteutf8("wibble wobble"), "\"wibble wobble\"");
84 check_string(quoteutf8("wibble\"wobble"), "\"wibble\\\"wobble\"");
85 check_string(quoteutf8("wibble\nwobble"), "\"wibble\\nwobble\"");
86 check_string(quoteutf8("wibble\\wobble"), "\"wibble\\\\wobble\"");
87 check_string(quoteutf8("wibble'wobble"), "\"wibble'wobble\"");