aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/src/UriTests.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/src/UriTests.cpp b/test/src/UriTests.cpp
index 1724b89..d7ada25 100644
--- a/test/src/UriTests.cpp
+++ b/test/src/UriTests.cpp
@@ -311,6 +311,44 @@ TEST(UriTests, ParseFromStringUserInfoBarelyLegal) {
}
}
+TEST(UriTests, ParseFromStringHostIllegalCharacters) {
+ const std::vector< std::string > testVectors{
+ {"//%X@www.example.com/"},
+ {"//@www:example.com/"},
+ {"//[vX.:]/"},
+ };
+ size_t index = 0;
+ for (const auto& testVector : testVectors) {
+ Uri::Uri uri;
+ ASSERT_FALSE(uri.ParseFromString(testVector)) << index;
+ ++index;
+ }
+}
+
+TEST(UriTests, ParseFromStringHostBarelyLegal) {
+ struct TestVector {
+ std::string uriString;
+ std::string host;
+ };
+ const std::vector< TestVector > testVectors{
+ {"//%41/", "A"},
+ {"///", ""},
+ {"//!/", "!"},
+ {"//'/", "'"},
+ {"//(/", "("},
+ {"//;/", ";"},
+ {"//1.2.3.4/", "1.2.3.4"},
+ {"//[v7.:]/", "[v7.:]"},
+ };
+ size_t index = 0;
+ for (const auto& testVector : testVectors) {
+ Uri::Uri uri;
+ ASSERT_TRUE(uri.ParseFromString(testVector.uriString)) << index;
+ ASSERT_EQ(testVector.host, uri.GetHost());
+ ++index;
+ }
+}
+
TEST(UriTests, ParseFromStringDontMisinterpretColonInAuthorityAsSchemeDelimiter) {
const std::vector< std::string > testVectors{
{"//foo:bar@www.example.com/"},