RISC-V: Bugfix for max_sew_overlap_and_next_ratio_valid_for_prev_sew_p[pr117483]
[official-gcc.git] / libstdc++-v3 / testsuite / 25_algorithms / copy / 94013.cc
blob63f6e7dabf6d650e08dc43b7a1ab6326d6e0b84d
1 // Copyright (C) 2020-2024 Free Software Foundation, Inc.
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.
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 }
20 #include <algorithm>
21 #include <testsuite_hooks.h>
23 void
24 test01()
26 volatile int i[2] = { 1, 2 };
27 volatile int j[2] = { 0, 0 };
28 int k[2] = { 0, 0 };
30 std::copy(i, i+2, j);
31 VERIFY( j[0] == 1 && j[1] == 2 );
32 std::copy(i, i+2, k);
33 VERIFY( k[0] == 1 && k[1] == 2 );
34 std::copy(k+1, k+2, i);
35 VERIFY( i[0] == 2 );
37 const volatile int* cj = j;
38 std::copy(cj, cj+2, i);
39 VERIFY( i[0] == 1 && i[1] == 2 );
40 std::copy(cj+1, cj+2, k);
41 VERIFY( k[0] == 2 );
42 const int* ck = k;
43 std::copy(ck, ck+2, i);
44 VERIFY( i[0] == 2 && i[1] == 2 );
47 void
48 test02()
50 #if __cplusplus > 201703L
51 volatile int i[2] = { 1, 2 };
52 volatile int j[2] = { 0, 0 };
53 int k[2] = { 0, 0 };
55 std::ranges::copy(i, i+2, j);
56 VERIFY( j[0] == 1 && j[1] == 2 );
57 std::ranges::copy(i, i+2, k);
58 VERIFY( k[0] == 1 && k[1] == 2 );
59 std::ranges::copy(k+1, k+2, i);
60 VERIFY( i[0] == 2 );
62 const volatile int* cj = j;
63 std::ranges::copy(cj, cj+2, i);
64 VERIFY( i[0] == 1 && i[1] == 2 );
65 std::ranges::copy(cj+1, cj+2, k);
66 VERIFY( k[0] == 2 );
67 const int* ck = k;
68 std::ranges::copy(ck, ck+2, i);
69 VERIFY( i[0] == 2 && i[1] == 2 );
70 #endif
73 int
74 main()
76 test01();
77 test02();