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