Skip to content

Commit 1f07337

Browse files
committed
Refactored unit tests in order to prepare for the new URI interface.
1 parent 8a05166 commit 1f07337

File tree

2 files changed

+65
-65
lines changed

2 files changed

+65
-65
lines changed

libs/network/test/uri/url_builder_test.cpp

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#define BOOST_TEST_MODULE URI builder test
77
#include <boost/config/warning_disable.hpp>
88
#include <boost/test/unit_test.hpp>
9+
#include <boost/network/uri.hpp>
910
#include <boost/network/uri/uri.hpp>
1011
#include <boost/network/uri/directives.hpp>
1112
#include <boost/network/uri/accessors.hpp>
@@ -19,14 +20,14 @@
1920
using namespace boost::network;
2021

2122
typedef boost::mpl::list<
22-
tags::default_string
23-
, tags::default_wstring
24-
> tag_types;
23+
uri::uri
24+
, uri::wuri
25+
> uri_types;
2526

2627

27-
BOOST_AUTO_TEST_CASE_TEMPLATE(builder_test, T, tag_types)
28+
BOOST_AUTO_TEST_CASE_TEMPLATE(builder_test, T, uri_types)
2829
{
29-
typedef uri::basic_uri<T> uri_type;
30+
typedef T uri_type;
3031
typedef typename uri_type::string_type string_type;
3132

3233
const std::string scheme("http");
@@ -45,9 +46,9 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(builder_test, T, tag_types)
4546
BOOST_CHECK(boost::equal(uri::path(instance), path));
4647
}
4748

48-
BOOST_AUTO_TEST_CASE_TEMPLATE(full_uri_builder_test, T, tag_types)
49+
BOOST_AUTO_TEST_CASE_TEMPLATE(full_uri_builder_test, T, uri_types)
4950
{
50-
typedef uri::basic_uri<T> uri_type;
51+
typedef T uri_type;
5152
typedef typename uri_type::string_type string_type;
5253

5354
const std::string scheme("http");
@@ -78,9 +79,9 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(full_uri_builder_test, T, tag_types)
7879
BOOST_CHECK(boost::equal(uri::fragment(instance), fragment));
7980
}
8081

81-
BOOST_AUTO_TEST_CASE_TEMPLATE(port_test, T, tag_types)
82+
BOOST_AUTO_TEST_CASE_TEMPLATE(port_test, T, uri_types)
8283
{
83-
typedef uri::basic_uri<T> uri_type;
84+
typedef T uri_type;
8485
typedef typename uri_type::string_type string_type;
8586

8687
const std::string scheme("http");
@@ -102,9 +103,9 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(port_test, T, tag_types)
102103
BOOST_CHECK(boost::equal(uri::path(instance), path));
103104
}
104105

105-
BOOST_AUTO_TEST_CASE_TEMPLATE(encoded_path_test, T, tag_types)
106+
BOOST_AUTO_TEST_CASE_TEMPLATE(encoded_path_test, T, uri_types)
106107
{
107-
typedef uri::basic_uri<T> uri_type;
108+
typedef T uri_type;
108109
typedef typename uri_type::string_type string_type;
109110

110111
const std::string scheme("http");
@@ -128,9 +129,9 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(encoded_path_test, T, tag_types)
128129
BOOST_CHECK(boost::equal(uri::decoded_path(instance), decoded_path));
129130
}
130131

131-
BOOST_AUTO_TEST_CASE_TEMPLATE(query_test, T, tag_types)
132+
BOOST_AUTO_TEST_CASE_TEMPLATE(query_test, T, uri_types)
132133
{
133-
typedef uri::basic_uri<T> uri_type;
134+
typedef T uri_type;
134135
typedef typename uri_type::string_type string_type;
135136

136137
const std::string scheme("http");
@@ -154,9 +155,9 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(query_test, T, tag_types)
154155
BOOST_CHECK(boost::equal(uri::query(instance), query));
155156
}
156157

157-
BOOST_AUTO_TEST_CASE_TEMPLATE(query_2_test, T, tag_types)
158+
BOOST_AUTO_TEST_CASE_TEMPLATE(query_2_test, T, uri_types)
158159
{
159-
typedef uri::basic_uri<T> uri_type;
160+
typedef T uri_type;
160161
typedef typename uri_type::string_type string_type;
161162

162163
const std::string scheme("http");
@@ -182,9 +183,9 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(query_2_test, T, tag_types)
182183
BOOST_CHECK(boost::equal(uri::query(instance), query));
183184
}
184185

