Skip to content

Commit ac0cf81

Browse files
committed
More tweaks
1 parent 4a07974 commit ac0cf81

File tree

3 files changed

+76
-0
lines changed

3 files changed

+76
-0
lines changed

modules/yup_core/network/yup_URL.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,36 @@ URL URL::createWithoutParsing (const String& u)
265265
return URL (u, 0);
266266
}
267267

268+
URL& URL::operator= (const URL& other)
269+
{
270+
if (this != std::addressof (other))
271+
{
272+
url = other.url;
273+
postData = other.postData;
274+
parameterNames = other.parameterNames;
275+
parameterValues = other.parameterValues;
276+
anchor = other.anchor;
277+
filesToUpload = other.filesToUpload;
278+
}
279+
280+
return *this;
281+
}
282+
283+
URL& URL::operator= (URL&& other)
284+
{
285+
if (this != std::addressof (other))
286+
{
287+
url = std::move (other.url);
288+
postData = std::move (other.postData);
289+
parameterNames = std::move (other.parameterNames);
290+
parameterValues = std::move (other.parameterValues);
291+
anchor = std::move (other.anchor);
292+
filesToUpload = std::move (other.filesToUpload);
293+
}
294+
295+
return *this;
296+
}
297+
268298
bool URL::operator== (const URL& other) const
269299
{
270300
return url == other.url

modules/yup_core/network/yup_URL.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ class YUP_API URL
7575
/** Move construct an URL. */
7676
URL (URL&& other);
7777

78+
/** Copy assign an URL. */
79+
URL& operator= (const URL& other);
80+
81+
/** Move assign an URL. */
82+
URL& operator= (URL&& other);
83+
7884
/** Compares two URLs.
7985
8086
All aspects of the URLs must be identical for them to match, including any parameters,

tests/yup_core/yup_URL.cpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,46 @@ TEST_F (URLTests, DefaultConstruction)
5757
EXPECT_FALSE (url.isWellFormed());
5858
}
5959

60+
TEST_F (URLTests, CopyConstruction)
61+
{
62+
URL url1 ("http://[email protected]?q=test&page=2#abc");
63+
64+
URL url2 { url1 };
65+
EXPECT_EQ (url1, url2);
66+
EXPECT_EQ (url1.toString (true), url2.toString (true));
67+
EXPECT_EQ (url1.toString (false), url2.toString (false));
68+
}
69+
70+
TEST_F (URLTests, CopyAssignment)
71+
{
72+
URL url1 ("http://[email protected]?q=test&page=2#abc");
73+
74+
URL url2;
75+
url2 = url1;
76+
EXPECT_EQ (url1, url2);
77+
EXPECT_EQ (url1.toString (true), url2.toString (true));
78+
EXPECT_EQ (url1.toString (false), url2.toString (false));
79+
}
80+
81+
TEST_F (URLTests, MoveConstruction)
82+
{
83+
auto urlString = String ("http://[email protected]?q=test&page=2#abc");
84+
URL url1 { urlString };
85+
86+
URL url2 { std::move (url1) };
87+
EXPECT_EQ (url2.toString (true), urlString);
88+
}
89+
90+
TEST_F (URLTests, MoveAssignment)
91+
{
92+
auto urlString = String ("http://[email protected]?q=test&page=2#abc");
93+
URL url1 { urlString };
94+
95+
URL url2;
96+
url2 = std::move (url1);
97+
EXPECT_EQ (url2.toString (true), urlString);
98+
}
99+
60100
TEST_F (URLTests, StringConstruction)
61101
{
62102
// Basic URL

0 commit comments

Comments
 (0)