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 void test_split(void) {
26 fprintf(stderr, "test_split\n");
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("\'misquoted\\\"", &nv, SPLIT_COMMENTS|SPLIT_QUOTES, 0, 0) == 0);
31 insist(split("\'mis\\escaped\'", &nv, SPLIT_COMMENTS|SPLIT_QUOTES, 0, 0) == 0);
33 insist((v = split("", &nv, SPLIT_COMMENTS|SPLIT_QUOTES, 0, 0)));
37 insist((v = split("wibble", &nv, SPLIT_COMMENTS|SPLIT_QUOTES, 0, 0)));
39 check_string(v[0], "wibble");
42 insist((v = split(" wibble \t\r\n wobble ", &nv,
43 SPLIT_COMMENTS|SPLIT_QUOTES, 0, 0)));
45 check_string(v[0], "wibble");
46 check_string(v[1], "wobble");
49 insist((v = split("wibble wobble #splat", &nv,
50 SPLIT_COMMENTS|SPLIT_QUOTES, 0, 0)));
52 check_string(v[0], "wibble");
53 check_string(v[1], "wobble");
56 insist((v = split("\"wibble wobble\" #splat", &nv,
57 SPLIT_COMMENTS|SPLIT_QUOTES, 0, 0)));
59 check_string(v[0], "wibble wobble");
62 insist((v = split("\"wibble \\\"\\nwobble\"", &nv,
63 SPLIT_COMMENTS|SPLIT_QUOTES, 0, 0)));
65 check_string(v[0], "wibble \"\nwobble");
68 insist((v = split("\"wibble wobble\" #splat", &nv,
69 SPLIT_QUOTES, 0, 0)));
71 check_string(v[0], "wibble wobble");
72 check_string(v[1], "#splat");
75 insist((v = split("\"wibble wobble\" #splat", &nv,
76 SPLIT_COMMENTS, 0, 0)));
78 check_string(v[0], "\"wibble");
79 check_string(v[1], "wobble\"");
82 check_string(quoteutf8("wibble"), "wibble");
83 check_string(quoteutf8(" wibble "), "\" wibble \"");
84 check_string(quoteutf8("wibble wobble"), "\"wibble wobble\"");
85 check_string(quoteutf8("wibble\"wobble"), "\"wibble\\\"wobble\"");
86 check_string(quoteutf8("wibble\nwobble"), "\"wibble\\nwobble\"");
87 check_string(quoteutf8("wibble\\wobble"), "\"wibble\\\\wobble\"");
88 check_string(quoteutf8("wibble'wobble"), "\"wibble'wobble\"");