185-
BOOST_AUTO_TEST_CASE_TEMPLATE(fragment_test, T, tag_types)
186+
BOOST_AUTO_TEST_CASE_TEMPLATE(fragment_test, T, uri_types)
186187
{
187-
typedef uri::basic_uri<T> uri_type;
188+
typedef T uri_type;
188189
typedef typename uri_type::string_type string_type;
189190

190191
const std::string scheme("http");
@@ -205,9 +206,9 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(fragment_test, T, tag_types)
205206
BOOST_CHECK(boost::equal(uri::fragment(instance), fragment));
206207
}
207208

208-
BOOST_AUTO_TEST_CASE_TEMPLATE(from_root_test, T, tag_types)
209+
BOOST_AUTO_TEST_CASE_TEMPLATE(from_root_test, T, uri_types)
209210
{
210-
typedef uri::basic_uri<T> uri_type;
211+
typedef T uri_type;
211212
typedef typename uri_type::string_type string_type;
212213

213214
const std::string root("http://www.example.com");
@@ -229,9 +230,9 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(from_root_test, T, tag_types)
229230
BOOST_CHECK(boost::equal(uri::fragment(instance), fragment));
230231
}
231232

232-
//BOOST_AUTO_TEST_CASE_TEMPLATE(scheme_test, T, tag_types)
233+
//BOOST_AUTO_TEST_CASE_TEMPLATE(scheme_test, T, uri_types)
233234
//{
234-
// typedef uri::basic_uri<T> uri_type;
235+
// typedef T uri_type;
235236
// typedef typename uri_type::string_type string_type;
236237
//
237238
// const std::string scheme("http");
@@ -252,7 +253,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(from_root_test, T, tag_types)
252253

