Source: Enhance check for C++17 filesystem support

* Add `lexically_normal` test for all platforms.

* On Windows, MinGW does not currently handle `lexically_normal()`
  correctly on UNC path, but MSVC and IntelLLVM do--add a comment
  on this to avoid future confusion.

* Add test with `\\?\` notation and `weakly_canonical` that also triggers
  the MinGW bug, but is fine with MSVC and oneAPI, for a more robust and
  comprehensive test.
This commit is contained in:
Michael Hirsch
2023-12-02 20:24:17 -05:00
committed by scivision
parent 57b94595a3
commit ad4481fa00

View File

@@ -9,12 +9,13 @@ int main()
std::filesystem::path p0(L"/a/b/c");
std::filesystem::path p1("/a/b/c");
std::filesystem::path p2("/a/b/c");
if (p1 != p2) {
std::filesystem::path p2("/a/b//c");
if (p1 != p2.lexically_normal()) {
return 1;
}
#if defined(_WIN32)
// "//host/" is not preserved in some environments like GNU under MinGW.
std::filesystem::path p3("//host/a/b/../c");
if (p3.lexically_normal().generic_string() != "//host/a/c") {
return 1;
@@ -24,6 +25,12 @@ int main()
if (p4.lexically_normal().generic_string() != "c:/a/") {
return 1;
}
std::filesystem::path b1("C:\\path\\y\\..\\");
if (std::filesystem::weakly_canonical("\\\\?\\C:\\path\\x\\..") !=
b1.lexically_normal()) {
return 1;
}
#endif
// If std::string is copy-on-write, the std::filesystem::path