Multiple exit loop handling in ivopts. Regression tested on x86-64/linux
[official-gcc.git] / libstdc++-v3 / testsuite / 26_numerics / valarray / 30416.cc
blob4ce8f75ed6408e8201e52f278a1d64d71e13b55b
1 // 2007-01-11 Paolo Carlini <pcarlini@suse.de>
3 // Copyright (C) 2007, 2009 Free Software Foundation, Inc.
4 //
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
9 // any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING3. If not see
18 // <http://www.gnu.org/licenses/>.
21 #include <valarray>
22 #include <testsuite_hooks.h>
24 bool
25 comp_vala(const std::valarray<int>& v1, const std::valarray<int>& v2)
27 if (v1.size() == v2.size())
29 for (size_t i = 0; i < v1.size(); ++i)
30 if (v1[i] != v2[i])
31 return false;
32 return true;
34 return false;
37 void
38 init_vala(std::valarray<int>& v, size_t first, size_t last, int val)
40 for (size_t i = first; i <= last; ++i)
41 v[i] = val++;
44 // libstdc++/30416
45 void test01()
47 bool test __attribute__((unused)) = true;
48 using namespace std;
50 // shift
51 valarray<int> v1;
52 valarray<int> v1_ris(v1.shift(0));
53 VERIFY( comp_vala(v1, v1_ris) );
55 valarray<int> v2;
56 valarray<int> v2_ris(v2.shift(10));
57 VERIFY( comp_vala(v2, v2_ris) );
59 valarray<int> v3;
60 valarray<int> v3_ris(v3.shift(-10));
61 VERIFY( comp_vala(v3, v3_ris) );
63 valarray<int> v4(10);
64 valarray<int> v4_ris(v4.shift(0));
65 VERIFY( comp_vala(v4, v4_ris) );
67 valarray<int> v5(10);
68 init_vala(v5, 0, 9, 1);
69 valarray<int> v5_ref(10);
71 valarray<int> v5_ris(v5.shift(16));
72 VERIFY( comp_vala(v5_ris, v5_ref) );
74 valarray<int> v6(10);
75 init_vala(v6, 0, 9, 1);
76 valarray<int> v6_ref(10);
78 valarray<int> v6_ris(v6.shift(-16));
79 VERIFY( comp_vala(v6_ris, v6_ref) );
81 valarray<int> v7(10);
82 init_vala(v7, 0, 9, 1);
83 valarray<int> v7_ref(10);
85 valarray<int> v7_ris(v7.shift(10));
86 VERIFY( comp_vala(v7_ris, v7_ref) );
88 valarray<int> v8(10);
89 init_vala(v8, 0, 9, 1);
90 valarray<int> v8_ref(10);
92 valarray<int> v8_ris(v8.shift(-10));
93 VERIFY( comp_vala(v8_ris, v8_ref) );
95 valarray<int> v9(10);
96 init_vala(v9, 0, 9, 1);
97 valarray<int> v9_ref(10);
98 init_vala(v9_ref, 0, 3, 7);
100 valarray<int> v9_ris(v9.shift(6));
101 VERIFY( comp_vala(v9_ris, v9_ref) );
103 valarray<int> v10(10);
104 init_vala(v10, 0, 9, 1);
105 valarray<int> v10_ref(10);
106 init_vala(v10_ref, 6, 9, 1);
108 valarray<int> v10_ris(v10.shift(-6));
109 VERIFY( comp_vala(v10_ris, v10_ref) );
111 // cshift
112 valarray<int> v11;
113 valarray<int> v11_ris(v11.cshift(0));
114 VERIFY( comp_vala(v11, v11_ris) );
116 valarray<int> v12;
117 valarray<int> v12_ris(v12.cshift(10));
118 VERIFY( comp_vala(v12, v12_ris) );
120 valarray<int> v13;
121 valarray<int> v13_ris(v13.cshift(-10));
122 VERIFY( comp_vala(v13, v13_ris) );
124 valarray<int> v14(10);
125 valarray<int> v14_ris(v14.cshift(0));
126 VERIFY( comp_vala(v14, v14_ris) );
128 valarray<int> v15(10);
129 init_vala(v15, 0, 9, 1);
130 valarray<int> v15_ref(10);
131 init_vala(v15_ref, 0, 3, 7);
132 init_vala(v15_ref, 4, 9, 1);
134 valarray<int> v15_ris(v15.cshift(16));
135 VERIFY( comp_vala(v15_ris, v15_ref) );
137 valarray<int> v16(10);
138 init_vala(v16, 0, 9, 1);
139 valarray<int> v16_ref(10);
140 init_vala(v16_ref, 0, 5, 5);
141 init_vala(v16_ref, 6, 9, 1);
143 valarray<int> v16_ris(v16.cshift(-16));
144 VERIFY( comp_vala(v16_ris, v16_ref) );
146 valarray<int> v17(10);
147 init_vala(v17, 0, 9, 1);
149 valarray<int> v17_ris(v15.cshift(10));
150 VERIFY( comp_vala(v17, v17_ris) );
152 valarray<int> v18(10);
153 init_vala(v18, 0, 9, 1);
155 valarray<int> v18_ris(v18.cshift(-10));
156 VERIFY( comp_vala(v18, v18_ris) );
158 valarray<int> v19(10);
159 init_vala(v19, 0, 9, 1);
160 valarray<int> v19_ref(10);
161 init_vala(v19_ref, 0, 3, 7);
162 init_vala(v19_ref, 4, 9, 1);
164 valarray<int> v19_ris(v15.cshift(6));
165 VERIFY( comp_vala(v19_ris, v19_ref) );
167 valarray<int> v20(10);
168 init_vala(v20, 0, 9, 1);
169 valarray<int> v20_ref(10);
170 init_vala(v20_ref, 0, 5, 5);
171 init_vala(v20_ref, 6, 9, 1);
173 valarray<int> v20_ris(v20.cshift(-6));
174 VERIFY( comp_vala(v20_ris, v20_ref) );
177 int main()
179 test01();
180 return 0;