diff options
author | Richard Walters <rwalters@digitalstirling.com> | 2018-07-02 21:44:18 -0700 |
---|---|---|
committer | Richard Walters <rwalters@digitalstirling.com> | 2018-07-02 21:44:18 -0700 |
commit | 212980eeb06bb44ff6b9da6fc3f324bdaeaf4929 (patch) | |
tree | 2f521122acaba0292aa5e411bd8039e3b23899cd /test | |
parent | 1af6861f8db57b54ba19b80964eb00c5f7340bfb (diff) |
Add more path normalization tests and fix a bug in it
For normalization "step 2C", if the output path was
empty, we don't want to pop the end of it off.
Diffstat (limited to 'test')
-rw-r--r-- | test/src/UriTests.cpp | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/test/src/UriTests.cpp b/test/src/UriTests.cpp index 4275de6..943c25c 100644 --- a/test/src/UriTests.cpp +++ b/test/src/UriTests.cpp @@ -593,13 +593,45 @@ TEST(UriTests, NormalizePath) { const std::vector< TestVector > testVectors{ {"/a/b/c/./../../g", {"", "a", "g"}}, {"mid/content=5/../6", {"mid", "6"}}, + {"http://example.com/a/../b", {"", "b"}}, + {"http://example.com/../b", {"", "b"}}, + {"http://example.com/a/../b", {"", "b"}}, + {"http://example.com/a/../../b", {"", "b"}}, + {"./a/b", {"a", "b"}}, + {"..", {}}, + {"/", {""}}, + {"a/b/..", {"a"}}, + {"a/b/.", {"a", "b"}}, + {"a/b/./c", {"a", "b", "c"}}, + {"a/b/./c/", {"a", "b", "c", ""}}, + {"/a/b/..", {"", "a"}}, + {"/a/b/.", {"", "a", "b"}}, + {"/a/b/./c", {"", "a", "b", "c"}}, + {"/a/b/./c/", {"", "a", "b", "c", ""}}, + {"./a/b/..", {"a"}}, + {"./a/b/.", {"a", "b"}}, + {"./a/b/./c", {"a", "b", "c"}}, + {"./a/b/./c/", {"a", "b", "c", ""}}, + {"../a/b/..", {"a"}}, + {"../a/b/.", {"a", "b"}}, + {"../a/b/./c", {"a", "b", "c"}}, + {"../a/b/./c/", {"a", "b", "c", ""}}, + {"../a/b/../c", {"a", "c"}}, + {"../a/b/./../c/", {"a", "c", ""}}, + {"../a/b/./../c", {"a", "c"}}, + {"../a/b/./../c/", {"a", "c", ""}}, + {"../a/b/.././c/", {"a", "c", ""}}, + {"../a/b/.././c", {"a", "c"}}, + {"../a/b/.././c/", {"a", "c", ""}}, + {"/./c/d", {"", "c", "d"}}, + {"/../c/d", {"", "c", "d"}}, }; size_t index = 0; for (const auto& testVector : testVectors) { Uri::Uri uri; ASSERT_TRUE(uri.ParseFromString(testVector.uriString)) << index; uri.NormalizePath(); - ASSERT_EQ(testVector.normalizedPathSegments, uri.GetPath()); + ASSERT_EQ(testVector.normalizedPathSegments, uri.GetPath()) << index; ++index; } } |