Fix [fs.path.gen] tests to use backslashes for mingw
authorJonathan Wakely <jwakely@redhat.com>
Thu, 13 Dec 2018 12:26:52 +0000 (12:26 +0000)
committerJonathan Wakely <redi@gcc.gnu.org>
Thu, 13 Dec 2018 12:26:52 +0000 (12:26 +0000)
The normalized paths contain backslashes so fix the expected values to
use backslashes too.

* testsuite/27_io/filesystem/path/generation/proximate.cc: Use
preferred directory separators for normalized paths.
* testsuite/27_io/filesystem/path/generation/relative.cc: Likewise.

From-SVN: r267090

libstdc++-v3/ChangeLog
libstdc++-v3/testsuite/27_io/filesystem/path/generation/proximate.cc
libstdc++-v3/testsuite/27_io/filesystem/path/generation/relative.cc

index 3299f104153c8149ea39bbc603c350a7798368a5..cde8426089ab5d2ada82c99bad9a3ed25a3f12d7 100644 (file)
@@ -1,5 +1,9 @@
 2018-12-13  Jonathan Wakely  <jwakely@redhat.com>
 
+       * testsuite/27_io/filesystem/path/generation/proximate.cc: Use
+       preferred directory separators for normalized paths.
+       * testsuite/27_io/filesystem/path/generation/relative.cc: Likewise.
+
        * testsuite/27_io/filesystem/path/itr/traversal.cc: Fix test for
        mingw.
 
index 93466c3b809855ca1f653a73294da54713e74e80..699b536b87724ab2635f94aa2b8005aabef70b6c 100644 (file)
 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 +55,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 );
 }
 
index 6652c196d076e92b4718893dc865a854390e2788..c366261951df17939c93dcfde0a8975f04abb52a 100644 (file)
 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_relative("/a/b/c"), "../../d" );
-  compare_paths( path("/a/b/c").lexically_relative("/a/d"), "../b/c" );
-  compare_paths( path("a/b/c").lexically_relative("a"), "b/c" );
-  compare_paths( path("a/b/c").lexically_relative("a/b/c/x/y"), "../.." );
+  compare_paths( path("/a/d").lexically_relative("/a/b/c"), "../../d"_norm );
+  compare_paths( path("/a/b/c").lexically_relative("/a/d"), "../b/c"_norm );
+  compare_paths( path("a/b/c").lexically_relative("a"), "b/c"_norm );
+  compare_paths( path("a/b/c").lexically_relative("a/b/c/x/y"), "../.."_norm );
   compare_paths( path("a/b/c").lexically_relative("a/b/c"), "." );
-  compare_paths( path("a/b").lexically_relative("c/d"), "../../a/b" );
+  compare_paths( path("a/b").lexically_relative("c/d"), "../../a/b"_norm );
 }
 
 void
@@ -43,10 +55,10 @@ test02()
 {
   path p = "a/b/c";
   compare_paths( p.lexically_relative(p), "." );
-  compare_paths( p.lexically_relative("a/../a/b/../b/c/../c/."), "../../b/c" );
+  compare_paths( p.lexically_relative("a/../a/b/../b/c/../c/."), "../../b/c"_norm );
   compare_paths( p.lexically_relative("../../../"), "" );
 
-  compare_paths( path("a/./.").lexically_relative("a"), "./." );
+  compare_paths( path("a/./.").lexically_relative("a"), "./."_norm );
 }
 
 void