]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/align/test/align_down_test.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / align / test / align_down_test.cpp
1 /*
2 (c) 2015 Glen Joseph Fernandes
3 <glenjofe -at- gmail.com>
4
5 Distributed under the Boost Software
6 License, Version 1.0.
7 http://boost.org/LICENSE_1_0.txt
8 */
9 #include <boost/align/align_down.hpp>
10 #include <boost/align/is_aligned.hpp>
11 #include <boost/core/lightweight_test.hpp>
12
13 template<std::size_t Alignment>
14 void test()
15 {
16 char s[Alignment << 1];
17 char* b = s;
18 while (!boost::alignment::is_aligned(b, Alignment)) {
19 b++;
20 }
21 {
22 void* p = &b[Alignment];
23 BOOST_TEST(boost::alignment::align_down(p, Alignment) == p);
24 }
25 {
26 void* p = &b[Alignment - 1];
27 void* q = b;
28 BOOST_TEST(boost::alignment::align_down(p, Alignment) == q);
29 }
30 }
31
32 int main()
33 {
34 test<1>();
35 test<2>();
36 test<4>();
37 test<8>();
38 test<16>();
39 test<32>();
40 test<64>();
41 test<128>();
42
43 return boost::report_errors();
44 }