1 /* 2 Copyright 2015 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/align_up.hpp> 9 #include <boost/align/is_aligned.hpp> 10 #include <boost/core/lightweight_test.hpp> 11 12 template<std::size_t Alignment> test()13void test() 14 { 15 char s[Alignment << 1]; 16 char* b = s; 17 while (!boost::alignment::is_aligned(b, Alignment)) { 18 ++b; 19 } 20 { 21 void* p = b; 22 BOOST_TEST(boost::alignment::align_up(p, Alignment) == p); 23 } 24 { 25 void* p = &b[Alignment]; 26 void* q = &b[1]; 27 BOOST_TEST(boost::alignment::align_up(q, Alignment) == p); 28 } 29 } 30 main()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 } 44