mirror of
https://git.mirrors.martin98.com/https://github.com/gulrak/filesystem
synced 2025-08-12 13:29:03 +08:00
refs #33, added test for trailing preferred seperator on last '..' for path::lexically_normal
This commit is contained in:
parent
8302328ef9
commit
cf5188899b
@ -2644,6 +2644,12 @@ GHC_INLINE path path::lexically_normal() const
|
|||||||
if (dest.empty()) {
|
if (dest.empty()) {
|
||||||
dest = ".";
|
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;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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("foo/..").lexically_normal() == ".");
|
||||||
CHECK(fs::path("ab/cd/ef/../../qw").lexically_normal() == "ab/qw");
|
CHECK(fs::path("ab/cd/ef/../../qw").lexically_normal() == "ab/qw");
|
||||||
CHECK(fs::path("a/b/../../../c").lexically_normal() == "../c");
|
CHECK(fs::path("a/b/../../../c").lexically_normal() == "../c");
|
||||||
|
CHECK(fs::path("../").lexically_normal() == "..");
|
||||||
#ifdef GHC_OS_WINDOWS
|
#ifdef GHC_OS_WINDOWS
|
||||||
CHECK(fs::path("\\/\\///\\/").lexically_normal() == "/");
|
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("..a/b/..\\//..///\\/../c\\\\/").lexically_normal() == "../c/");
|
CHECK(fs::path("..a/b/..\\//..///\\/../c\\\\/").lexically_normal() == "../c/");
|
||||||
|
CHECK(fs::path("..\\").lexically_normal() == "..");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// lexically_relative()
|
// lexically_relative()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user