Skip to content

Commit 2fa9a05

Browse files
Simplify test using a stack allocated array
This also happens to fix #1232, although this makes little sense to me.
1 parent 96a98f8 commit 2fa9a05

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

test/test_api.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -138,29 +138,27 @@ struct xsimd_api_test
138138
batch_type b = batch_type::load(v.data(), xsimd::aligned_mode());
139139
V res(size);
140140

141-
bool* b_data = new bool[size];
141+
std::array<bool, size> b_data;
142142

143143
xsimd::store_as(res.data(), b, xsimd::unaligned_mode());
144144
INFO(name, " unaligned");
145145
CHECK_VECTOR_EQ(res, v);
146146

147-
std::fill(b_data, b_data + size, false);
147+
std::fill(b_data.begin(), b_data.end(), false);
148148
batch_bool_type bb = (b == b);
149-
xsimd::store_as(b_data, bb, xsimd::unaligned_mode());
149+
xsimd::store_as(&b_data[0], bb, xsimd::unaligned_mode());
150150
INFO(name, " batch_bool unaligned");
151-
CHECK_UNARY(std::accumulate(b_data, b_data + size, true, std::logical_and<bool>()));
151+
CHECK_UNARY(std::accumulate(b_data.begin(), b_data.end(), true, std::logical_and<bool>()));
152152

153153
xsimd::store_as(res.data(), b, xsimd::aligned_mode());
154154
INFO(name, " aligned");
155155
CHECK_VECTOR_EQ(res, v);
156156

157-
std::fill(b_data, b_data + size, false);
157+
std::fill(b_data.begin(), b_data.end(), false);
158158
bb = (b == b);
159-
xsimd::store_as(b_data, bb, xsimd::aligned_mode());
159+
xsimd::store_as(&b_data[0], bb, xsimd::aligned_mode());
160160
INFO(name, " batch_bool aligned");
161-
CHECK_UNARY(std::accumulate(b_data, b_data + size, true, std::logical_and<bool>()));
162-
163-
delete[] b_data;
161+
CHECK_UNARY(std::accumulate(b_data.begin(), b_data.end(), true, std::logical_and<bool>()));
164162
}
165163

166164
template <class T>

0 commit comments

Comments
 (0)