]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/endian/test/endian_reverse_test3.cpp
1 // Copyright 2020 Peter Dimov
2 // Distributed under the Boost Software License, Version 1.0.
3 // https://www.boost.org/LICENSE_1_0.txt
5 #include <boost/endian/conversion.hpp>
6 #include <boost/core/lightweight_test.hpp>
7 #include <boost/config.hpp>
10 template<class T
> void test_reverse( T x
)
12 using boost::endian::endian_reverse
;
16 x2
= endian_reverse( endian_reverse( x2
) );
17 BOOST_TEST( x
== x2
);
19 x2
= boost::endian::native_to_little( boost::endian::little_to_native( x2
) );
20 BOOST_TEST( x
== x2
);
22 x2
= boost::endian::native_to_big( boost::endian::big_to_native( x2
) );
23 BOOST_TEST( x
== x2
);
26 template<class T
> void test_reverse_inplace( T x
)
28 using boost::endian::endian_reverse_inplace
;
32 endian_reverse_inplace( x2
);
33 endian_reverse_inplace( x2
);
34 BOOST_TEST( x
== x2
);
36 boost::endian::native_to_little_inplace( x2
);
37 boost::endian::little_to_native_inplace( x2
);
38 BOOST_TEST( x
== x2
);
40 boost::endian::native_to_big_inplace( x2
);
41 boost::endian::big_to_native_inplace( x2
);
42 BOOST_TEST( x
== x2
);
47 #if !defined(BOOST_NO_CXX11_SCOPED_ENUMS)
51 enum class E4
: long { e4
};
59 #if !defined(BOOST_NO_CXX11_SCOPED_ENUMS)
61 test_reverse( E3::e3
);
62 test_reverse( E4::e4
);
66 test_reverse_inplace( 1 );
67 test_reverse_inplace( true );
69 test_reverse_inplace( 1.0f
);
70 test_reverse_inplace( 1.0 );
72 test_reverse_inplace( e1
);
74 #if !defined(BOOST_NO_CXX11_SCOPED_ENUMS)
76 test_reverse_inplace( e2
);
77 test_reverse_inplace( E3::e3
);
78 test_reverse_inplace( E4::e4
);
82 return boost::report_errors();