| 1 | // Copyright 2020 Peter Dimov |
|---|---|
| 2 | // Distributed under the Boost Software License, Version 1.0. |
| 3 | // https://www.boost.org/LICENSE_1_0.txt |
| 4 | |
| 5 | #if !defined(__GNUC__) |
| 6 | |
| 7 | #include <boost/config/pragma_message.hpp> |
| 8 | BOOST_PRAGMA_MESSAGE( "Skipping test because __GNUC__ is not defined") |
| 9 | int main() {} |
| 10 | |
| 11 | #else |
| 12 | |
| 13 | #define BOOST_ENDIAN_FORCE_PODNESS |
| 14 | #define BOOST_ENDIAN_NO_CTORS |
| 15 | #include <boost/endian/buffers.hpp> |
| 16 | #include <boost/core/lightweight_test.hpp> |
| 17 | |
| 18 | using namespace boost::endian; |
| 19 | |
| 20 | struct X |
| 21 | { |
| 22 | big_uint16_buf_t a; |
| 23 | native_float64_buf_t b; |
| 24 | little_uint16_buf_t c; |
| 25 | } __attribute__((packed)); |
| 26 | |
| 27 | int main() |
| 28 | { |
| 29 | BOOST_TEST_EQ( sizeof(big_uint16_buf_t), 2 ); |
| 30 | BOOST_TEST_EQ( sizeof(native_float64_buf_t), 8 ); |
| 31 | BOOST_TEST_EQ( sizeof(little_uint16_buf_t), 2 ); |
| 32 | |
| 33 | BOOST_TEST_EQ( sizeof(X), 12 ); |
| 34 | |
| 35 | return boost::report_errors(); |
| 36 | } |
| 37 | |
| 38 | #endif |
| 39 |
