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

Martin Storsjö via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri Mar 5 01:12:34 PST 2021


mstorsjo updated this revision to Diff 328431.
mstorsjo edited the summary of this revision.
mstorsjo added a comment.

Added a testcase for `//net/`.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89943/new/

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,8 +86,15 @@
     , {"/foo/", {"/", "foo", ""}, "/", "", "/", "foo/", "/foo", ""}
     , {"foo/bar", {"foo","bar"}, "",  "", "",  "foo/bar", "foo", "bar"}
     , {"/foo//bar", {"/","foo","bar"}, "/", "", "/", "foo/bar", "/foo", "bar"}
+#ifdef _WIN32
+    , {"//net", {"//net"}, "//net", "//net", "", "", "//net", ""}
+    , {"//net/", {"//net", "/"}, "//net/", "//net", "/", "", "//net/", ""}
+    , {"//net/foo", {"//net", "/", "foo"}, "//net/", "//net", "/", "foo", "//net/", "foo"}
+#else
     , {"//net", {"/", "net"}, "/", "", "/", "net", "/", "net"}
+    , {"//net/", {"/", "net", ""}, "/", "", "/", "net/", "//net", ""}
     , {"//net/foo", {"/", "net", "foo"}, "/", "", "/", "net/foo", "/net", "foo"}
+#endif
     , {"///foo///", {"/", "foo", ""}, "/", "", "/", "foo///", "///foo", ""}
     , {"///foo///bar", {"/", "foo", "bar"}, "/", "", "/", "foo///bar", "///foo", "bar"}
     , {"/.", {"/", "."}, "/", "", "/", ".", "/", "."}
@@ -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,13 +123,23 @@
     , {"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\\"}
     , {"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
     , {"//", {"/"}, "/", "", "/", "", "/", ""}
   };
 
@@ -127,7 +153,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 +171,28 @@
     assert(p.filename() == TC.filename);
     assert(p.has_filename() != TC.filename.empty());
 
+#ifdef _WIN32
+    if (!p.has_root_name()) {
+      assert(p.is_absolute() == false);
+    } else {
+      std::string root_name = p.root_name().string();
+      assert(root_name.length() >= 2);
+      if (root_name[1] == ':') {
+        // Drive letter, absolute if has a root directory
+        assert(p.is_absolute() == p.has_root_directory());
+      } else {
+        // Possibly a server path
+        // Convert to one separator style, for simplicity
+        std::replace(root_name.begin(), root_name.end(), '\\', '/');
+        if (root_name[0] == '/' && root_name[1] == '/')
+          assert(p.is_absolute() == true);
+        else
+          assert(p.is_absolute() == false);
+      }
+    }
+#else
     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.328431.patch
Type: text/x-patch
Size: 4940 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20210305/9e362f56/attachment-0001.bin>


More information about the libcxx-commits mailing list