6
6
//
7
7
// ===----------------------------------------------------------------------===//
8
8
9
+ // ADDITIONAL_COMPILE_FLAGS(gcc): -Wno-bool-compare
9
10
// ADDITIONAL_COMPILE_FLAGS(gcc-style-warnings): -Wno-sign-compare
10
11
// MSVC warning C4389: '==': signed/unsigned mismatch
11
12
// ADDITIONAL_COMPILE_FLAGS(cl-style-warnings): /wd4389
@@ -162,6 +163,45 @@ void test_deque() {
162
163
}
163
164
}
164
165
166
+ template <class T >
167
+ struct TestIntegerPromotions1 {
168
+ template <class U >
169
+ TEST_CONSTEXPR_CXX20 void test (T val, U to_find) {
170
+ bool expect_match = val == to_find;
171
+ assert (std::find (&val, &val + 1 , to_find) == (expect_match ? &val : &val + 1 ));
172
+ }
173
+
174
+ template <class U >
175
+ TEST_CONSTEXPR_CXX20 void operator ()() {
176
+ test<U>(0 , 0 );
177
+ test<U>(0 , 1 );
178
+ test<U>(1 , 1 );
179
+ test<U>(0 , -1 );
180
+ test<U>(-1 , -1 );
181
+ test<U>(0 , U (-127 ));
182
+ test<U>(T (-127 ), U (-127 ));
183
+ test<U>(T (-128 ), U (-128 ));
184
+ test<U>(T (-129 ), U (-129 ));
185
+ test<U>(T (255 ), U (255 ));
186
+ test<U>(T (256 ), U (256 ));
187
+ test<U>(T (257 ), U (257 ));
188
+ test<U>(0 , std::numeric_limits<U>::min ());
189
+ test<U>(T (std::numeric_limits<U>::min ()), std::numeric_limits<U>::min ());
190
+ test<U>(0 , std::numeric_limits<U>::min () + 1 );
191
+ test<U>(T (std::numeric_limits<U>::min () + 1 ), std::numeric_limits<U>::min () + 1 );
192
+ test<U>(0 , std::numeric_limits<U>::max ());
193
+ test<U>(T (std::numeric_limits<U>::max ()), std::numeric_limits<U>::max ());
194
+ test<U>(T (std::numeric_limits<U>::max () - 1 ), std::numeric_limits<U>::max () - 1 );
195
+ }
196
+ };
197
+
198
+ struct TestIntegerPromotions {
199
+ template <class T >
200
+ TEST_CONSTEXPR_CXX20 void operator ()() {
201
+ types::for_each (types::integral_types (), TestIntegerPromotions1<T>());
202
+ }
203
+ };
204
+
165
205
TEST_CONSTEXPR_CXX20 bool test () {
166
206
types::for_each (types::integer_types (), TestTypes<char >());
167
207
types::for_each (types::integer_types (), TestTypes<int >());
@@ -181,6 +221,8 @@ TEST_CONSTEXPR_CXX20 bool test() {
181
221
}
182
222
#endif
183
223
224
+ types::for_each (types::integral_types (), TestIntegerPromotions ());
225
+
184
226
return true ;
185
227
}
186
228
0 commit comments