]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/endian/test/endian_ld_st_roundtrip_test.cpp
1 // Copyright 2019 Peter Dimov
3 // Distributed under the Boost Software License, Version 1.0.
4 // http://www.boost.org/LICENSE_1_0.txt
6 #include <boost/endian/conversion.hpp>
7 #include <boost/core/lightweight_test.hpp>
8 #include <boost/config.hpp>
9 #include <boost/cstdint.hpp>
12 template<class T
> void test( T
const& x
)
15 unsigned char buffer
[ sizeof(T
) ];
17 boost::endian::endian_store
<T
, sizeof(T
), boost::endian::order::little
>( buffer
, x
);
18 T x2
= boost::endian::endian_load
<T
, sizeof(T
), boost::endian::order::little
>( buffer
);
20 BOOST_TEST_EQ( x
, x2
);
24 unsigned char buffer
[ sizeof(T
) ];
26 boost::endian::endian_store
<T
, sizeof(T
), boost::endian::order::big
>( buffer
, x
);
27 T x2
= boost::endian::endian_load
<T
, sizeof(T
), boost::endian::order::big
>( buffer
);
29 BOOST_TEST_EQ( x
, x2
);
44 return boost::report_errors();