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

Commit302c717

Browse files
committed
[uri] Fixed issuecpp-netlib#104.
1 parenteef48fa commit302c717

File tree

2 files changed

+23
-22
lines changed

2 files changed

+23
-22
lines changed

‎boost/network/uri/uri.hpp‎

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,20 +59,17 @@ class BOOST_URI_DECL uri {
5959
}
6060

6161
uri(const uri &other)
62-
: uri_(other.uri_),
63-
uri_parts_(other.uri_parts_),
64-
is_valid_(other.is_valid_) {
65-
62+
: uri_(other.uri_) {
63+
parse();
6664
}
6765

6866
uri &operator = (const uri &other) {
6967
uri(other).swap(*this);
7068
return *this;
7169
}
7270

73-
uri &operator = (const string_type &uri) {
74-
uri_ = uri;
75-
parse();
71+
uri &operator = (const string_type &uri_string) {
72+
uri(uri_string).swap(*this);
7673
return *this;
7774
}
7875

@@ -82,7 +79,8 @@ class BOOST_URI_DECL uri {
8279

8380
voidswap(uri &other) {
8481
boost::swap(uri_, other.uri_);
85-
parse();
82+
boost::swap(uri_parts_, other.uri_parts_);
83+
boost::swap(is_valid_, other.is_valid_);
8684
}
8785

8886
const_iteratorbegin()const {

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

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include<boost/network/uri/uri.hpp>
1111
#include<boost/network/uri/uri_io.hpp>
1212
#include<boost/range/algorithm/equal.hpp>
13+
#include<boost/scoped_ptr.hpp>
1314
#include<map>
1415

1516

@@ -397,16 +398,15 @@ BOOST_AUTO_TEST_CASE(xmpp_query_map_test) {
397398
BOOST_CHECK_EQUAL((++queries.begin())->second,"Hello%20World");
398399
}
399400

400-
BOOST_AUTO_TEST_CASE(range_test)
401-
{
401+
BOOST_AUTO_TEST_CASE(range_test) {
402402
const std::stringurl("http://www.example.com/");
403403
uri::uriinstance(url);
404404
BOOST_REQUIRE(uri::valid(instance));
405405
BOOST_CHECK(boost::equal(instance, url));
406406
}
407407

408-
BOOST_AUTO_TEST_CASE(issue_67_test)
409-
{
408+
BOOST_AUTO_TEST_CASE(issue_67_test) {
409+
// https://github.com/cpp-netlib/cpp-netlib/issues/67
410410
const std::stringsite_name("http://www.google.com");
411411
uri::uri bar0;
412412
uri::uri bar1 = site_name;
@@ -415,32 +415,35 @@ BOOST_AUTO_TEST_CASE(issue_67_test)
415415
BOOST_CHECK(uri::is_valid(bar1));
416416
}
417417

418-
BOOST_AUTO_TEST_CASE(from_parts_1)
419-
{
418+
BOOST_AUTO_TEST_CASE(from_parts_1) {
420419
BOOST_CHECK_EQUAL(uri::uri("http://www.example.com/path?query#fragment"),
421420
uri::from_parts(uri::uri("http://www.example.com"),"/path","query","fragment"));
422421
}
423422

424-
BOOST_AUTO_TEST_CASE(from_parts_2)
425-
{
423+
BOOST_AUTO_TEST_CASE(from_parts_2) {
426424
BOOST_CHECK_EQUAL(uri::uri("http://www.example.com/path?query#fragment"),
427425
uri::from_parts("http://www.example.com","/path","query","fragment"));
428426
}
429427

430-
BOOST_AUTO_TEST_CASE(from_parts_3)
431-
{
428+
BOOST_AUTO_TEST_CASE(from_parts_3) {
432429
BOOST_CHECK_EQUAL(uri::uri("http://www.example.com/path?query"),
433430
uri::from_parts("http://www.example.com","/path","query"));
434431
}
435432

436-
BOOST_AUTO_TEST_CASE(from_parts_4)
437-
{
433+
BOOST_AUTO_TEST_CASE(from_parts_4) {
438434
BOOST_CHECK_EQUAL(uri::uri("http://www.example.com/path"),
439435
uri::from_parts("http://www.example.com","/path"));
440436
}
441437

442-
BOOST_AUTO_TEST_CASE(from_file)
443-
{
438+
BOOST_AUTO_TEST_CASE(from_file) {
444439
boost::filesystem::pathpath("/a/path/to/a/file.txt");
445440
BOOST_CHECK_EQUAL(uri::uri("file:///a/path/to/a/file.txt"),uri::from_file(path));
446441
}
442+
443+
BOOST_AUTO_TEST_CASE(issue_104_test) {
444+
// https://github.com/cpp-netlib/cpp-netlib/issues/104
445+
boost::scoped_ptr<uri::uri>instance(newuri::uri("http://www.example.com/"));
446+
uri::uri copy = *instance;
447+
instance.reset();
448+
BOOST_CHECK_EQUAL(uri::scheme(copy),"http");
449+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp