[libcxx-commits] [PATCH] D98106: [libcxx] [test] Fix lexically_normal and lexically_relative_and_proximate for windows

Martin Storsjö via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri Mar 5 23:53:38 PST 2021


mstorsjo created this revision.
mstorsjo requested review of this revision.
Herald added a project: libc++.
Herald added a reviewer: libc++.

Convert the expected result path to preferred separators, add exceptions
to the test results where needed (due to some cases being interpreted
as a root name).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98106

Files:
  libcxx/test/std/input.output/filesystems/class.path/path.member/path.gen/lexically_normal.pass.cpp
  libcxx/test/std/input.output/filesystems/class.path/path.member/path.gen/lexically_relative_and_proximate.pass.cpp


Index: libcxx/test/std/input.output/filesystems/class.path/path.member/path.gen/lexically_relative_and_proximate.pass.cpp
===================================================================
--- libcxx/test/std/input.output/filesystems/class.path/path.member/path.gen/lexically_relative_and_proximate.pass.cpp
+++ libcxx/test/std/input.output/filesystems/class.path/path.member/path.gen/lexically_relative_and_proximate.pass.cpp
@@ -36,9 +36,15 @@
       {"a", "/", ""},
       {"//net", "a", ""},
       {"a", "//net", ""},
+#ifdef _WIN32
+      {"//net/", "//net", ""},
+      {"//net", "//net/", ""},
+      {"//base", "a", ""},
+#else
       {"//net/", "//net", "."},
       {"//net", "//net/", "."},
       {"//base", "a", ""},
+#endif
       {"a", "a", "."},
       {"a/b", "a/b", "."},
       {"a/b/c/", "a/b/c/", "."},
@@ -59,6 +65,8 @@
     ++ID;
     const fs::path p(TC.input);
     const fs::path output = p.lexically_relative(TC.base);
+    fs::path expect(TC.expect);
+    expect.make_preferred();
     auto ReportErr = [&](const char* Testing, fs::path const& Output,
                                               fs::path const& Expected) {
       Failed = true;
@@ -71,8 +79,8 @@
         ID, Testing, TC.input.c_str(), TC.base.c_str(),
         Expected.string().c_str(), Output.string().c_str());
     };
-    if (!PathEq(output, TC.expect))
-      ReportErr("path::lexically_relative", output, TC.expect);
+    if (!PathEq(output, expect))
+      ReportErr("path::lexically_relative", output, expect);
     const fs::path proximate_output = p.lexically_proximate(TC.base);
     // [path.gen] lexically_proximate
     // Returns: If the value of lexically_relative(base) is not an empty path,
Index: libcxx/test/std/input.output/filesystems/class.path/path.member/path.gen/lexically_normal.pass.cpp
===================================================================
--- libcxx/test/std/input.output/filesystems/class.path/path.member/path.gen/lexically_normal.pass.cpp
+++ libcxx/test/std/input.output/filesystems/class.path/path.member/path.gen/lexically_normal.pass.cpp
@@ -54,10 +54,17 @@
       {"/a/b/./", "/a/b/"},
       {"/a/b/c/../d", "/a/b/d"},
       {"/a/b/c/../d/", "/a/b/d/"},
+#ifdef _WIN32
+      {"//a/", "//a/"},
+      {"//a/b/", "//a/b/"},
+      {"//a/b/.", "//a/b/"},
+      {"//a/..", "//a/"},
+#else
       {"//a/", "/a/"},
       {"//a/b/", "/a/b/"},
       {"//a/b/.", "/a/b/"},
       {"//a/..", "/"},
+#endif
       ///===---------------------------------------------------------------===//
       /// Tests specifically for the clauses under [fs.path.generic]p6
       ///===---------------------------------------------------------------===//
@@ -125,13 +132,15 @@
     ++ID;
     fs::path p(TC.input);
     const fs::path output = p.lexically_normal();
-    if (!PathEq(output, TC.expect)) {
+    fs::path expect(TC.expect);
+    expect.make_preferred();
+    if (!PathEq(output, expect)) {
       Failed = true;
       std::fprintf(stderr, "TEST CASE #%d FAILED:\n"
                   "  Input: '%s'\n"
                   "  Expected: '%s'\n"
                   "  Output: '%s'\n",
-        ID, TC.input.c_str(), TC.expect.c_str(), output.string().c_str());
+        ID, TC.input.c_str(), expect.string().c_str(), output.string().c_str());
     }
   }
   return Failed;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98106.328743.patch
Type: text/x-patch
Size: 3322 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20210306/098e259f/attachment.bin>


More information about the libcxx-commits mailing list