@@ -47,7 +47,7 @@ class traits_test : public testing::Test
4747 using rtype1 = xsimd::simd_return_type<value_type, float >;
4848 constexpr bool res1 = std::is_same<rtype1, xsimd::batch<float >>::value;
4949 EXPECT_TRUE (res1);
50-
50+
5151 using rtype2 = xsimd::simd_return_type<bool , value_type>;
5252 constexpr bool res2 = std::is_same<rtype2, xsimd::batch_bool<value_type>>::value;
5353 EXPECT_TRUE (res2);
@@ -71,3 +71,65 @@ TYPED_TEST(traits_test, simd_return_type)
7171 this ->test_simd_return_type ();
7272}
7373
74+ template <class B >
75+ class complex_traits_test : public testing ::Test
76+ {
77+ protected:
78+
79+ using batch_type = B;
80+ using value_type = typename B::value_type;
81+
82+ void test_simd_traits ()
83+ {
84+ using traits_type = xsimd::simd_traits<value_type>;
85+ EXPECT_EQ (traits_type::size, batch_type::size);
86+ constexpr bool same_type = std::is_same<B, typename traits_type::type>::value;
87+ EXPECT_TRUE (same_type);
88+ using batch_bool_type = xsimd::batch_bool<typename value_type::value_type>;
89+ constexpr bool same_bool_type = std::is_same<batch_bool_type, typename traits_type::bool_type>::value;
90+ EXPECT_TRUE (same_bool_type);
91+
92+ using vector_traits_type = xsimd::simd_traits<std::vector<value_type>>;
93+ EXPECT_EQ (vector_traits_type::size, 1 );
94+ constexpr bool vec_same_type = std::is_same<typename vector_traits_type::type, std::vector<value_type>>::value;
95+ EXPECT_TRUE (vec_same_type);
96+ }
97+
98+ void test_revert_simd_traits ()
99+ {
100+ using traits_type = xsimd::revert_simd_traits<batch_type>;
101+ EXPECT_EQ (traits_type::size, batch_type::size);
102+ constexpr bool same_type = std::is_same<value_type, typename traits_type::type>::value;
103+ EXPECT_TRUE (same_type);
104+ }
105+
106+ void test_simd_return_type ()
107+ {
108+ using rtype1 = xsimd::simd_return_type<value_type, float >;
109+ constexpr bool res1 = std::is_same<rtype1, xsimd::batch<std::complex <float >>>::value;
110+ EXPECT_TRUE (res1);
111+
112+ using rtype2 = xsimd::simd_return_type<bool , value_type>;
113+ constexpr bool res2 = std::is_same<rtype2, xsimd::batch_bool<value_type>>::value;
114+ EXPECT_TRUE (res2);
115+ }
116+ };
117+
118+ TYPED_TEST_SUITE (complex_traits_test, batch_complex_types, simd_test_names);
119+
120+ TYPED_TEST (complex_traits_test, simd_traits)
121+ {
122+ this ->test_simd_traits ();
123+ }
124+
125+ TYPED_TEST (complex_traits_test, revert_simd_traits)
126+ {
127+ this ->test_revert_simd_traits ();
128+ }
129+
130+ TYPED_TEST (complex_traits_test, simd_return_type)
131+ {
132+ this ->test_simd_return_type ();
133+ }
134+
135+
0 commit comments