refs #33, added test for trailing preferred seperator on last '..' for path::lexically_normal

This commit is contained in:
Steffen Schuemann 2019-10-23 22:21:10 +02:00
parent 8302328ef9
commit cf5188899b
2 changed files with 8 additions and 0 deletions

View File

@ -2644,6 +2644,12 @@ GHC_INLINE path path::lexically_normal() const
if (dest.empty()) {
dest = ".";
}
else {
static const path suffix[2] = {"", ".."};
if(std::equal(std::reverse_iterator<path::const_iterator>(dest.end()), std::reverse_iterator<path::const_iterator>(dest.begin()), suffix)) {
dest._path.pop_back();
}
}
return dest;
}

View File

@ -873,10 +873,12 @@ TEST_CASE("30.10.8.4.11 path generation", "[filesystem][path][fs.path.gen]")
CHECK(fs::path("foo/..").lexically_normal() == ".");
CHECK(fs::path("ab/cd/ef/../../qw").lexically_normal() == "ab/qw");
CHECK(fs::path("a/b/../../../c").lexically_normal() == "../c");
CHECK(fs::path("../").lexically_normal() == "..");
#ifdef GHC_OS_WINDOWS
CHECK(fs::path("\\/\\///\\/").lexically_normal() == "/");
CHECK(fs::path("a/b/..\\//..///\\/../c\\\\/").lexically_normal() == "../c/");
CHECK(fs::path("..a/b/..\\//..///\\/../c\\\\/").lexically_normal() == "../c/");
CHECK(fs::path("..\\").lexically_normal() == "..");
#endif
// lexically_relative()