| 1 | // { dg-options "-DUSE_FILESYSTEM_TS -lstdc++fs" } |
| 2 | // { dg-do run { target c++11 } } |
| 3 | // { dg-require-filesystem-ts "" } |
| 4 | |
| 5 | // Copyright (C) 2014-2025 Free Software Foundation, Inc. |
| 6 | // |
| 7 | // This file is part of the GNU ISO C++ Library. This library is free |
| 8 | // software; you can redistribute it and/or modify it under the |
| 9 | // terms of the GNU General Public License as published by the |
| 10 | // Free Software Foundation; either version 3, or (at your option) |
| 11 | // any later version. |
| 12 | |
| 13 | // This library is distributed in the hope that it will be useful, |
| 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | // GNU General Public License for more details. |
| 17 | |
| 18 | // You should have received a copy of the GNU General Public License along |
| 19 | // with this library; see the file COPYING3. If not see |
| 20 | // <http://www.gnu.org/licenses/>. |
| 21 | |
| 22 | #include <testsuite_fs.h> |
| 23 | |
| 24 | using std::experimental::filesystem::path; |
| 25 | using __gnu_test::compare_paths; |
| 26 | |
| 27 | void |
| 28 | test01() |
| 29 | { |
| 30 | for (std::string s : __gnu_test::test_paths) |
| 31 | { |
| 32 | path p0 = s, p1, p2, p3, p4; |
| 33 | |
| 34 | p1 = s; |
| 35 | compare_paths(p0, p1); |
| 36 | |
| 37 | p2 = s.c_str(); |
| 38 | compare_paths(p0, p2); |
| 39 | |
| 40 | #if _GLIBCXX_USE_WCHAR_T |
| 41 | std::wstring ws(s.begin(), s.end()); |
| 42 | |
| 43 | p3 = ws; |
| 44 | compare_paths(p0, p3); |
| 45 | |
| 46 | p4 = ws.c_str(); |
| 47 | compare_paths(p0, p4); |
| 48 | #endif |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | void |
| 53 | test02() |
| 54 | { |
| 55 | for (std::string s : __gnu_test::test_paths) |
| 56 | { |
| 57 | path p0 = s, p1, p2, p3, p4, p5, p6, p7, p8; |
| 58 | |
| 59 | p1.assign(s); |
| 60 | compare_paths(p0, p1); |
| 61 | |
| 62 | p2.assign( s.begin(), s.end() ); |
| 63 | compare_paths(p0, p2); |
| 64 | |
| 65 | p3.assign( s.c_str() ); |
| 66 | compare_paths(p0, p3); |
| 67 | |
| 68 | p4.assign( s.c_str(), s.c_str() + s.size() ); |
| 69 | compare_paths(p0, p4); |
| 70 | |
| 71 | #if _GLIBCXX_USE_WCHAR_T |
| 72 | std::wstring ws(s.begin(), s.end()); |
| 73 | |
| 74 | p5.assign(ws); |
| 75 | compare_paths(p0, p5); |
| 76 | |
| 77 | p6.assign( ws.begin(), ws.end() ); |
| 78 | compare_paths(p0, p6); |
| 79 | |
| 80 | p7.assign( ws.c_str() ); |
| 81 | compare_paths(p0, p7); |
| 82 | |
| 83 | p8.assign( ws.c_str(), ws.c_str() + ws.size() ); |
| 84 | compare_paths(p0, p8); |
| 85 | #endif |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | int |
| 90 | main() |
| 91 | { |
| 92 | test01(); |
| 93 | test02(); |
| 94 | } |