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_cookies(void) {
23 struct cookiedata cd
[1];
25 /* These are the examples from RFC2109 */
26 insist(!parse_cookie("$Version=\"1\"; Customer=\"WILE_E_COYOTE\"; $Path=\"/acme\"", cd
));
27 insist(!strcmp(cd
->version
, "1"));
28 insist(cd
->ncookies
== 1);
29 insist(find_cookie(cd
, "Customer") == &cd
->cookies
[0]);
30 check_string(cd
->cookies
[0].value
, "WILE_E_COYOTE");
31 check_string(cd
->cookies
[0].path
, "/acme");
32 insist(cd
->cookies
[0].domain
== 0);
33 insist(!parse_cookie("$Version=\"1\";\n"
34 "Customer=\"WILE_E_COYOTE\"; $Path=\"/acme\";\n"
35 "Part_Number=\"Rocket_Launcher_0001\"; $Path=\"/acme\"",
37 insist(cd
->ncookies
== 2);
38 insist(find_cookie(cd
, "Customer") == &cd
->cookies
[0]);
39 insist(find_cookie(cd
, "Part_Number") == &cd
->cookies
[1]);
40 check_string(cd
->cookies
[0].value
, "WILE_E_COYOTE");
41 check_string(cd
->cookies
[0].path
, "/acme");
42 insist(cd
->cookies
[0].domain
== 0);
43 check_string(cd
->cookies
[1].value
, "Rocket_Launcher_0001");
44 check_string(cd
->cookies
[1].path
, "/acme");
45 insist(cd
->cookies
[1].domain
== 0);
46 insist(!parse_cookie("$Version=\"1\";\n"
47 "Customer=\"WILE_E_COYOTE\"; $Path=\"/acme\";\n"
48 "Part_Number=\"Rocket_Launcher_0001\"; $Path=\"/acme\";\n"
49 "Shipping=\"FedEx\"; $Path=\"/acme\"",
51 insist(cd
->ncookies
== 3);
52 insist(find_cookie(cd
, "Customer") == &cd
->cookies
[0]);
53 insist(find_cookie(cd
, "Part_Number") == &cd
->cookies
[1]);
54 insist(find_cookie(cd
, "Shipping") == &cd
->cookies
[2]);
55 check_string(cd
->cookies
[0].value
, "WILE_E_COYOTE");
56 check_string(cd
->cookies
[0].path
, "/acme");
57 insist(cd
->cookies
[0].domain
== 0);
58 check_string(cd
->cookies
[1].value
, "Rocket_Launcher_0001");
59 check_string(cd
->cookies
[1].path
, "/acme");
60 insist(cd
->cookies
[1].domain
== 0);
61 check_string(cd
->cookies
[2].value
, "FedEx");
62 check_string(cd
->cookies
[2].path
, "/acme");
63 insist(cd
->cookies
[2].domain
== 0);
65 insist(!parse_cookie("BX=brqn3il3r9jro&b=3&s=vv", cd
));
66 insist(cd
->ncookies
== 1);
67 insist(find_cookie(cd
, "BX") == &cd
->cookies
[0]);
68 check_string(cd
->cookies
[0].value
, "brqn3il3r9jro&b=3&s=vv");
69 insist(cd
->cookies
[0].path
== 0);
70 insist(cd
->cookies
[0].domain
== 0);