1 // Copyright (C) 2020-2023 Free Software Foundation, Inc.
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)
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.
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/>.
18 // { dg-do run { target c++20 } }
21 #include <testsuite_hooks.h>
22 #include <testsuite_iterators.h>
24 using __gnu_test::test_range
;
25 using __gnu_test::test_container
;
26 using __gnu_test::bidirectional_iterator_wrapper
;
28 namespace ranges
= std::ranges
;
33 int x
[] = { 1, 2, 3, 4 };
35 test_container
<int, bidirectional_iterator_wrapper
> cx(x
), cw(w
);
36 const int y
[] = { 4, 3, 2, 1 };
38 auto [in
,out
] = ranges::reverse_copy(cx
, cw
.begin());
39 VERIFY( in
== ranges::end(cx
) && out
== cw
.end() );
40 VERIFY( ranges::equal(cw
, y
) );
46 int x
[] = { 1, 2, 3, 4, 5 };
48 test_range
<int, bidirectional_iterator_wrapper
> rx(x
), rw(w
);
49 const int y
[] = { 5, 4, 3, 2, 1 };
51 auto [in
,out
] = ranges::reverse_copy(rx
, ranges::begin(rw
));
52 VERIFY( in
== ranges::end(rx
) && out
== ranges::end(rw
) );
53 VERIFY( ranges::equal(rw
, y
) );
59 const int x
[] = { 1, 2, 3 };
61 const int y
[] = { 2, 1 };
62 ranges::reverse_copy(x
, x
+2, w
);
63 return ranges::equal(w
, y
);
72 static_assert(test03());