Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
uri.cpp File Reference
#include <boost/test/unit_test.hpp>
#include <iostream>
#include <string>
#include <websocketpp/uri.hpp>
Include dependency graph for uri.cpp:

Go to the source code of this file.

Macros

#define BOOST_TEST_MODULE   uri
 

Functions

 BOOST_AUTO_TEST_CASE (uri_valid)
 
 BOOST_AUTO_TEST_CASE (uri_valid_no_port_unsecure)
 
 BOOST_AUTO_TEST_CASE (uri_valid_no_port_secure)
 
 BOOST_AUTO_TEST_CASE (uri_valid_no_resource)
 
 BOOST_AUTO_TEST_CASE (uri_valid_ipv6_literal)
 
 BOOST_AUTO_TEST_CASE (uri_valid_2)
 
 BOOST_AUTO_TEST_CASE (uri_invalid_long_port)
 
 BOOST_AUTO_TEST_CASE (uri_invalid_scheme)
 
 BOOST_AUTO_TEST_CASE (uri_http_scheme)
 
 BOOST_AUTO_TEST_CASE (uri_valid_ipv4_literal)
 
 BOOST_AUTO_TEST_CASE (uri_valid_3)
 
 BOOST_AUTO_TEST_CASE (uri_invalid_method_separator)
 
 BOOST_AUTO_TEST_CASE (uri_invalid_gt_16_bit_port)
 
 BOOST_AUTO_TEST_CASE (uri_invalid_fragment)
 
 BOOST_AUTO_TEST_CASE (uri_invalid_bad_v6_literal_1)
 
 BOOST_AUTO_TEST_CASE (uri_invalid_bad_v6_literal_2)
 
 BOOST_AUTO_TEST_CASE (uri_valid_4)
 
 BOOST_AUTO_TEST_CASE (uri_valid_v4_mapped)
 
 BOOST_AUTO_TEST_CASE (uri_valid_v6_mixed_case)
 
 BOOST_AUTO_TEST_CASE (uri_invalid_no_scheme)
 

Macro Definition Documentation

◆ BOOST_TEST_MODULE

#define BOOST_TEST_MODULE   uri

Definition at line 28 of file uri.cpp.

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/20]

BOOST_AUTO_TEST_CASE ( uri_http_scheme )

Definition at line 125 of file uri.cpp.

125 {
126 websocketpp::uri uri("http://localhost:9000/chat");
127
128 BOOST_CHECK( uri.get_valid() );
129 BOOST_CHECK( !uri.get_secure() );
130 BOOST_CHECK_EQUAL( uri.get_scheme(), "http");
131 BOOST_CHECK_EQUAL( uri.get_host(), "localhost");
132 BOOST_CHECK_EQUAL( uri.get_port(), 9000 );
133 BOOST_CHECK_EQUAL( uri.get_resource(), "/chat" );
134}
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [2/20]

BOOST_AUTO_TEST_CASE ( uri_invalid_bad_v6_literal_1 )

Definition at line 182 of file uri.cpp.

182 {
183 websocketpp::uri uri("wss://::1/chat");
184
185 BOOST_CHECK( !uri.get_valid() );
186}
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [3/20]

BOOST_AUTO_TEST_CASE ( uri_invalid_bad_v6_literal_2 )

Definition at line 189 of file uri.cpp.

189 {
190 websocketpp::uri uri("wss://::1:2009/chat");
191
192 BOOST_CHECK( !uri.get_valid() );
193}
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [4/20]

BOOST_AUTO_TEST_CASE ( uri_invalid_fragment )

Definition at line 175 of file uri.cpp.

175 {
176 websocketpp::uri uri("wss:/localhost:70000/chat#foo");
177
178 BOOST_CHECK( !uri.get_valid() );
179}
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [5/20]

BOOST_AUTO_TEST_CASE ( uri_invalid_gt_16_bit_port )

Definition at line 168 of file uri.cpp.

168 {
169 websocketpp::uri uri("wss:/localhost:70000/chat");
170
171 BOOST_CHECK( !uri.get_valid() );
172}
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [6/20]

BOOST_AUTO_TEST_CASE ( uri_invalid_long_port )

Definition at line 111 of file uri.cpp.

111 {
112 websocketpp::uri uri("wss://localhost:900000/chat");
113
114 BOOST_CHECK( !uri.get_valid() );
115}
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [7/20]

