1 // { dg-options "-std=gnu++17 -lstdc++fs" }
2 // { dg-do run { target c++17 } }
3 // { dg-require-filesystem-ts "" }
5 // Copyright (C) 2014-2018 Free Software Foundation, Inc.
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)
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.
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/>.
22 // C++17 30.10.7.5 path iterators [fs.path.itr]
27 #include <testsuite_hooks.h>
28 #include <testsuite_fs.h>
30 using std::filesystem::path
;
36 VERIFY( p
.begin() == p
.end() );
38 std::vector
<path
> v
, v2
;
41 v
.assign(p
.begin(), p
.end());
46 v
.assign(p
.begin(), p
.end());
51 v
.assign(p
.begin(), p
.end());
56 v
.assign(p
.begin(), p
.end());
60 p
= "//rootname/dir/.";
61 v
.assign(p
.begin(), p
.end());
63 v2
= { "//rootname", "/", "dir", "." };
65 v2
= { "/", "rootname", "dir", "." };
69 p
= "//rootname/dir/";
70 v
.assign(p
.begin(), p
.end());
72 v2
= { "//rootname", "/", "dir", "" };
74 v2
= { "/", "rootname", "dir", "" };
78 p
= "//rootname/dir/filename";
79 v
.assign(p
.begin(), p
.end());
81 v2
= { "//rootname", "/", "dir", "filename" };
83 v2
= { "/", "rootname", "dir", "filename" };
91 using reverse_iterator
= std::reverse_iterator
<path::iterator
>;
92 std::vector
<path
> fwd
, rev
;
94 for (const path
& p
: __gnu_test::test_paths
)
96 const auto begin
= p
.begin(), end
= p
.end();
97 fwd
.assign(begin
, end
);
98 rev
.assign(reverse_iterator(end
), reverse_iterator(begin
));
99 VERIFY( fwd
.size() == rev
.size() );
100 VERIFY( std::equal(fwd
.begin(), fwd
.end(), rev
.rbegin()) );
107 path paths
[] = { "single", "multiple/elements", "trailing/slash/", "/." };
108 for (const path
& p
: paths
)
109 for (auto iter
= p
.begin(); iter
!= p
.end(); ++iter
)
114 VERIFY( iter2
== iter
);
117 VERIFY( iter2
== iter
);