summaryrefslogtreecommitdiffstats
path: root/src/boost/libs/endian/test/quick.cpp
blob: b4861ff85821f004a891aef2ef259f2f741d6d7c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
//  Copyright 2019 Peter Dimov
//  Distributed under the Boost Software License, Version 1.0.
//  http://www.boost.org/LICENSE_1_0.txt

#include <boost/endian/arithmetic.hpp>
#include <boost/core/lightweight_test.hpp>

int main()
{
    using namespace boost::endian;

    {
        little_uint32_t v( 0x01020304 );

        BOOST_TEST_EQ( v.data()[ 0 ], 0x04 );
        BOOST_TEST_EQ( v.data()[ 1 ], 0x03 );
        BOOST_TEST_EQ( v.data()[ 2 ], 0x02 );
        BOOST_TEST_EQ( v.data()[ 3 ], 0x01 );
    }

    {
        big_uint32_t v( 0x01020304 );

        BOOST_TEST_EQ( v.data()[ 0 ], 0x01 );
        BOOST_TEST_EQ( v.data()[ 1 ], 0x02 );
        BOOST_TEST_EQ( v.data()[ 2 ], 0x03 );
        BOOST_TEST_EQ( v.data()[ 3 ], 0x04 );
    }

    return boost::report_errors();
}