253254
BOOST_AUTO_TEST_CASE(encoded_null_char_test)
254255
{
255-
typedef uri::basic_uri<tags::default_string> uri_type;
256+
typedef uri::uri uri_type;
256257
typedef uri_type::string_type string_type;
257258

258259
const std::string scheme("http");

libs/network/test/uri/url_test.cpp

Lines changed: 42 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
#define BOOST_TEST_MODULE URL Test
77
#include <boost/config/warning_disable.hpp>
88
#include <boost/test/unit_test.hpp>
9+
#include <boost/network/uri.hpp>
910
#include <boost/network/uri/uri.hpp>
1011
#include <boost/network/uri/accessors.hpp>
11-
#include <boost/network/tags.hpp>
1212
#include <boost/mpl/list.hpp>
1313
#include <boost/range/algorithm/equal.hpp>
1414
#include <boost/range/algorithm/copy.hpp>
@@ -18,15 +18,14 @@
1818

1919
using namespace boost::network;
2020

21-
2221
typedef boost::mpl::list<
23-
tags::default_string
24-
, tags::default_wstring
25-
> tag_types;
22+
uri::uri
23+
, uri::wuri
24+
> uri_types;
2625

2726

28-
BOOST_AUTO_TEST_CASE_TEMPLATE(uri_test, T, tag_types) {
29-
typedef uri::basic_uri<T> uri_type;
27+
BOOST_AUTO_TEST_CASE_TEMPLATE(uri_test, T, uri_types) {
28+
typedef T uri_type;
3029
typedef typename uri_type::string_type string_type;
3130

3231
const std::string url("http://www.example.com/");
@@ -41,8 +40,8 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(uri_test, T, tag_types) {
4140
BOOST_CHECK(boost::equal(uri::path(instance), path));
4241
}
4342

44-
BOOST_AUTO_TEST_CASE_TEMPLATE(full_uri_test, T, tag_types) {
45-
typedef uri::basic_uri<T> uri_type;
43+
BOOST_AUTO_TEST_CASE_TEMPLATE(full_uri_test, T, uri_types) {
44+
typedef T uri_type;
4645
typedef typename uri_type::string_type string_type;
4746

4847
const std::string url("http://user:password@www.example.com:80/path?query#fragment");
@@ -66,8 +65,8 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(full_uri_test, T, tag_types) {
6665
BOOST_CHECK(boost::equal(uri::fragment(instance), fragment));
6766
}
6867

69-
BOOST_AUTO_TEST_CASE_TEMPLATE(mailto_test, T, tag_types) {
70-
typedef uri::basic_uri<T> uri_type;
68+
BOOST_AUTO_TEST_CASE_TEMPLATE(mailto_test, T, uri_types) {
69+
typedef T uri_type;
7170
typedef typename uri_type::string_type string_type;
7271

7372
const std::string url("mailto:john.doe@example.com");
@@ -81,8 +80,8 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(mailto_test, T, tag_types) {
8180
BOOST_CHECK(boost::equal(uri::path(instance), path));
8281
}
8382

84-
BOOST_AUTO_TEST_CASE_TEMPLATE(file_test, T, tag_types) {
85-
typedef uri::basic_uri<T> uri_type;
83+
BOOST_AUTO_TEST_CASE_TEMPLATE(file_test, T, uri_types) {
84+
typedef T uri_type;
8685
typedef typename uri_type::string_type string_type;
8786

8887
const std::string url("file:///bin/bash");
@@ -95,8 +94,8 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(file_test, T, tag_types) {
9594
BOOST_CHECK(boost::equal(uri::path(instance), path));
9695
}
9796

98-
BOOST_AUTO_TEST_CASE_TEMPLATE(xmpp_test, T, tag_types) {
99-
typedef uri::basic_uri<T> uri_type;
97+
BOOST_AUTO_TEST_CASE_TEMPLATE(xmpp_test, T, uri_types) {
98+
typedef T uri_type;
10099
typedef typename uri_type::string_type string_type;
101100

102101
const std::string url("xmpp:example-node@example.com?message;subject=Hello%20World");
@@ -112,8 +111,8 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(xmpp_test, T, tag_types) {
112111
BOOST_CHECK(boost::equal(uri::query(instance), query));
113112
}
114113

115-
BOOST_AUTO_TEST_CASE_TEMPLATE(ipv4_address_test, T, tag_types) {
116-
typedef uri::basic_uri<T> uri_type;
114+
BOOST_AUTO_TEST_CASE_TEMPLATE(ipv4_address_test, T, uri_types) {
115+
typedef T uri_type;
117116
typedef typename uri_type::string_type string_type;
118117

119118
const std::string url("http://129.79.245.252/");
@@ -128,8 +127,8 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(ipv4_address_test, T, tag_types) {
128127
BOOST_CHECK(boost::equal(uri::path(instance), path));
129128
}
130129

131-
BOOST_AUTO_TEST_CASE_TEMPLATE(ipv6_address_test_1, T, tag_types) {
132-
typedef uri::basic_uri<T> uri_type;
130+
BOOST_AUTO_TEST_CASE_TEMPLATE(ipv6_address_test_1, T, uri_types) {
131+
typedef T uri_type;
133132
typedef typename uri_type::string_type string_type;
134133

135134
const std::string url("http://[1080:0:0:0:8:800:200C:417A]/");
@@ -144,8 +143,8 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(ipv6_address_test_1, T, tag_types) {
144143
BOOST_CHECK(boost::equal(uri::path(instance), path));
145144
}
146145

147-
BOOST_AUTO_TEST_CASE_TEMPLATE(ipv6_address_test_2, T, tag_types) {
148-
typedef uri::basic_uri<T> uri_type;
146+
BOOST_AUTO_TEST_CASE_TEMPLATE(ipv6_address_test_2, T, uri_types) {
147+
typedef T uri_type;
149148
typedef typename uri_type::string_type string_type;
150149

151150
const std::string url("http://[2001:db8:85a3:8d3:1319:8a2e:370:7348]/");
@@ -160,8 +159,8 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(ipv6_address_test_2, T, tag_types) {
160159
BOOST_CHECK(boost::equal(uri::path(instance), path));
161160
}
162161

163-
BOOST_AUTO_TEST_CASE_TEMPLATE(ftp_test, T, tag_types) {
164-
typedef uri::basic_uri<T> uri_type;
162+
BOOST_AUTO_TEST_CASE_TEMPLATE(ftp_test, T, uri_types) {
163+
typedef T uri_type;
165164
typedef typename uri_type::string_type string_type;
166165

167166
const std::string url("ftp://john.doe@ftp.example.com/");
@@ -178,8 +177,8 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(ftp_test, T, tag_types) {
178177
BOOST_CHECK(boost::equal(uri::path(instance), path));
179178
}
180179

181-
BOOST_AUTO_TEST_CASE_TEMPLATE(news_test, T, tag_types) {
182-
typedef uri::basic_uri<T> uri_type;
180+
BOOST_AUTO_TEST_CASE_TEMPLATE(news_test, T, uri_types) {
181+
typedef T uri_type;
183182
typedef typename uri_type::string_type string_type;
184183

185184
const std::string url("news:comp.infosystems.www.servers.unix");
@@ -192,8 +191,8 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(news_test, T, tag_types) {
192191
BOOST_CHECK(boost::equal(uri::path(instance), path));
193192
}
194193

195-
BOOST_AUTO_TEST_CASE_TEMPLATE(tel_test, T, tag_types) {
196-
typedef uri::basic_uri<T> uri_type;
194+
BOOST_AUTO_TEST_CASE_TEMPLATE(tel_test, T, uri_types) {
195+
typedef T uri_type;
197196
typedef typename uri_type::string_type string_type;
198197

199198
const std::string url("tel:+1-816-555-1212");
@@ -206,8 +205,8 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(tel_test, T, tag_types) {
206205
BOOST_CHECK(boost::equal(uri::path(instance), path));
207206
}
208207

209-
BOOST_AUTO_TEST_CASE_TEMPLATE(encoded_uri_test, T, tag_types) {
210-
typedef uri::basic_uri<T> uri_type;
208+
BOOST_AUTO_TEST_CASE_TEMPLATE(encoded_uri_test, T, uri_types) {
209+
typedef T uri_type;
211210
typedef typename uri_type::string_type string_type;
212211

213212
const std::string url("http://www.example.com/Path%20With%20%28Some%29%20Encoded%20Characters%21");
@@ -224,8 +223,8 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(encoded_uri_test, T, tag_types) {
224223
BOOST_CHECK(boost::equal(uri::decoded_path(instance), decoded_path));
225224
}
226225

227-
BOOST_AUTO_TEST_CASE_TEMPLATE(copy_constructor_test, T, tag_types) {
228-
typedef uri::basic_uri<T> uri_type;
226+
BOOST_AUTO_TEST_CASE_TEMPLATE(copy_constructor_test, T, uri_types) {
227+
typedef T uri_type;
229228
typedef typename uri_type::string_type string_type;
230229

231230
const std::string url("http://www.example.com/");
@@ -235,8 +234,8 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(copy_constructor_test, T, tag_types) {
235234
BOOST_CHECK(instance == copy);
236235
}
237236

238-
BOOST_AUTO_TEST_CASE_TEMPLATE(assignment_test, T, tag_types) {
239-
typedef uri::basic_uri<T> uri_type;
237+
BOOST_AUTO_TEST_CASE_TEMPLATE(assignment_test, T, uri_types) {
238+
typedef T uri_type;
240239
typedef typename uri_type::string_type string_type;
241240

242241
const std::string url("http://www.example.com/");
@@ -248,8 +247,8 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(assignment_test, T, tag_types) {
248247
BOOST_CHECK(instance == copy);
249248
}
250249

251-
BOOST_AUTO_TEST_CASE_TEMPLATE(username_test, T, tag_types) {
252-
typedef uri::basic_uri<T> uri_type;
250+
BOOST_AUTO_TEST_CASE_TEMPLATE(username_test, T, uri_types) {
251+
typedef T uri_type;
253252
typedef typename uri_type::string_type string_type;
254253

255254
const std::string url("ftp://john.doe:password@ftp.example.com/");
@@ -263,8 +262,8 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(username_test, T, tag_types) {
263262
BOOST_CHECK(boost::equal(uri::password(instance), password));
264263
}
265264

266-
BOOST_AUTO_TEST_CASE_TEMPLATE(authority_test, T, tag_types) {
267-
typedef uri::basic_uri<T> uri_type;
265+
BOOST_AUTO_TEST_CASE_TEMPLATE(authority_test, T, uri_types) {
266+
typedef T uri_type;
268267
typedef typename uri_type::string_type string_type;
269268

270269
const std::string url("http://user:password@www.example.com:80/path?query#fragment");
@@ -275,8 +274,8 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(authority_test, T, tag_types) {
275274
BOOST_CHECK(boost::equal(uri::authority(instance), authority));
276275
}
277276

278-
BOOST_AUTO_TEST_CASE_TEMPLATE(http_query_map_test, T, tag_types) {
279-
typedef uri::basic_uri<T> uri_type;
277+
BOOST_AUTO_TEST_CASE_TEMPLATE(http_query_map_test, T, uri_types) {
278+
typedef T uri_type;
280279
typedef typename uri_type::string_type string_type;
281280

282281
const std::string url("http://user:password@www.example.com:80/path?query#fragment");
@@ -293,8 +292,8 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(http_query_map_test, T, tag_types) {
293292
BOOST_CHECK(boost::equal(queries.begin()->second, value));
294293
}
295294

296-
BOOST_AUTO_TEST_CASE_TEMPLATE(xmpp_query_map_test, T, tag_types) {
297-
typedef uri::basic_uri<T> uri_type;
295+
BOOST_AUTO_TEST_CASE_TEMPLATE(xmpp_query_map_test, T, uri_types) {
296+
typedef T uri_type;
298297
typedef typename uri_type::string_type string_type;
299298

300299
const std::string url("xmpp:example-node@example.com?message;subject=Hello%20World");
@@ -313,9 +312,9 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(xmpp_query_map_test, T, tag_types) {
313312
BOOST_CHECK(boost::equal((++queries.begin())->second, value_2));
314313
}
315314

316-
BOOST_AUTO_TEST_CASE_TEMPLATE(range_test, T, tag_types)
315+
BOOST_AUTO_TEST_CASE_TEMPLATE(range_test, T, uri_types)
317316
{
318-
typedef uri::basic_uri<T> uri_type;
317+
typedef T uri_type;
319318
typedef typename uri_type::string_type string_type;
320319

321320
const std::string url("http://www.example.com/");

0 commit comments

Comments
 (0)