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