]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - libstdc++-v3/testsuite/27_io/filesystem/path/generation/proximate.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 27_io / filesystem / path / generation / proximate.cc
index 93466c3b809855ca1f653a73294da54713e74e80..a67a9054ddbf7129440acb2097b173fbaa3bcb28 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2017-2018 Free Software Foundation, Inc.
+// Copyright (C) 2017-2020 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
@@ -15,9 +15,8 @@
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
-// { dg-options "-std=gnu++17 -lstdc++fs" }
+// { dg-options "-std=gnu++17" }
 // { dg-do run { target c++17 } }
-// { dg-require-filesystem-ts "" }
 
 #include <filesystem>
 #include <testsuite_hooks.h>
 using std::filesystem::path;
 using __gnu_test::compare_paths;
 
+// Normalize directory-separators
+std::string operator""_norm(const char* s, std::size_t n)
+{
+  std::string str(s, n);
+#if defined(__MING32__) || defined(__MINGW64__)
+  for (auto& c : str)
+    if (c == '/')
+      c = '\\';
+#endif
+  return str;
+}
+
 void
 test01()
 {
   // C++17 [fs.path.gen] p5
-  compare_paths( path("/a/d").lexically_proximate("/a/b/c"), "../../d" );
-  compare_paths( path("/a/b/c").lexically_proximate("/a/d"), "../b/c" );
-  compare_paths( path("a/b/c").lexically_proximate("a"), "b/c" );
-  compare_paths( path("a/b/c").lexically_proximate("a/b/c/x/y"), "../.." );
-  compare_paths( path("a/b/c").lexically_proximate("a/b/c"), "." );
-  compare_paths( path("a/b").lexically_proximate("c/d"), "../../a/b" );
+  compare_paths( path("/a/d").lexically_proximate("/a/b/c"), "../../d"_norm );
+  compare_paths( path("/a/b/c").lexically_proximate("/a/d"), "../b/c"_norm );
+  compare_paths( path("a/b/c").lexically_proximate("a"), "b/c"_norm );
+  compare_paths( path("a/b/c").lexically_proximate("a/b/c/x/y"), "../.."_norm );
+  compare_paths( path("a/b/c").lexically_proximate("a/b/c"), "."_norm );
+  compare_paths( path("a/b").lexically_proximate("c/d"), "../../a/b"_norm );
 }
 
 void
@@ -43,7 +54,8 @@ test02()
 {
   path p = "a/b/c";
   compare_paths( p.lexically_proximate(p), "." );
-  compare_paths( p.lexically_proximate("a/../a/b/../b/c/../c/."), "../../b/c" );
+  compare_paths( p.lexically_proximate("a/../a/b/../b/c/../c/."),
+                "../../b/c"_norm );
   compare_paths( p.lexically_proximate("../../../"), p );
 }