Skip to content

Commit 5cb8676

Browse files
committed
Merge branch 'master' of github.com:cpp-netlib/cpp-netlib
2 parents 02cf3ad + 350c215 commit 5cb8676

File tree

5 files changed

+32
-9
lines changed

5 files changed

+32
-9
lines changed

http/src/network/protocol/http/request/request.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,8 @@ struct request : request_base {
3030
request(request const&);
3131
request& operator=(request);
3232

33-
// Then we lift the swap and equals implementation.
34-
using request_base::swap;
35-
using request_base::equals;
33+
virtual void swap(request& other);
34+
virtual bool equals(request const& other) const;
3635

3736
// From message_base...
3837
// Mutators

http/src/network/protocol/http/request/request.ipp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,16 @@ request& request::operator=(request rhs) {
161161
return *this;
162162
}
163163

164+
void request::swap(request& other ) {
165+
using std::swap;
166+
swap(pimpl_, other.pimpl_);
167+
request_storage_base::swap(other);
168+
}
169+
170+
bool request::equals(request const& other) const {
171+
return pimpl_->equals(*other.pimpl_) && request_storage_base::equals(other);
172+
}
173+
164174
// From message_base...
165175
// Mutators
166176
void request::set_destination(std::string const& destination) {

http/test/request_base_test.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ TEST(request_test, request_storage_flow) {
4242
ASSERT_EQ(bytes_read, sizeof(data));
4343
std::string flattened;
4444
simple.flatten(flattened);
45-
ASSERT_EQ(flattened, std::string(output, sizeof(data)));
46-
ASSERT_EQ(std::string(data, sizeof(data)), std::string(output, sizeof(data)));
45+
ASSERT_EQ(flattened, output);
46+
ASSERT_EQ(std::string(data, sizeof(data)), output);
4747
simple.clear();
4848
}
4949

@@ -58,9 +58,8 @@ TEST(request_test, request_storage_copy) {
5858
ASSERT_EQ(bytes_read, sizeof(quick_brown));
5959
std::string flattened;
6060
copy.flatten(flattened);
61-
ASSERT_EQ(flattened, std::string(output, sizeof(quick_brown)));
62-
ASSERT_EQ(std::string(quick_brown, sizeof(quick_brown)),
63-
std::string(output, sizeof(quick_brown)));
61+
ASSERT_EQ(flattened, output);
62+
ASSERT_EQ(std::string(quick_brown, sizeof(quick_brown)), output);
6463
copy.clear();
6564
flattened.clear();
6665
original.flatten(flattened);

http/test/request_test.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,21 @@ TEST(message_test, request_construction) {
1919
http::request other(request);
2020
}
2121

22+
TEST(message_test, request_swap) {
23+
network::uri tmp_uri;
24+
network::uri request_uri("http://www.google.com/");
25+
network::uri other_uri("http://www.google.it/");
26+
http::request request(request_uri);
27+
http::request other(other_uri);
28+
29+
request.swap(other);
30+
31+
request.get_uri(tmp_uri);
32+
ASSERT_EQ(tmp_uri, other_uri);
33+
other.get_uri(tmp_uri);
34+
ASSERT_EQ(tmp_uri, request_uri);
35+
}
36+
2237
TEST(message_test, request_value_semantics) {
2338
// First let's default construct a request.
2439
http::request original;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy