]>
Commit | Line | Data |
---|---|---|
641cb5a6 | 1 | // { dg-do run { target c++17 } } |
641cb5a6 | 2 | |
83ffe9cd | 3 | // Copyright (C) 2014-2023 Free Software Foundation, Inc. |
641cb5a6 JW |
4 | // |
5 | // This file is part of the GNU ISO C++ Library. This library is free | |
6 | // software; you can redistribute it and/or modify it under the | |
7 | // terms of the GNU General Public License as published by the | |
8 | // Free Software Foundation; either version 3, or (at your option) | |
9 | // any later version. | |
10 | ||
11 | // This library is distributed in the hope that it will be useful, | |
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | // GNU General Public License for more details. | |
15 | ||
16 | // You should have received a copy of the GNU General Public License along | |
17 | // with this library; see the file COPYING3. If not see | |
18 | // <http://www.gnu.org/licenses/>. | |
19 | ||
20 | #include <filesystem> | |
21 | #include <testsuite_fs.h> | |
d96f11a2 | 22 | #include <testsuite_hooks.h> |
641cb5a6 JW |
23 | |
24 | using std::filesystem::path; | |
25 | using __gnu_test::compare_paths; | |
26 | ||
27 | void | |
28 | test01() | |
29 | { | |
4a7c7999 | 30 | for (const path p : __gnu_test::test_paths) |
641cb5a6 JW |
31 | { |
32 | path copy; | |
33 | copy = p; | |
34 | __gnu_test::compare_paths(p, copy); | |
35 | } | |
36 | } | |
37 | ||
38 | void | |
39 | test02() | |
40 | { | |
4a7c7999 | 41 | for (const path p : __gnu_test::test_paths) |
641cb5a6 JW |
42 | { |
43 | path copy = p; | |
44 | path move; | |
45 | move = std::move(copy); | |
46 | __gnu_test::compare_paths(p, move); | |
47 | } | |
48 | } | |
49 | ||
d96f11a2 JW |
50 | void |
51 | test03() | |
52 | { | |
53 | // self assignment should have no effect | |
54 | const path orig = "foo/bar/baz"; | |
55 | path p = orig; | |
56 | const auto ptr1 = p.c_str(); | |
57 | const auto ptr2 = p.begin()->c_str(); | |
58 | p = std::move(p); | |
59 | __gnu_test::compare_paths(p, orig); | |
60 | p = p; | |
61 | __gnu_test::compare_paths(p, orig); | |
62 | VERIFY( ptr1 == p.c_str() ); | |
63 | VERIFY( ptr2 == p.begin()->c_str() ); | |
64 | } | |
65 | ||
f9b22a0c JW |
66 | void |
67 | test04() | |
68 | { | |
69 | // PR libstdc++/90557 | |
70 | path p1 = "a/b/c"; | |
71 | const path p2 = "d/e"; | |
72 | const path p3 = p2; | |
73 | p1.clear(); | |
74 | p1 = p2; | |
75 | __gnu_test::compare_paths(p1, p2); | |
76 | __gnu_test::compare_paths(p1, p3); | |
77 | __gnu_test::compare_paths(p2, p3); | |
78 | } | |
79 | ||
641cb5a6 JW |
80 | int |
81 | main() | |
82 | { | |
83 | test01(); | |
84 | test02(); | |
d96f11a2 | 85 | test03(); |
f9b22a0c | 86 | test04(); |
641cb5a6 | 87 | } |