comparison libstdc++-v3/testsuite/25_algorithms/copy_backward/94013.cc @ 19:2b5abeee2509 default tip

update gcc11
author anatofuz
date Mon, 25 May 2020 07:50:57 +0900
parents
children
comparison
equal deleted inserted replaced
18:1830386684a0 19:2b5abeee2509
1 // Copyright (C) 2020 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.
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
18 // { dg-do run }
19
20 #include <algorithm>
21 #include <testsuite_hooks.h>
22
23 void
24 test01()
25 {
26 volatile int i[2] = { 1, 2 };
27 volatile int j[2] = { 0, 0 };
28 int k[2] = { 0, 0 };
29
30 std::copy_backward(i, i+2, j+2);
31 VERIFY( j[0] == 1 && j[1] == 2 );
32 std::copy_backward(i, i+2, k+2);
33 VERIFY( k[0] == 1 && k[1] == 2 );
34 std::copy_backward(k+1, k+2, i+1);
35 VERIFY( i[0] == 2 );
36
37 const volatile int* cj = j;
38 std::copy_backward(cj, cj+2, i+2);
39 VERIFY( i[0] == 1 && i[1] == 2 );
40 std::copy_backward(cj+1, cj+2, k+1);
41 VERIFY( k[0] == 2 );
42 const int* ck = k;
43 std::copy_backward(ck, ck+2, i+2);
44 VERIFY( i[0] == 2 && i[1] == 2 );
45 }
46
47 void
48 test02()
49 {
50 #if __cplusplus > 201703L
51 volatile int i[2] = { 1, 2 };
52 volatile int j[2] = { 0, 0 };
53 int k[2] = { 0, 0 };
54
55 std::ranges::copy_backward(i, i+2, j+2);
56 VERIFY( j[0] == 1 && j[1] == 2 );
57 std::ranges::copy_backward(i, i+2, k+2);
58 VERIFY( k[0] == 1 && k[1] == 2 );
59 std::ranges::copy_backward(k+1, k+2, i+1);
60 VERIFY( i[0] == 2 );
61
62 const volatile int* cj = j;
63 std::ranges::copy_backward(cj, cj+2, i+2);
64 VERIFY( i[0] == 1 && i[1] == 2 );
65 std::ranges::copy_backward(cj+1, cj+2, k+1);
66 VERIFY( k[0] == 2 );
67 const int* ck = k;
68 std::ranges::copy_backward(ck, ck+2, i+2);
69 VERIFY( i[0] == 2 && i[1] == 2 );
70 #endif
71 }
72
73 int
74 main()
75 {
76 test01();
77 test02();
78 }