BOOST_AUTO_TEST_CASE ( uri_invalid_method_separator )

Definition at line 161 of file uri.cpp.

161 {
162 websocketpp::uri uri("wss:/localhost:9000/chat");
163
164 BOOST_CHECK( !uri.get_valid() );
165}
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [8/20]

BOOST_AUTO_TEST_CASE ( uri_invalid_no_scheme )

Definition at line 233 of file uri.cpp.

233 {
234 websocketpp::uri uri("myserver.com");
235
236 BOOST_CHECK( !uri.get_valid() );
237}
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [9/20]

BOOST_AUTO_TEST_CASE ( uri_invalid_scheme )

Definition at line 118 of file uri.cpp.

118 {
119 websocketpp::uri uri("foo://localhost:9000/chat");
120
121 BOOST_CHECK( !uri.get_valid() );
122}
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [10/20]

BOOST_AUTO_TEST_CASE ( uri_valid )

Definition at line 37 of file uri.cpp.

37 {
38 websocketpp::uri uri("ws://localhost:9000/chat");
39
40 BOOST_CHECK( uri.get_valid() );
41 BOOST_CHECK( !uri.get_secure() );
42 BOOST_CHECK_EQUAL( uri.get_scheme(), "ws");
43 BOOST_CHECK_EQUAL( uri.get_host(), "localhost");
44 BOOST_CHECK_EQUAL( uri.get_port(), 9000 );
45 BOOST_CHECK_EQUAL( uri.get_resource(), "/chat" );
46 BOOST_CHECK_EQUAL( uri.get_query(), "" );
47}
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [11/20]

BOOST_AUTO_TEST_CASE ( uri_valid_2 )

Definition at line 98 of file uri.cpp.

98 {
99 websocketpp::uri uri("wss://thor-websocket.zaphoyd.net:88/");
100
101 BOOST_CHECK( uri.get_valid() );
102 BOOST_CHECK( uri.get_secure() );
103 BOOST_CHECK_EQUAL( uri.get_scheme(), "wss");
104 BOOST_CHECK_EQUAL( uri.get_host(), "thor-websocket.zaphoyd.net");
105 BOOST_CHECK_EQUAL( uri.get_port(), 88 );
106 BOOST_CHECK_EQUAL( uri.get_resource(), "/" );
107}
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [12/20]

BOOST_AUTO_TEST_CASE ( uri_valid_3 )

Definition at line 149 of file uri.cpp.

149 {
150 websocketpp::uri uri("wss://localhost:9000/chat/foo/bar");
151
152 BOOST_CHECK( uri.get_valid() );
153 BOOST_CHECK( uri.get_secure() );
154 BOOST_CHECK_EQUAL( uri.get_scheme(), "wss");
155 BOOST_CHECK_EQUAL( uri.get_host(), "localhost");
156 BOOST_CHECK_EQUAL( uri.get_port(), 9000 );
157 BOOST_CHECK_EQUAL( uri.get_resource(), "/chat/foo/bar" );
158}
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [13/20]

BOOST_AUTO_TEST_CASE ( uri_valid_4 )

Definition at line 196 of file uri.cpp.

196 {
197 websocketpp::uri uri("wss://localhost:9000/chat/foo/bar?foo=bar");
198
199 BOOST_CHECK( uri.get_valid() );
200 BOOST_CHECK( uri.get_secure() );
201 BOOST_CHECK_EQUAL( uri.get_scheme(), "wss" );
202 BOOST_CHECK_EQUAL( uri.get_host(), "localhost");
203 BOOST_CHECK_EQUAL( uri.get_port(), 9000 );
204 BOOST_CHECK_EQUAL( uri.get_resource(), "/chat/foo/bar?foo=bar" );
205 BOOST_CHECK_EQUAL( uri.get_query(), "foo=bar" );
206}
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [14/20]

BOOST_AUTO_TEST_CASE ( uri_valid_ipv4_literal )

Definition at line 137 of file uri.cpp.

137 {
138 websocketpp::uri uri("wss://127.0.0.1:9000/chat");
139
140 BOOST_CHECK( uri.get_valid() );
141 BOOST_CHECK( uri.get_secure() );
142 BOOST_CHECK_EQUAL( uri.get_scheme(), "wss");
143 BOOST_CHECK_EQUAL( uri.get_host(), "127.0.0.1");
144 BOOST_CHECK_EQUAL( uri.get_port(), 9000 );
145 BOOST_CHECK_EQUAL( uri.get_resource(), "/chat" );
146}
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [15/20]

