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

Commit2c2cf86

Browse files
committed
Updated test for port as an unsigned short.
1 parenta47e864 commit2c2cf86

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

‎boost/network/uri/uri.hpp‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,18 +263,21 @@ struct port_wrapper {
263263

264264
}
265265

266-
operatorboost::optional<unsignedshort> ()const {
266+
boost::optional<unsignedshort>to_optional()const {
267267
typename basic_uri<Tag>::string_type port = uri.port();
268268
return (port.empty())?
269269
boost::optional<unsignedshort>() :
270270
boost::optional<unsignedshort>(boost::lexical_cast<unsignedshort>(port));
271271
}
272272

273+
operator boost::optional<unsignedshort> ()const {
274+
returnto_optional();
275+
}
276+
273277
operatorunsignedshort ()const {
274-
const boost::optional<unsignedshort> &port =
275-
static_cast<boost::optional<unsignedshort> >(*this);
276278
typedeftypename string<Tag>::type string_type;
277279
typedef constants<Tag> consts;
280+
const boost::optional<unsignedshort> &port =to_optional();
278281
if (port)return *port;
279282
returnboost::iequals(uri.scheme_range(),string_type(consts::https())) ?443 :80;
280283
}

‎libs/network/test/url_test.cpp‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(full_uri_test, T, tag_types) {
5656
BOOST_CHECK(boost::equal(uri::scheme(instance), scheme));
5757
BOOST_CHECK(boost::equal(uri::user_info(instance), user_info));
5858
BOOST_CHECK(boost::equal(uri::host(instance), host));
59-
//BOOST_CHECK_EQUAL(uri::port(instance), port);
59+
BOOST_CHECK_EQUAL(static_cast<unsignedshort>(uri::port_us(instance)),8000);
6060
BOOST_CHECK(boost::equal(uri::port(instance), port));
6161
BOOST_CHECK(boost::equal(uri::path(instance), path));
6262
BOOST_CHECK(boost::equal(uri::query(instance), query));
@@ -214,7 +214,6 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(assignment_test, T, tag_types) {
214214
uri_typeinstance(string_type(boost::begin(url),boost::end(url)));
215215
uri_type copy;
216216
copy = instance;
217-
// BOOST_CHECK(instance.raw() == copy.raw());
218217
BOOST_CHECK(instance.to_string() == copy.to_string());
219218
BOOST_CHECK(instance == copy);
220219
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp