aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/src/UriTests.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/src/UriTests.cpp b/test/src/UriTests.cpp
index 7f4a1a0..e2ad7bd 100644
--- a/test/src/UriTests.cpp
+++ b/test/src/UriTests.cpp
@@ -755,3 +755,34 @@ TEST(UriTests, IPv6Address) {
++index;
}
}
+
+TEST(UriTests, GenerateString) {
+ struct TestVector {
+ std::string scheme;
+ std::string host;
+ std::string query;
+ std::string expectedUriString;
+ };
+ const std::vector< TestVector > testVectors{
+ {"http", "www.example.com", "foobar", "http://www.example.com?foobar"},
+ {"", "example.com", "bar", "//example.com?bar"},
+ {"", "example.com", "", "//example.com"},
+ {"", "", "bar", "?bar"},
+ {"http", "", "bar", "http:?bar"},
+ {"http", "", "", "http:"},
+ {"http", "::1", "", "http://[::1]"},
+ {"http", "::1.2.3.4", "", "http://[::1.2.3.4]"},
+ {"http", "1.2.3.4", "", "http://1.2.3.4"},
+ {"", "", "", ""},
+ };
+ size_t index = 0;
+ for (const auto& testVector : testVectors) {
+ Uri::Uri uri;
+ uri.SetScheme(testVector.scheme);
+ uri.SetHost(testVector.host);
+ uri.SetQuery(testVector.query);
+ const auto actualUriString = uri.GenerateString();
+ ASSERT_EQ(testVector.expectedUriString, actualUriString) << index;
+ ++index;
+ }
+}