]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/align/test/is_aligned_integral_test.cpp
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / libs / align / test / is_aligned_integral_test.cpp
CommitLineData
92f5a8d4
TL
1/*
2Copyright 2019 Glen Joseph Fernandes
3(glenjofe@gmail.com)
4
5Distributed under the Boost Software License, Version 1.0.
6(http://www.boost.org/LICENSE_1_0.txt)
7*/
8#include <boost/align/is_aligned.hpp>
9#include <boost/core/lightweight_test.hpp>
10
11template<std::size_t N>
12struct A { };
13
14template<class T, std::size_t N>
15void test(A<N>)
16{
17 T v1 = N;
18 BOOST_TEST(boost::alignment::is_aligned(v1, N));
19 T v2 = N - 1;
20 BOOST_TEST(!boost::alignment::is_aligned(v2, N));
21 T v3 = N + 1;
22 BOOST_TEST(!boost::alignment::is_aligned(v3, N));
23 T v4 = N + N;
24 BOOST_TEST(boost::alignment::is_aligned(v4, N));
25}
26
27template<class T>
28void test(A<1>)
29{
30 T v = 1;
31 BOOST_TEST(boost::alignment::is_aligned(v, 1));
32}
33
34template<class T>
35void test()
36{
37 test<T>(A<1>());
38 test<T>(A<2>());
39 test<T>(A<4>());
40 test<T>(A<8>());
41 test<T>(A<16>());
42 test<T>(A<32>());
43 test<T>(A<64>());
44 test<T>(A<128>());
45}
46
47int main()
48{
49 test<int>();
50 test<unsigned>();
51 test<long>();
52 test<unsigned long>();
53 test<short>();
54 test<unsigned short>();
55#if !defined(BOOST_NO_LONG_LONG)
56 test<long long>();
57 test<unsigned long long>();
58#endif
59 test<std::size_t>();
60 test<std::ptrdiff_t>();
61
62 return boost::report_errors();
63}