Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3458473

Browse files
committed
Cleaned up the URI tests a little further.
1 parentbd77b44 commit3458473

File tree

11 files changed

+125
-96
lines changed

11 files changed

+125
-96
lines changed

‎boost/network/uri/directives/authority.hpp‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@ struct authority_directive {
1111
: authority(authority)
1212
{}
1313

14-
voidoperator () (uri &uri_)const {
15-
uri_.append(authority);
14+
template<
15+
classUri
16+
>
17+
voidoperator () (Uri &uri)const {
18+
uri.append(authority);
1619
}
1720

1821
std::string authority;

‎boost/network/uri/directives/fragment.hpp‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ struct fragment_directive {
1616
: fragment(fragment)
1717
{}
1818

19-
voidoperator () (uri &uri_)const {
20-
std::string encoded_fragment;
21-
staticconstchar separator[] = {'#'};
22-
uri_.append(boost::begin(separator),boost::end(separator));
23-
encode(fragment,std::back_inserter(encoded_fragment));
24-
uri_.append(encoded_fragment);
19+
template<
20+
classUri
21+
>
22+
voidoperator () (Uri &uri)const {
23+
uri.append("#");
24+
uri.append(fragment);
2525
}
2626

2727
std::string fragment;

‎boost/network/uri/directives/host.hpp‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@ struct host_directive {
1515
: host(host)
1616
{}
1717

18-
voidoperator () (uri &uri_)const {
19-
uri_.append(host);
18+
template<
19+
classUri
20+
>
21+
voidoperator () (Uri &uri)const {
22+
uri.append(host);
2023
}
2124

2225
std::string host;

‎boost/network/uri/directives/path.hpp‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@ struct path_directive {
1515
: path(path)
1616
{}
1717

18-
voidoperator () (uri &uri_)const {
19-
uri_.append(path);
18+
template<
19+
classUri
20+
>
21+
voidoperator () (Uri &uri)const {
22+
uri.append(path);
2023
}
2124

2225
std::string path;

‎boost/network/uri/directives/port.hpp‎

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,31 +17,19 @@ struct port_directive {
1717
: port(port)
1818
{}
1919

20-
voidoperator () (uri &uri_)const {
21-
staticconstchar separator[] = {':'};
22-
uri_.append(boost::begin(separator),boost::end(separator));
23-
uri_.append(port);
24-
}
25-
26-
std::string port;
27-
28-
};
29-
30-
31-
structport_directive_us {
32-
33-
explicitport_directive_us(boost::uint16_t port)
34-
: port(port)
20+
explicitport_directive(boost::uint16_t port)
21+
: port(boost::lexical_cast<std::string>(port))
3522
{}
3623

37-
voidoperator () (uri &uri_)const {
38-
staticconstchar separator[] = {':'};
39-
uri_.append(boost::begin(separator),boost::end(separator));
40-
std::string port_ = boost::lexical_cast<std::string>(port);
41-
uri_.append(port_);
24+
template<
25+
classUri
26+
>
27+
voidoperator () (Uri &uri)const {
28+
uri.append(":");
29+
uri.append(port);
4230
}
4331

44-
boost::uint16_t port;
32+
std::string port;
4533

4634
};
4735

@@ -51,8 +39,8 @@ port_directive port(const std::string &port) {
5139
}
5240

5341
inline
54-
port_directive_usport(boost::uint16_t port) {
55-
returnport_directive_us(port);
42+
port_directiveport(boost::uint16_t port) {
43+
returnport_directive(port);
5644
}
5745
}// namespace uri
5846
}// namespace network

‎boost/network/uri/directives/query.hpp‎

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@ struct query_directive {
1616
: query(query)
1717
{}
1818

19-
voidoperator () (uri &uri_)const {
20-
std::string encoded_query;
21-
staticconstchar separator[] = {'?'};
22-
uri_.append(boost::begin(separator),boost::end(separator));
23-
uri_.append(query);
19+
template<
20+
classUri
21+
>
22+
voidoperator () (Uri &uri)const {
23+
uri.append("?");
24+
uri.append(query);
2425
}
2526

2627
std::string query;
@@ -38,24 +39,22 @@ struct query_key_query_directive {
3839
: key(key), query(query)
3940
{}
4041

41-
voidoperator () (uri &uri_)const {
42+
template<
43+
classUri
44+
>
45+
voidoperator () (Uri &uri)const {
4246
std::string encoded_key, encoded_query;
43-
staticconstchar qmark[] = {'?'};
44-
staticconstchar equal[] = {'='};
45-
staticconstchar scolon[] = {';'};
46-
if (!uri_.query_range())
47+
if (!uri.query_range())
4748
{
48-
uri_.append(boost::begin(qmark),boost::end(qmark));
49+
uri.append("?");
4950
}
5051
else
5152
{
52-
uri_.append(boost::begin(scolon),boost::end(scolon));
53+
uri.append(";");
5354
}
54-
encode(key,std::back_inserter(encoded_key));
55-
uri_.append(encoded_key);
56-
uri_.append(boost::begin(equal),boost::end(equal));
57-
encode(query,std::back_inserter(encoded_query));
58-
uri_.append(encoded_query);
55+
uri.append(key);
56+
uri.append("=");
57+
uri.append(query);
5958
}
6059

6160
std::string key;

‎boost/network/uri/directives/scheme.hpp‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ struct scheme_directive {
1515
: scheme(scheme)
1616
{}
1717

18-
voidoperator () (uri &uri_)const {
19-
staticconstchar separator[] = {':','/','/'};
20-
uri_.append(scheme);
21-
uri_.append(boost::begin(separator),boost::end(separator));
18+
template<
19+
classUri
20+
>
21+
voidoperator () (Uri &uri)const {
22+
uri.append(scheme);
23+
uri.append("://");
2224
}
2325

2426
std::string scheme;

‎boost/network/uri/directives/user_info.hpp‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ struct user_info_directive {
1515
: user_info(user_info)
1616
{}
1717

18-
voidoperator () (uri &uri_)const {
19-
staticconstchar separator[] = {'@'};
20-
uri_.append(user_info);
21-
uri_.append(boost::begin(separator),boost::end(separator));
18+
template<
19+
classUri
20+
>
21+
voidoperator () (Uri &uri)const {
22+
uri.append(user_info);
23+
uri.append("@");
2224
}
2325

2426
std::string user_info;

‎boost/network/uri/uri.hpp‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,21 @@ bool is_valid(const uri &uri_) {
281281
returnvalid(uri_);
282282
}
283283

284+
inline
285+
boolis_hierarchical(const uri &uri_) {
286+
//uri::const_range_type scheme = uri_.scheme_range();
287+
//uri::const_range_type user_info = uri_.user_info_range();
288+
//return is_valid(uri_) &&
289+
// boost::equal(std::make_pair(boost::end(scheme),
290+
// boost::begin(user_info)),
291+
// boost::as_literal("://"));
292+
returnfalse;
293+
}
294+
295+
boolis_opaque(const uri &uri_) {
296+
returnfalse;
297+
}
298+
284299
inline
285300
booloperator == (const uri &lhs,const uri &rhs) {
286301
returnstd::equal(lhs.begin(), lhs.end(), rhs.begin());

‎libs/network/test/uri/url_builder_test.cpp‎

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,9 @@ BOOST_AUTO_TEST_CASE(encoded_path_test)
7070
instance <<uri::scheme("http")
7171
<<uri::host("www.example.com")
7272
<<uri::port(8000)
73-
<<uri::encoded_path("/Path%20With%20%28Some%29%20Encoded%20Characters%21")
74-
//<< uri::path(uri::encoded("/Path%20With%20%28Some%29%20Encoded%20Characters%21")
73+
<<uri::encoded_path("/Path With (Some) Encoded Characters!")
74+
;
7575
;
76-
std::cout << instance << std::endl;
7776
BOOST_REQUIRE(uri::valid(instance));
7877
BOOST_CHECK_EQUAL(uri::scheme(instance),"http");
7978
BOOST_CHECK_EQUAL(uri::host(instance),"www.example.com");
@@ -141,24 +140,17 @@ BOOST_AUTO_TEST_CASE(from_root_test)
141140
// BOOST_CHECK_EQUAL(uri::path(instance), "/");
142141
//}
143142

144-
//BOOST_AUTO_TEST_CASE(encoded_null_char_test)
145-
//{
146-
// typedef uri::uri uri_type;
147-
// typedef uri_type::string_type string_type;
148-
//
149-
// const std::string scheme("http");
150-
// const std::string host("www.example.com");
151-
// const std::string path("/");
152-
//
153-
// uri_type instance;
154-
// // there is a potential bug in the way we process ranges if the
155-
// // strings are null terminated.
156-
// instance << uri::scheme("http")
157-
// << uri::host("www.example.com")
158-
// << uri::encoded_path("/")
159-
// ;
160-
// BOOST_REQUIRE(uri::valid(instance));
161-
// BOOST_CHECK_EQUAL(uri::scheme(instance), scheme);
162-
// BOOST_CHECK_EQUAL(uri::host(instance), host);
163-
// BOOST_CHECK_EQUAL(uri::path(instance), path);
164-
//}
143+
BOOST_AUTO_TEST_CASE(encoded_null_char_test)
144+
{
145+
// there is a potential bug in the way we process ranges if the
146+
// strings are null terminated.
147+
uri::uri instance;
148+
instance <<uri::scheme("http")
149+
<<uri::host("www.example.com")
150+
<<uri::encoded_path("/")
151+
;
152+
BOOST_REQUIRE(uri::valid(instance));
153+
BOOST_CHECK_EQUAL(uri::scheme(instance),"http");
154+
BOOST_CHECK_EQUAL(uri::host(instance),"www.example.com");
155+
BOOST_CHECK_EQUAL(uri::path(instance),"/");
156+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp