]>
Commit | Line | Data |
---|---|---|
1 | #include <apt-pkg/strutl.h> | |
2 | ||
3 | #include "assert.h" | |
4 | ||
5 | int main() { | |
6 | // Basic stuff | |
7 | { | |
8 | URI U("http://www.debian.org:90/temp/test"); | |
9 | equals("http", U.Access); | |
10 | equals("", U.User); | |
11 | equals("", U.Password); | |
12 | equals(90, U.Port); | |
13 | equals("www.debian.org", U.Host); | |
14 | equals("/temp/test", U.Path); | |
15 | } { | |
16 | URI U("http://jgg:foo@ualberta.ca/blah"); | |
17 | equals("http", U.Access); | |
18 | equals("jgg", U.User); | |
19 | equals("foo", U.Password); | |
20 | equals(0, U.Port); | |
21 | equals("ualberta.ca", U.Host); | |
22 | equals("/blah", U.Path); | |
23 | } { | |
24 | URI U("file:/usr/bin/foo"); | |
25 | equals("file", U.Access); | |
26 | equals("", U.User); | |
27 | equals("", U.Password); | |
28 | equals(0, U.Port); | |
29 | equals("", U.Host); | |
30 | equals("/usr/bin/foo", U.Path); | |
31 | } { | |
32 | URI U("cdrom:Moo Cow Rom:/debian"); | |
33 | equals("cdrom", U.Access); | |
34 | equals("", U.User); | |
35 | equals("", U.Password); | |
36 | equals(0, U.Port); | |
37 | equals("Moo Cow Rom", U.Host); | |
38 | equals("/debian", U.Path); | |
39 | } { | |
40 | URI U("gzip:./bar/cow"); | |
41 | equals("gzip", U.Access); | |
42 | equals("", U.User); | |
43 | equals("", U.Password); | |
44 | equals(0, U.Port); | |
45 | equals(".", U.Host); | |
46 | equals("/bar/cow", U.Path); | |
47 | } { | |
48 | URI U("ftp:ftp.fr.debian.org/debian/pool/main/x/xtel/xtel_3.2.1-15_i386.deb"); | |
49 | equals("ftp", U.Access); | |
50 | equals("", U.User); | |
51 | equals("", U.Password); | |
52 | equals(0, U.Port); | |
53 | equals("ftp.fr.debian.org", U.Host); | |
54 | equals("/debian/pool/main/x/xtel/xtel_3.2.1-15_i386.deb", U.Path); | |
55 | } | |
56 | ||
57 | // RFC 2732 stuff | |
58 | { | |
59 | URI U("http://[1080::8:800:200C:417A]/foo"); | |
60 | equals("http", U.Access); | |
61 | equals("", U.User); | |
62 | equals("", U.Password); | |
63 | equals(0, U.Port); | |
64 | equals("1080::8:800:200C:417A", U.Host); | |
65 | equals("/foo", U.Path); | |
66 | } { | |
67 | URI U("http://[::FFFF:129.144.52.38]:80/index.html"); | |
68 | equals("http", U.Access); | |
69 | equals("", U.User); | |
70 | equals("", U.Password); | |
71 | equals(80, U.Port); | |
72 | equals("::FFFF:129.144.52.38", U.Host); | |
73 | equals("/index.html", U.Path); | |
74 | } { | |
75 | URI U("http://[::FFFF:129.144.52.38:]:80/index.html"); | |
76 | equals("http", U.Access); | |
77 | equals("", U.User); | |
78 | equals("", U.Password); | |
79 | equals(80, U.Port); | |
80 | equals("::FFFF:129.144.52.38:", U.Host); | |
81 | equals("/index.html", U.Path); | |
82 | } { | |
83 | URI U("http://[::FFFF:129.144.52.38:]/index.html"); | |
84 | equals("http", U.Access); | |
85 | equals("", U.User); | |
86 | equals("", U.Password); | |
87 | equals(0, U.Port); | |
88 | equals("::FFFF:129.144.52.38:", U.Host); | |
89 | equals("/index.html", U.Path); | |
90 | } | |
91 | /* My Evil Corruption of RFC 2732 to handle CDROM names! Fun for | |
92 | the whole family! */ | |
93 | { | |
94 | URI U("cdrom:[The Debian 1.2 disk, 1/2 R1:6]/debian/"); | |
95 | equals("cdrom", U.Access); | |
96 | equals("", U.User); | |
97 | equals("", U.Password); | |
98 | equals(0, U.Port); | |
99 | equals("The Debian 1.2 disk, 1/2 R1:6", U.Host); | |
100 | equals("/debian/", U.Path); | |
101 | } { | |
102 | URI U("cdrom:Foo Bar Cow/debian/"); | |
103 | equals("cdrom", U.Access); | |
104 | equals("", U.User); | |
105 | equals("", U.Password); | |
106 | equals(0, U.Port); | |
107 | equals("Foo Bar Cow", U.Host); | |
108 | equals("/debian/", U.Path); | |
109 | } | |
110 | ||
111 | // Percent-encoding. | |
112 | { | |
113 | URI U("ftp://foo:b%40r@example.org"); | |
114 | equals("foo", U.User); | |
115 | equals("b@r", U.Password); | |
116 | equals("ftp://foo:b%40r@example.org/", (std::string) U); | |
117 | } | |
118 | ||
119 | return 0; | |
120 | } |