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

request_value_semantics test failed#238

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
deanberris merged 4 commits intocpp-netlib:masterfromnico159:master
May 23, 2013
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletionshttp/src/network/protocol/http/request/request.hpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -30,9 +30,8 @@ struct request : request_base {
request(request const&);
request& operator=(request);

// Then we lift the swap and equals implementation.
using request_base::swap;
using request_base::equals;
virtual void swap(request& other);
virtual bool equals(request const& other) const;

// From message_base...
// Mutators
Expand Down
10 changes: 10 additions & 0 deletionshttp/src/network/protocol/http/request/request.ipp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -161,6 +161,16 @@ request& request::operator=(request rhs) {
return *this;
}

void request::swap(request& other ) {
using std::swap;
swap(pimpl_, other.pimpl_);
request_storage_base::swap(other);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Almost, but not quite. It should probably look like this:

using std::swap;swap(pimpl_, other.pimpl_);request_storage_base::swap(other);

}

bool request::equals(request const& other) const {
return pimpl_->equals(*other.pimpl_) && request_storage_base::equals(other);
}

// From message_base...
// Mutators
void request::set_destination(std::string const& destination) {
Expand Down
9 changes: 4 additions & 5 deletionshttp/test/request_base_test.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -42,8 +42,8 @@ TEST(request_test, request_storage_flow) {
ASSERT_EQ(bytes_read, sizeof(data));
std::string flattened;
simple.flatten(flattened);
ASSERT_EQ(flattened,std::string(output, sizeof(data)));
ASSERT_EQ(std::string(data, sizeof(data)),std::string(output, sizeof(data)));
ASSERT_EQ(flattened, output);
ASSERT_EQ(std::string(data, sizeof(data)), output);
simple.clear();
}

Expand All@@ -58,9 +58,8 @@ TEST(request_test, request_storage_copy) {
ASSERT_EQ(bytes_read, sizeof(quick_brown));
std::string flattened;
copy.flatten(flattened);
ASSERT_EQ(flattened, std::string(output, sizeof(quick_brown)));
ASSERT_EQ(std::string(quick_brown, sizeof(quick_brown)),
std::string(output, sizeof(quick_brown)));
ASSERT_EQ(flattened, output);
ASSERT_EQ(std::string(quick_brown, sizeof(quick_brown)), output);
copy.clear();
flattened.clear();
original.flatten(flattened);
Expand Down
15 changes: 15 additions & 0 deletionshttp/test/request_test.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -19,6 +19,21 @@ TEST(message_test, request_construction) {
http::request other(request);
}

TEST(message_test, request_swap) {
network::uri tmp_uri;
network::uri request_uri("http://www.google.com/");
network::uri other_uri("http://www.google.it/");
http::request request(request_uri);
http::request other(other_uri);

request.swap(other);

request.get_uri(tmp_uri);
ASSERT_EQ(tmp_uri, other_uri);
other.get_uri(tmp_uri);
ASSERT_EQ(tmp_uri, request_uri);
}

TEST(message_test, request_value_semantics) {
// First let's default construct a request.
http::request original;
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp