chiark / gitweb /
Split up increasingly unwieldy lib/test.c into multiple files.
[disorder] / lib / t-url.c
1 /*
2  * This file is part of DisOrder.
3  * Copyright (C) 2005, 2007, 2008 Richard Kettlewell
4  *
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.
9  *
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.
14  *
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
18  * USA
19  */
20 #include "test.h"
21
22 void test_url(void) {
23   struct url p;
24   
25   printf("test_url\n");
26
27   insist(parse_url("http://www.example.com/example/path", &p) == 0);
28   check_string(p.scheme, "http");
29   check_string(p.host, "www.example.com");
30   insist(p.port == -1);
31   check_string(p.path, "/example/path");
32   insist(p.query == 0);
33
34   insist(parse_url("https://www.example.com:82/example%2fpath?+query+", &p) == 0);
35   check_string(p.scheme, "https");
36   check_string(p.host, "www.example.com");
37   insist(p.port == 82);
38   check_string(p.path, "/example/path");
39   check_string(p.query, "+query+");
40
41   insist(parse_url("//www.example.com/example/path", &p) == 0);
42   insist(p.scheme == 0);
43   check_string(p.host, "www.example.com");
44   insist(p.port == -1);
45   check_string(p.path, "/example/path");
46   insist(p.query == 0);
47
48   insist(parse_url("http://www.example.com:100000/", &p) == -1);
49   insist(parse_url("http://www.example.com:1000000000000/", &p) == -1);
50   insist(parse_url("http://www.example.com/example%2zpath", &p) == -1);
51 }
52
53 /*
54 Local Variables:
55 c-basic-offset:2
56 comment-column:40
57 fill-column:79
58 indent-tabs-mode:nil
59 End:
60 */