]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/core/test/bit_endian_test.cpp
1 // Test for boost/core/bit.hpp (bit_ceil)
3 // Copyright 2020 Peter Dimov
4 // Distributed under the Boost Software License, Version 1.0.
5 // https://www.boost.org/LICENSE_1_0.txt
7 #include <boost/core/bit.hpp>
8 #include <boost/core/lightweight_test.hpp>
9 #include <boost/cstdint.hpp>
13 # pragma warning(disable: 4127) // conditional expression is constant
18 boost::uint64_t v
= ( static_cast<boost::uint64_t>( 0x01020304u
) << 32 ) + 0x05060708u
;
20 if( boost::core::endian::native
== boost::core::endian::little
)
22 unsigned char w
[] = { 8, 7, 6, 5, 4, 3, 2, 1 };
23 BOOST_TEST( std::memcmp( &v
, w
, 8 ) == 0 );
25 else if( boost::core::endian::native
== boost::core::endian::big
)
27 unsigned char w
[] = { 1, 2, 3, 4, 5, 6, 7, 8 };
28 BOOST_TEST( std::memcmp( &v
, w
, 8 ) == 0 );
32 unsigned char w1
[] = { 8, 7, 6, 5, 4, 3, 2, 1 };
33 BOOST_TEST( std::memcmp( &v
, w1
, 8 ) != 0 );
35 unsigned char w2
[] = { 1, 2, 3, 4, 5, 6, 7, 8 };
36 BOOST_TEST( std::memcmp( &v
, w2
, 8 ) != 0 );
39 return boost::report_errors();