Skip to content

Commit 64fe019

Browse files
committed
Test refactoring: memory
1 parent deabdd1 commit 64fe019

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

test/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ set(XSIMD_TESTS
152152
test_fp_manipulation.cpp
153153
test_hyperbolic.cpp
154154
test_interface.cpp
155+
test_memory.cpp
155156
test_utils.hpp
156157
#[[ xsimd_api_test.hpp
157158
xsimd_api_test.cpp

test/test_memory.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/***************************************************************************
2+
* Copyright (c) Johan Mabille, Sylvain Corlay, Wolf Vollprecht and *
3+
* Martin Renou *
4+
* Copyright (c) QuantStack *
5+
* *
6+
* Distributed under the terms of the BSD 3-Clause License. *
7+
* *
8+
* The full license is in the file LICENSE, distributed with this software. *
9+
****************************************************************************/
10+
11+
#include <vector>
12+
#include <type_traits>
13+
14+
#include "gtest/gtest.h"
15+
16+
#include "xsimd/config/xsimd_instruction_set.hpp"
17+
18+
#ifdef XSIMD_INSTR_SET_AVAILABLE
19+
20+
#include "xsimd/memory/xsimd_alignment.hpp"
21+
22+
struct mock_container {};
23+
24+
TEST(xsimd, alignment)
25+
{
26+
using u_vector_type = std::vector<double>;
27+
using a_vector_type = std::vector<double, xsimd::aligned_allocator<double, XSIMD_DEFAULT_ALIGNMENT>>;
28+
29+
using u_vector_align = xsimd::container_alignment_t<u_vector_type>;
30+
using a_vector_align = xsimd::container_alignment_t<a_vector_type>;
31+
using mock_align = xsimd::container_alignment_t<mock_container>;
32+
33+
EXPECT_TRUE((std::is_same<u_vector_align, xsimd::unaligned_mode>::value));
34+
EXPECT_TRUE((std::is_same<a_vector_align, xsimd::aligned_mode>::value));
35+
EXPECT_TRUE((std::is_same<mock_align, xsimd::unaligned_mode>::value));
36+
}
37+
#endif // XSIMD_INSTR_SET_AVAILABLE

0 commit comments

Comments
 (0)