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
26 fprintf(stderr, "test_kvp\n");
28 #define KVP_URLDECODE(S) kvp_urldecode((S), strlen(S))
29 insist(KVP_URLDECODE("=%zz") == 0);
30 insist(KVP_URLDECODE("=%0") == 0);
31 insist(KVP_URLDECODE("=%0z") == 0);
32 insist(KVP_URLDECODE("=%%") == 0);
33 insist(KVP_URLDECODE("==%") == 0);
34 insist(KVP_URLDECODE("wibble") == 0);
35 insist(KVP_URLDECODE("") == 0);
36 insist(KVP_URLDECODE("wibble&") == 0);
37 insist((k = KVP_URLDECODE("one=bl%61t+foo")) != 0);
38 check_string(kvp_get(k, "one"), "blat foo");
39 insist(kvp_get(k, "ONE") == 0);
41 insist((k = KVP_URLDECODE("wibble=splat&bar=spong")) != 0);
42 check_string(kvp_get(k, "wibble"), "splat");
43 check_string(kvp_get(k, "bar"), "spong");
44 insist(kvp_get(k, "ONE") == 0);
45 insist(k->next->next == 0);
47 insist(kvp_set(&k, "bar", "spong") == 0);
48 insist(kvp_set(&k, "bar", "foo") == 1);
49 insist(kvp_set(&k, "zog", "%") == 1);
50 insist(kvp_set(&k, "wibble", 0) == 1);
51 insist(kvp_set(&k, "wibble", 0) == 0);
52 check_string(kvp_urlencode(k, 0),
54 check_string(kvp_urlencode(k, &n),
56 insist(n == strlen("bar=foo&zog=%25"));
57 check_string(urlencodestring("abc% +\n"),