]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/align/test/aligned_alloc_test.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / align / test / aligned_alloc_test.cpp
1 /*
2 Copyright 2014 Glen Joseph Fernandes
3 (glenjofe@gmail.com)
4
5 Distributed under the Boost Software License, Version 1.0.
6 (http://www.boost.org/LICENSE_1_0.txt)
7 */
8 #include <boost/align/aligned_alloc.hpp>
9 #include <boost/align/is_aligned.hpp>
10 #include <boost/core/lightweight_test.hpp>
11 #include <cstring>
12
13 void test(std::size_t alignment)
14 {
15 {
16 void* p = boost::alignment::aligned_alloc(alignment, alignment + 1);
17 BOOST_TEST(p != 0);
18 BOOST_TEST(boost::alignment::is_aligned(p, alignment));
19 std::memset(p, 0, alignment);
20 boost::alignment::aligned_free(p);
21 }
22 {
23 void* p = boost::alignment::aligned_alloc(alignment, 1);
24 BOOST_TEST(p != 0);
25 BOOST_TEST(boost::alignment::is_aligned(p, alignment));
26 std::memset(p, 0, 1);
27 boost::alignment::aligned_free(p);
28 }
29 {
30 void* p = boost::alignment::aligned_alloc(alignment, 0);
31 boost::alignment::aligned_free(p);
32 }
33 }
34
35 int main()
36 {
37 test(1);
38 test(2);
39 test(4);
40 test(8);
41 test(16);
42 test(32);
43 test(64);
44 test(128);
45
46 return boost::report_errors();
47 }