[libcxx-commits] [PATCH] D89943: [libcxx] [test] Fix path.decompose for windows

Martin Storsjö via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Oct 22 03:34:43 PDT 2020


mstorsjo created this revision.
mstorsjo added a reviewer: libc++.
Herald added a project: libc++.
Herald added 1 blocking reviewer(s): libc++.
mstorsjo requested review of this revision.

This requires fairly large ifdefs in the test case table. I know ifdefs are to be avoided if possible, but given the number of output expected variables for each row here, it'd be unwieldy to have a separate field for each of the expected values on windows. Other alternatives that keeps it manageable are welcome too.

Ifdef out assertions that root_name() is empty and that is_absolute() == has_root_directory(), as there's differences in them on windows.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D89943

Files:
  libcxx/test/std/input.output/filesystems/class.path/path.member/path.decompose/path.decompose.pass.cpp


Index: libcxx/test/std/input.output/filesystems/class.path/path.member/path.decompose/path.decompose.pass.cpp
===================================================================
--- libcxx/test/std/input.output/filesystems/class.path/path.member/path.decompose/path.decompose.pass.cpp
+++ libcxx/test/std/input.output/filesystems/class.path/path.member/path.decompose/path.decompose.pass.cpp
@@ -86,10 +86,17 @@
     , {"/foo/", {"/", "foo", ""}, "/", "", "/", "foo/", "/foo", ""}
     , {"foo/bar", {"foo","bar"}, "",  "", "",  "foo/bar", "foo", "bar"}
     , {"/foo//bar", {"/","foo","bar"}, "/", "", "/", "foo/bar", "/foo", "bar"}
+#ifdef _MSC_VER
+    , {"//net", {"//net"}, "//net", "//net", "", "", "//net", ""}
+    , {"//net/foo", {"//net", "/", "foo"}, "//net/", "//net", "/", "foo", "//net/", "foo"}
+    , {"///foo///", {"///", "foo", ""}, "///", "", "///", "foo///", "///foo", ""}
+    , {"///foo///bar", {"///", "foo", "bar"}, "///", "", "///", "foo///bar", "///foo", "bar"}
+#else
     , {"//net", {"/", "net"}, "/", "", "/", "net", "/", "net"}
     , {"//net/foo", {"/", "net", "foo"}, "/", "", "/", "net/foo", "/net", "foo"}
     , {"///foo///", {"/", "foo", ""}, "/", "", "/", "foo///", "///foo", ""}
     , {"///foo///bar", {"/", "foo", "bar"}, "/", "", "/", "foo///bar", "///foo", "bar"}
+#endif
     , {"/.", {"/", "."}, "/", "", "/", ".", "/", "."}
     , {"./", {".", ""}, "", "", "", "./", ".", ""}
     , {"/..", {"/", ".."}, "/", "", "/", "..", "/", ".."}
@@ -100,6 +107,15 @@
     , {"foo/./bar", {"foo", ".", "bar"}, "", "", "", "foo/./bar", "foo/.", "bar"}
     , {"foo/../", {"foo", "..", ""}, "", "", "", "foo/../", "foo/..", ""}
     , {"foo/../bar", {"foo", "..", "bar"}, "", "", "", "foo/../bar", "foo/..", "bar"}
+#ifdef _WIN32
+    , {"c:", {"c:"}, "c:", "c:", "", "", "c:", ""}
+    , {"c:/", {"c:", "/"}, "c:/", "c:", "/", "", "c:/", ""}
+    , {"c:foo", {"c:", "foo"}, "c:", "c:", "", "foo", "c:", "foo"}
+    , {"c:/foo", {"c:", "/", "foo"}, "c:/", "c:", "/", "foo", "c:/", "foo"}
+    , {"c:foo/", {"c:", "foo", ""}, "c:", "c:", "", "foo/", "c:foo", ""}
+    , {"c:/foo/", {"c:", "/", "foo", ""}, "c:/", "c:", "/", "foo/",  "c:/foo", ""}
+    , {"c:/foo/bar", {"c:", "/", "foo", "bar"}, "c:/", "c:", "/", "foo/bar", "c:/foo", "bar"}
+#else
     , {"c:", {"c:"}, "", "", "", "c:", "", "c:"}
     , {"c:/", {"c:", ""}, "", "", "", "c:/", "c:", ""}
     , {"c:foo", {"c:foo"}, "", "", "", "c:foo", "", "c:foo"}
@@ -107,7 +123,17 @@
     , {"c:foo/", {"c:foo", ""}, "", "", "", "c:foo/", "c:foo", ""}
     , {"c:/foo/", {"c:", "foo", ""}, "", "", "", "c:/foo/",  "c:/foo", ""}
     , {"c:/foo/bar", {"c:", "foo", "bar"}, "", "", "", "c:/foo/bar", "c:/foo", "bar"}
+#endif
     , {"prn:", {"prn:"}, "", "", "", "prn:", "", "prn:"}
+#ifdef _WIN32
+    , {"c:\\", {"c:", "\\"}, "c:\\", "c:", "\\", "", "c:\\", ""}
+    , {"c:\\foo", {"c:", "\\", "foo"}, "c:\\", "c:", "\\", "foo", "c:\\", "foo"}
+    , {"c:foo\\", {"c:", "foo", ""}, "c:", "c:", "", "foo\\", "c:foo", ""}
+    , {"c:\\foo\\", {"c:", "\\", "foo", ""}, "c:\\", "c:", "\\", "foo\\", "c:\\foo", ""}
+    , {"c:\\foo/",  {"c:", "\\", "foo", ""}, "c:\\", "c:", "\\", "foo/", "c:\\foo", ""}
+    , {"c:/foo\\bar", {"c:", "/", "foo", "bar"}, "c:\\", "c:", "\\", "foo\\bar", "c:/foo", "bar"}
+    , {"//", {"//"}, "/", "", "/", "", "/", ""}
+#else
     , {"c:\\", {"c:\\"}, "", "", "", "c:\\", "", "c:\\"}
     , {"c:\\foo", {"c:\\foo"}, "", "", "", "c:\\foo", "", "c:\\foo"}
     , {"c:foo\\", {"c:foo\\"}, "", "", "", "c:foo\\", "", "c:foo\\"}
@@ -115,6 +141,7 @@
     , {"c:\\foo/",  {"c:\\foo", ""}, "", "", "", "c:\\foo/", "c:\\foo", ""}
     , {"c:/foo\\bar", {"c:", "foo\\bar"}, "", "", "", "c:/foo\\bar", "c:", "foo\\bar"}
     , {"//", {"/"}, "/", "", "/", "", "/", ""}
+#endif
   };
 
 void decompPathTest()
@@ -127,7 +154,9 @@
     assert(p.root_path() == TC.root_path);
     assert(p.has_root_path() != TC.root_path.empty());
 
+#ifndef _WIN32
     assert(p.root_name().native().empty());
+#endif
     assert(p.root_name() == TC.root_name);
     assert(p.has_root_name() != TC.root_name.empty());
 
@@ -143,7 +172,9 @@
     assert(p.filename() == TC.filename);
     assert(p.has_filename() != TC.filename.empty());
 
+#ifndef _WIN32
     assert(p.is_absolute() == p.has_root_directory());
+#endif
     assert(p.is_relative() != p.is_absolute());
     if (p.empty())
       assert(p.is_relative());


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D89943.299910.patch
Type: text/x-patch
Size: 4401 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20201022/f8fa19ec/attachment.bin>


More information about the libcxx-commits mailing list