diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2018-12-13 12:26:52 +0000 |
---|---|---|
committer | Jonathan Wakely <redi@gcc.gnu.org> | 2018-12-13 12:26:52 +0000 |
commit | a7a6c14a55dce7cae3bcc7f440c3764f5c048147 (patch) | |
tree | 66059615001d9fdead7676d9709320008e76b315 | |
parent | ebfaf345701abe17eae7757dd07ebc0c2955b0e6 (diff) | |
download | gcc-a7a6c14a55dce7cae3bcc7f440c3764f5c048147.zip gcc-a7a6c14a55dce7cae3bcc7f440c3764f5c048147.tar.gz gcc-a7a6c14a55dce7cae3bcc7f440c3764f5c048147.tar.bz2 |
Fix [fs.path.gen] tests to use backslashes for mingw
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
-rw-r--r-- | libstdc++-v3/ChangeLog | 4 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/27_io/filesystem/path/generation/proximate.cc | 27 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/27_io/filesystem/path/generation/relative.cc | 26 |
3 files changed, 43 insertions, 14 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 3299f10..cde8426 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -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. diff --git a/libstdc++-v3/testsuite/27_io/filesystem/path/generation/proximate.cc b/libstdc++-v3/testsuite/27_io/filesystem/path/generation/proximate.cc index 93466c3..699b536 100644 --- a/libstdc++-v3/testsuite/27_io/filesystem/path/generation/proximate.cc +++ b/libstdc++-v3/testsuite/27_io/filesystem/path/generation/proximate.cc @@ -26,16 +26,28 @@ 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 ); } diff --git a/libstdc++-v3/testsuite/27_io/filesystem/path/generation/relative.cc b/libstdc++-v3/testsuite/27_io/filesystem/path/generation/relative.cc index 6652c19..c366261 100644 --- a/libstdc++-v3/testsuite/27_io/filesystem/path/generation/relative.cc +++ b/libstdc++-v3/testsuite/27_io/filesystem/path/generation/relative.cc @@ -26,16 +26,28 @@ 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 |