diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/src/UriTests.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/test/src/UriTests.cpp b/test/src/UriTests.cpp index b4be2d5..d246a4d 100644 --- a/test/src/UriTests.cpp +++ b/test/src/UriTests.cpp @@ -274,3 +274,39 @@ TEST(UriTests, ParseFromStringSchemeBarelyLegal) { ++index; } } + +TEST(UriTests, ParseFromStringUserInfoIllegalCharacters) { + const std::vector< std::string > testVectors{ + {"//%X@www.example.com/"}, + {"//{@www.example.com/"}, + }; + size_t index = 0; + for (const auto& testVector : testVectors) { + Uri::Uri uri; + ASSERT_FALSE(uri.ParseFromString(testVector)) << index; + ++index; + } +} + +TEST(UriTests, ParseFromStringUserInfoBarelyLegal) { + struct TestVector { + std::string uriString; + std::string userInfo; + }; + const std::vector< TestVector > testVectors{ + {"//%41@www.example.com/", "A"}, + {"//@www.example.com/", ""}, + {"//!@www.example.com/", "!"}, + {"//'@www.example.com/", "'"}, + {"//(@www.example.com/", "("}, + {"//;@www.example.com/", ";"}, + {"http://:@www.example.com/", ":"}, + }; + size_t index = 0; + for (const auto& testVector : testVectors) { + Uri::Uri uri; + ASSERT_TRUE(uri.ParseFromString(testVector.uriString)) << index; + ASSERT_EQ(testVector.userInfo, uri.GetUserInfo()); + ++index; + } +} |