BOOST_AUTO_TEST_CASE ( uri_valid_ipv6_literal )

Definition at line 86 of file uri.cpp.

86 {
87 websocketpp::uri uri("wss://[::1]:9000/chat");
88
89 BOOST_CHECK( uri.get_valid() );
90 BOOST_CHECK( uri.get_secure() );
91 BOOST_CHECK_EQUAL( uri.get_scheme(), "wss");
92 BOOST_CHECK_EQUAL( uri.get_host(), "::1");
93 BOOST_CHECK_EQUAL( uri.get_port(), 9000 );
94 BOOST_CHECK_EQUAL( uri.get_resource(), "/chat" );
95}
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [16/20]

BOOST_AUTO_TEST_CASE ( uri_valid_no_port_secure )

Definition at line 62 of file uri.cpp.

62 {
63 websocketpp::uri uri("wss://localhost/chat");
64
65 BOOST_CHECK( uri.get_valid() );
66 BOOST_CHECK( uri.get_secure() );
67 BOOST_CHECK_EQUAL( uri.get_scheme(), "wss");
68 BOOST_CHECK_EQUAL( uri.get_host(), "localhost");
69 BOOST_CHECK_EQUAL( uri.get_port(), 443 );
70 BOOST_CHECK_EQUAL( uri.get_resource(), "/chat" );
71}
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [17/20]

BOOST_AUTO_TEST_CASE ( uri_valid_no_port_unsecure )

Definition at line 50 of file uri.cpp.

50 {
51 websocketpp::uri uri("ws://localhost/chat");
52
53 BOOST_CHECK( uri.get_valid() );
54 BOOST_CHECK( !uri.get_secure() );
55 BOOST_CHECK_EQUAL( uri.get_scheme(), "ws");
56 BOOST_CHECK_EQUAL( uri.get_host(), "localhost");
57 BOOST_CHECK_EQUAL( uri.get_port(), 80 );
58 BOOST_CHECK_EQUAL( uri.get_resource(), "/chat" );
59}
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [18/20]

BOOST_AUTO_TEST_CASE ( uri_valid_no_resource )

Definition at line 74 of file uri.cpp.

74 {
75 websocketpp::uri uri("wss://localhost:9000");
76
77 BOOST_CHECK( uri.get_valid() );
78 BOOST_CHECK( uri.get_secure() );
79 BOOST_CHECK_EQUAL( uri.get_scheme(), "wss");
80 BOOST_CHECK_EQUAL( uri.get_host(), "localhost");
81 BOOST_CHECK_EQUAL( uri.get_port(), 9000 );
82 BOOST_CHECK_EQUAL( uri.get_resource(), "/" );
83}
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [19/20]

BOOST_AUTO_TEST_CASE ( uri_valid_v4_mapped )

Definition at line 209 of file uri.cpp.

209 {
210 websocketpp::uri uri("wss://[0000:0000:0000:0000:0000:0000:192.168.1.1]:9000/");
211
212 BOOST_CHECK( uri.get_valid() );
213 BOOST_CHECK( uri.get_secure() );
214 BOOST_CHECK_EQUAL( uri.get_scheme(), "wss" );
215 BOOST_CHECK_EQUAL( uri.get_host(), "0000:0000:0000:0000:0000:0000:192.168.1.1");
216 BOOST_CHECK_EQUAL( uri.get_port(), 9000 );
217 BOOST_CHECK_EQUAL( uri.get_resource(), "/" );
218}
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [20/20]

BOOST_AUTO_TEST_CASE ( uri_valid_v6_mixed_case )

Definition at line 221 of file uri.cpp.

221 {
222 websocketpp::uri uri("wss://[::10aB]:9000/");
223
224 BOOST_CHECK( uri.get_valid() == true );
225 BOOST_CHECK( uri.get_secure() == true );
226 BOOST_CHECK_EQUAL( uri.get_scheme(), "wss" );
227 BOOST_CHECK_EQUAL( uri.get_host(), "::10aB");
228 BOOST_CHECK_EQUAL( uri.get_port(), 9000 );
229 BOOST_CHECK_EQUAL( uri.get_resource(), "/" );
230}
Here is the call graph for this function: