Skip to content

Commit 236825f

Browse files
committed
Corrected the 'swap' test
- this worked because string_view had broken equality
1 parent 7e11174 commit 236825f

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/uri.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,13 +166,13 @@ void uri::initialize(optional<string_type> scheme,
166166
}
167167
}
168168

169-
uri::uri() : uri_view_(uri_), uri_parts_() {}
169+
uri::uri() : uri_view_(uri_) {}
170170

171-
uri::uri(const uri &other) : uri_(other.uri_), uri_view_(uri_), uri_parts_() {
171+
uri::uri(const uri &other) : uri_(other.uri_), uri_view_(uri_) {
172172
detail::advance_parts(uri_view_, uri_parts_, other.uri_parts_);
173173
}
174174

175-
uri::uri(const uri_builder &builder) : uri_parts_() {
175+
uri::uri(const uri_builder &builder) {
176176
initialize(builder.scheme_, builder.user_info_, builder.host_, builder.port_,
177177
builder.path_, builder.query_, builder.fragment_);
178178
}
@@ -194,11 +194,12 @@ uri &uri::operator=(uri other) {
194194
}
195195

196196
void uri::swap(uri &other) noexcept {
197-
auto parts = uri_parts_;
198-
advance_parts(other.uri_view_, uri_parts_, other.uri_parts_);
199197
uri_.swap(other.uri_);
200198
uri_view_.swap(other.uri_view_);
201-
advance_parts(other.uri_view_, other.uri_parts_, parts);
199+
200+
const auto this_parts = uri_parts_;
201+
detail::advance_parts(uri_view_, uri_parts_, other.uri_parts_);
202+
detail::advance_parts(other.uri_view_, other.uri_parts_, this_parts);
202203
}
203204

204205
uri::const_iterator uri::begin() const noexcept { return uri_view_.begin(); }

test/uri_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ TEST(uri_test, swap_test) {
444444
ASSERT_TRUE(original.has_path());
445445
EXPECT_EQ("file", original.scheme());
446446
EXPECT_EQ("", original.host());
447-
EXPECT_EQ("/something/different", original.path());
447+
EXPECT_EQ("/something/different/", original.path());
448448

449449
ASSERT_TRUE(instance.has_scheme());
450450
ASSERT_TRUE(instance.has_host());

0 commit comments

Comments
 (0)