diff options
author | Richard Walters <rwalters@digitalstirling.com> | 2020-10-06 19:06:13 -0700 |
---|---|---|
committer | Richard Walters <rwalters@digitalstirling.com> | 2020-10-06 19:06:13 -0700 |
commit | af730ddd195521fd25b7c1dd13fd10c349dd4a7c (patch) | |
tree | 780cb76eff9d115feb1357c608483515851dffc8 | |
parent | 58b228cbf8c3013bedb48e65c6dc0199076b592a (diff) |
Add more test cases for IPvFuture syntax
-rw-r--r-- | test/src/UriTests.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/test/src/UriTests.cpp b/test/src/UriTests.cpp index 34e3483..2fec3a0 100644 --- a/test/src/UriTests.cpp +++ b/test/src/UriTests.cpp @@ -767,6 +767,36 @@ TEST(UriTests, IPv6Address) { } } +TEST(UriTests, IPvFutureAddress) { + struct TestVector { + std::string uriString; + std::string expectedHost; + bool isValid; + }; + const std::vector< TestVector > testVectors{ + // valid + {"http://[v1.x]/", "v1.x", true}, + {"http://[vf.xy]/", "vf.xy", true}, + {"http://[vf.x:y]/", "vf.x:y", true}, + + // invalid + {"http://[vx]/", "", false}, + {"http://[v12]/", "", false}, + {"http://[v1.?]/", "", false}, + {"http://[v1.x?]/", "", false}, + }; + size_t index = 0; + for (const auto& testVector : testVectors) { + Uri::Uri uri; + const bool parseResult = uri.ParseFromString(testVector.uriString); + ASSERT_EQ(testVector.isValid, parseResult) << index; + if (parseResult) { + ASSERT_EQ(testVector.expectedHost, uri.GetHost()); + } + ++index; + } +} + TEST(UriTests, GenerateString) { struct TestVector { std::string scheme; |