|
9 | 9 | * The full license is in the file LICENSE, distributed with this software. * |
10 | 10 | ****************************************************************************/ |
11 | 11 |
|
| 12 | +#include <numeric> |
| 13 | + |
12 | 14 | #include "xsimd/xsimd.hpp" |
13 | 15 | #ifndef XSIMD_NO_SUPPORTED_ARCHITECTURE |
14 | 16 |
|
@@ -43,6 +45,22 @@ struct constant_batch_test |
43 | 45 | CHECK_BATCH_EQ((batch_type)b, expected); |
44 | 46 | } |
45 | 47 |
|
| 48 | + void test_init_from_array() const |
| 49 | + { |
| 50 | +#if __cplusplus >= 202002L |
| 51 | + constexpr array_type expected = []() |
| 52 | + { |
| 53 | + array_type out = {}; |
| 54 | + std::iota(out.begin(), out.end(), 0); |
| 55 | + return out; |
| 56 | + }(); |
| 57 | + |
| 58 | + constexpr auto b = xsimd::make_batch_constant<expected, arch_type>(); |
| 59 | + INFO("batch(value_type)"); |
| 60 | + CHECK_BATCH_EQ((batch_type)b, expected); |
| 61 | +#endif |
| 62 | + } |
| 63 | + |
46 | 64 | void test_init_from_generator() const |
47 | 65 | { |
48 | 66 | array_type expected; |
@@ -217,6 +235,8 @@ TEST_CASE_TEMPLATE("[constant batch]", B, BATCH_INT_TYPES) |
217 | 235 | constant_batch_test<B> Test; |
218 | 236 | SUBCASE("init_from_constant") { Test.test_init_from_constant(); } |
219 | 237 |
|
| 238 | + SUBCASE("test_init_from_array") { Test.test_init_from_array(); } |
| 239 | + |
220 | 240 | SUBCASE("init_from_generator") { Test.test_init_from_generator(); } |
221 | 241 |
|
222 | 242 | SUBCASE("as_batch") { Test.test_cast(); } |
@@ -263,6 +283,25 @@ struct constant_bool_batch_test |
263 | 283 | CHECK_BATCH_EQ((batch_bool_type)b, expected); |
264 | 284 | } |
265 | 285 |
|
| 286 | + void test_init_from_array() const |
| 287 | + { |
| 288 | +#if __cplusplus >= 202002L |
| 289 | + constexpr bool_array_type expected = []() |
| 290 | + { |
| 291 | + bool_array_type out = {}; |
| 292 | + for (std::size_t k = 0; k < out.size(); ++k) |
| 293 | + { |
| 294 | + out[k] = k % 2 == 0; |
| 295 | + } |
| 296 | + return out; |
| 297 | + }(); |
| 298 | + |
| 299 | + constexpr auto b = xsimd::make_batch_bool_constant<value_type, expected, arch_type>(); |
| 300 | + INFO("batch_bool_constant(value_type)"); |
| 301 | + CHECK_BATCH_EQ((batch_bool_type)b, expected); |
| 302 | +#endif |
| 303 | + } |
| 304 | + |
266 | 305 | void test_init_from_generator() const |
267 | 306 | { |
268 | 307 | bool_array_type expected; |
@@ -357,6 +396,8 @@ TEST_CASE_TEMPLATE("[constant bool batch]", B, BATCH_INT_TYPES) |
357 | 396 | constant_bool_batch_test<B> Test; |
358 | 397 | SUBCASE("init_from_constant") { Test.test_init_from_constant(); } |
359 | 398 |
|
| 399 | + SUBCASE("test_init_from_array") { Test.test_init_from_array(); } |
| 400 | + |
360 | 401 | SUBCASE("init_from_generator") { Test.test_init_from_generator(); } |
361 | 402 |
|
362 | 403 | SUBCASE("as_batch") { Test.test_cast(); } |
|
0 commit comments