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

Commit80c416f

Browse files
committed
Added unit tests for encoded strings in URL.
1 parent7f8e36b commit80c416f

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

‎boost/network/uri/uri_accessors.hpp‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010

1111
#include<boost/network/uri/uri.hpp>
12+
#include<boost/network/uri/encode.hpp>
13+
#include<boost/network/uri/decode.hpp>
1214
#include<boost/spirit/include/qi.hpp>
1315

1416

@@ -80,6 +82,16 @@ typename basic_uri<Tag>::string_type password(const basic_uri<Tag> &uri) {
8082
}
8183
returntypename string<Tag>::type(it,boost::end(user_info_range));
8284
}
85+
86+
template<
87+
classTag
88+
>
89+
typename basic_uri<Tag>::string_typedecoded_path(const basic_uri<Tag> &uri) {
90+
typename basic_uri<Tag>::const_range_type path_range = uri.path_range();
91+
typename basic_uri<Tag>::string_type decoded_path;
92+
decode(path_range,std::back_inserter(decoded_path));
93+
return decoded_path;
94+
}
8395
}// namespace uri
8496
}// namespace network
8597
}// namespace boost

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,16 +201,18 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(encoded_uri_test, T, tag_types) {
201201
typedef uri::basic_uri<T> uri_type;
202202
typedeftypename uri_type::string_type string_type;
203203

204-
const std::stringurl("http://www.example.com/");
204+
const std::stringurl("http://www.example.com/Path%20With%20%28Some%29%20Encoded%20Characters%21");
205205
const std::stringscheme("http");
206206
const std::stringhost("www.example.com");
207-
const std::stringpath("/");
207+
const std::stringencoded_path("/Path%20With%20%28Some%29%20Encoded%20Characters%21");
208+
const std::stringdecoded_path("/Path With (Some) Encoded Characters!");
208209

209210
uri_typeinstance(string_type(boost::begin(url),boost::end(url)));
210211
BOOST_REQUIRE(uri::is_valid(instance));
211212
BOOST_CHECK(boost::equal(uri::scheme(instance), scheme));
212213
BOOST_CHECK(boost::equal(uri::host(instance), host));
213-
BOOST_CHECK(boost::equal(uri::path(instance), path));
214+
BOOST_CHECK(boost::equal(uri::path(instance), encoded_path));
215+
BOOST_CHECK(boost::equal(uri::decoded_path(instance), decoded_path));
214216
}
215217

216218
BOOST_AUTO_TEST_CASE_TEMPLATE(copy_constructor_test, T, tag_types) {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp