From a09abace8d4ec0d2fc9bb65493dfae7b7ce8e0fe Mon Sep 17 00:00:00 2001 From: Richard Walters Date: Mon, 23 Jul 2018 21:42:00 -0700 Subject: Add copy constructor and assignment operator --- test/src/UriTests.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'test/src') diff --git a/test/src/UriTests.cpp b/test/src/UriTests.cpp index d8dca7a..72d9f72 100644 --- a/test/src/UriTests.cpp +++ b/test/src/UriTests.cpp @@ -872,3 +872,26 @@ TEST(UriTests, QueryEmptyButPresent) { ASSERT_EQ("", uri.GetQuery()); ASSERT_EQ("http://example.com/?", uri.GenerateString()); } + +TEST(UriTests, MakeACopy) { + Uri::Uri uri1; + (void)uri1.ParseFromString("http://www.example.com/foo.txt"); + Uri::Uri uri2(uri1); + uri1.SetQuery("bar"); + uri2.SetFragment("page2"); + uri2.SetHost("example.com"); + EXPECT_EQ("http://www.example.com/foo.txt?bar", uri1.GenerateString()); + EXPECT_EQ("http://example.com/foo.txt#page2", uri2.GenerateString()); +} + +TEST(UriTests, AssignACopy) { + Uri::Uri uri1; + (void)uri1.ParseFromString("http://www.example.com/foo.txt"); + Uri::Uri uri2; + uri2 = uri1; + uri1.SetQuery("bar"); + uri2.SetFragment("page2"); + uri2.SetHost("example.com"); + EXPECT_EQ("http://www.example.com/foo.txt?bar", uri1.GenerateString()); + EXPECT_EQ("http://example.com/foo.txt#page2", uri2.GenerateString()); +} -- cgit v1.2.3