aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/src/UriTests.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/test/src/UriTests.cpp b/test/src/UriTests.cpp
index 6ee57c4..b4be2d5 100644
--- a/test/src/UriTests.cpp
+++ b/test/src/UriTests.cpp
@@ -235,3 +235,42 @@ TEST(UriTests, ParseFromStringTwiceFirstUserInfoThenWithout) {
ASSERT_TRUE(uri.ParseFromString("/foo/bar"));
ASSERT_TRUE(uri.GetUserInfo().empty());
}
+
+TEST(UriTests, ParseFromStringSchemeIllegalCharacters) {
+ const std::vector< std::string > testVectors{
+ {"://www.example.com/"},
+ {"0://www.example.com/"},
+ {"+://www.example.com/"},
+ {"@://www.example.com/"},
+ {".://www.example.com/"},
+ {"h@://www.example.com/"},
+ };
+ size_t index = 0;
+ for (const auto& testVector : testVectors) {
+ Uri::Uri uri;
+ ASSERT_FALSE(uri.ParseFromString(testVector)) << index;
+ ++index;
+ }
+}
+
+TEST(UriTests, ParseFromStringSchemeBarelyLegal) {
+ struct TestVector {
+ std::string uriString;
+ std::string scheme;
+ };
+ const std::vector< TestVector > testVectors{
+ {"h://www.example.com/", "h"},
+ {"x+://www.example.com/", "x+"},
+ {"y-://www.example.com/", "y-"},
+ {"z.://www.example.com/", "z."},
+ {"aa://www.example.com/", "aa"},
+ {"a0://www.example.com/", "a0"},
+ };
+ size_t index = 0;
+ for (const auto& testVector : testVectors) {
+ Uri::Uri uri;
+ ASSERT_TRUE(uri.ParseFromString(testVector.uriString)) << index;
+ ASSERT_EQ(testVector.scheme, uri.GetScheme());
+ ++index;
+ }
+}