1 // Copyright 2019 Peter Dimov
2 //
3 // Distributed under the Boost Software License, Version 1.0.
4 // http://www.boost.org/LICENSE_1_0.txt
5 
6 #include <boost/endian/arithmetic.hpp>
7 #include <boost/endian/buffers.hpp>
8 #include <boost/core/lightweight_test.hpp>
9 
test()10 template<class A, class B> void test()
11 {
12     A a( 5 );
13     BOOST_TEST_EQ( a.value(), 5 );
14 
15     B& b = a;
16     BOOST_TEST_EQ( b.value(), 5 );
17 
18     b = 14;
19     BOOST_TEST_EQ( b.value(), 14 );
20     BOOST_TEST_EQ( a.value(), 14 );
21 
22     A const& ca = a;
23     BOOST_TEST_EQ( ca.value(), 14 );
24 
25     B const& cb = b;
26     BOOST_TEST_EQ( cb.value(), 14 );
27 
28     a = 31;
29 
30     BOOST_TEST_EQ( a.value(), 31 );
31     BOOST_TEST_EQ( b.value(), 31 );
32 
33     BOOST_TEST_EQ( ca.value(), 31 );
34     BOOST_TEST_EQ( cb.value(), 31 );
35 }
36 
main()37 int main()
38 {
39     using namespace boost::endian;
40 
41     test<big_int16_t, big_int16_buf_t>();
42     test<little_int32_t, little_int32_buf_t>();
43 
44     return boost::report_errors();
45 }
46