]>
Commit | Line | Data |
---|---|---|
7adcbafe | 1 | // Copyright (C) 2017-2022 Free Software Foundation, Inc. |
0348dd00 JW |
2 | // |
3 | // This file is part of the GNU ISO C++ Library. This library is free | |
4 | // software; you can redistribute it and/or modify it under the | |
5 | // terms of the GNU General Public License as published by the | |
6 | // Free Software Foundation; either version 3, or (at your option) | |
7 | // any later version. | |
8 | ||
9 | // This library is distributed in the hope that it will be useful, | |
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | // GNU General Public License for more details. | |
13 | ||
14 | // You should have received a copy of the GNU General Public License along | |
15 | // with this library; see the file COPYING3. If not see | |
16 | // <http://www.gnu.org/licenses/>. | |
17 | ||
0348dd00 | 18 | // { dg-do run { target c++17 } } |
0348dd00 JW |
19 | |
20 | #include <filesystem> | |
49d729ea | 21 | #include <string.h> |
0348dd00 | 22 | #include <testsuite_hooks.h> |
49d729ea | 23 | #include <testsuite_iterators.h> |
0348dd00 JW |
24 | |
25 | using std::filesystem::path; | |
26 | ||
27 | void | |
28 | test01() | |
29 | { | |
49d729ea | 30 | // path(string_type&&, format) |
9534a5e6 | 31 | auto s = [&]() -> path::string_type { return path("foo/bar").native(); }; |
0348dd00 JW |
32 | path p0(s()); |
33 | path p1(s(), path::auto_format); | |
34 | VERIFY( p1 == p0 ); | |
35 | path p2(s(), path::native_format); | |
36 | VERIFY( p2 == p0 ); | |
37 | path p3(s(), path::generic_format); | |
38 | VERIFY( p3 == p0 ); | |
39 | } | |
40 | ||
41 | void | |
42 | test02() | |
43 | { | |
49d729ea | 44 | // path(const Source&, format) |
9534a5e6 | 45 | const path::string_type s = path("foo/bar").native(); |
0348dd00 JW |
46 | path p0(s); |
47 | path p1(s, path::auto_format); | |
48 | VERIFY( p1 == p0 ); | |
49 | path p2(s, path::native_format); | |
50 | VERIFY( p2 == p0 ); | |
51 | path p3(s, path::generic_format); | |
52 | VERIFY( p3 == p0 ); | |
53 | } | |
54 | ||
55 | void | |
56 | test03() | |
57 | { | |
49d729ea | 58 | // path(const Source&, format) |
9534a5e6 | 59 | const std::string s = "foo/bar"; |
0348dd00 JW |
60 | path p0(s); |
61 | path p1(s, path::auto_format); | |
62 | VERIFY( p1 == p0 ); | |
63 | path p2(s, path::native_format); | |
64 | VERIFY( p2 == p0 ); | |
65 | path p3(s, path::generic_format); | |
66 | VERIFY( p3 == p0 ); | |
67 | } | |
68 | ||
69 | void | |
70 | test04() | |
71 | { | |
49d729ea JW |
72 | #ifdef _GLIBCXX_USE_WCHAR_T |
73 | // path(const Source&, format) | |
9534a5e6 | 74 | const std::wstring s = L"foo/bar"; |
49d729ea JW |
75 | path p0(s); |
76 | path p1(s, path::auto_format); | |
0348dd00 | 77 | VERIFY( p1 == p0 ); |
49d729ea | 78 | path p2(s, path::native_format); |
0348dd00 | 79 | VERIFY( p2 == p0 ); |
49d729ea | 80 | path p3(s, path::generic_format); |
0348dd00 | 81 | VERIFY( p3 == p0 ); |
49d729ea | 82 | #endif |
0348dd00 JW |
83 | } |
84 | ||
85 | void | |
86 | test05() | |
87 | { | |
49d729ea JW |
88 | // path(const Source&, format) |
89 | const char* s = "foo/bar"; | |
90 | path p0(s); | |
91 | path p1(s, path::auto_format); | |
92 | VERIFY( p1 == p0 ); | |
93 | path p2(s, path::native_format); | |
94 | VERIFY( p2 == p0 ); | |
95 | path p3(s, path::generic_format); | |
96 | VERIFY( p3 == p0 ); | |
97 | } | |
98 | ||
99 | void | |
100 | test06() | |
101 | { | |
102 | // path(InputIterator, InputIterator, format) | |
103 | const char s[] = "foo/bar"; | |
104 | using namespace __gnu_test; | |
105 | const test_container<const char, input_iterator_wrapper> c(s, s + strlen(s)); | |
106 | auto c0 = c; | |
107 | path p0(std::begin(c0), std::end(c0)); | |
108 | auto c1 = c; | |
109 | path p1(std::begin(c1), std::end(c1), path::auto_format); | |
110 | VERIFY( p1 == p0 ); | |
111 | auto c2 = c; | |
112 | path p2(std::begin(c2), std::end(c2), path::native_format); | |
113 | VERIFY( p2 == p0 ); | |
114 | auto c3 = c; | |
115 | path p3(std::begin(c3), std::end(c3), path::generic_format); | |
116 | VERIFY( p3 == p0 ); | |
117 | } | |
118 | ||
119 | void | |
120 | test07() | |
121 | { | |
122 | // path(const Source&, const locale&, format) | |
0348dd00 JW |
123 | const char* s = "foo/bar"; |
124 | std::locale loc; | |
125 | path p0(s, loc); | |
126 | path p1(s, loc, path::auto_format); | |
127 | VERIFY( p1 == p0 ); | |
128 | path p2(s, loc, path::native_format); | |
129 | VERIFY( p2 == p0 ); | |
130 | path p3(s, loc, path::generic_format); | |
131 | VERIFY( p3 == p0 ); | |
132 | } | |
133 | ||
134 | void | |
49d729ea | 135 | test08() |
0348dd00 | 136 | { |
49d729ea | 137 | // path(InputIterator, InputIterator, const locale&, format) |
0348dd00 | 138 | const char s[] = "foo/bar"; |
49d729ea JW |
139 | using namespace __gnu_test; |
140 | const test_container<const char, input_iterator_wrapper> c(s, s + strlen(s)); | |
0348dd00 | 141 | std::locale loc; |
49d729ea JW |
142 | auto c0 = c; |
143 | path p0(std::begin(c0), std::end(c0), loc); | |
144 | auto c1 = c; | |
145 | path p1(std::begin(c1), std::end(c1), loc, path::auto_format); | |
0348dd00 | 146 | VERIFY( p1 == p0 ); |
49d729ea JW |
147 | auto c2 = c; |
148 | path p2(std::begin(c2), std::end(c2), loc, path::native_format); | |
0348dd00 | 149 | VERIFY( p2 == p0 ); |
49d729ea JW |
150 | auto c3 = c; |
151 | path p3(std::begin(c3), std::end(c3), loc, path::generic_format); | |
0348dd00 JW |
152 | VERIFY( p3 == p0 ); |
153 | } | |
154 | ||
155 | int | |
156 | main() | |
157 | { | |
158 | test01(); | |
159 | test02(); | |
160 | test03(); | |
161 | test04(); | |
162 | test05(); | |
163 | test06(); | |
49d729ea JW |
164 | test07(); |
165 | test08(); | |
0348dd00 | 166 | } |