From 3c296ff707652117c10f9c297f2ea81954f4c296 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Fri, 11 Oct 2019 19:42:32 +0300 Subject: [PATCH] Add test/endian_reverse_cx_test --- test/Jamfile.v2 | 3 +++ test/endian_reverse_cx_test.cpp | 30 ++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 test/endian_reverse_cx_test.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 3000c28..0ead80c 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -70,3 +70,6 @@ run endian_arithmetic_test.cpp ; run endian_arithmetic_test.cpp : : : BOOST_ENDIAN_NO_INTRINSICS : endian_arithmetic_test_ni ; run deprecated_test.cpp ; + +compile endian_reverse_cx_test.cpp ; +compile endian_reverse_cx_test.cpp : BOOST_ENDIAN_NO_INTRINSICS : endian_reverse_cx_test_ni ; diff --git a/test/endian_reverse_cx_test.cpp b/test/endian_reverse_cx_test.cpp new file mode 100644 index 0000000..bd88d86 --- /dev/null +++ b/test/endian_reverse_cx_test.cpp @@ -0,0 +1,30 @@ +// Copyright 2019 Peter Dimov +// +// Distributed under the Boost Software License, Version 1.0. +// http://www.boost.org/LICENSE_1_0.txt + +#include +#include +#include +#include + +#if defined(BOOST_NO_CXX11_CONSTEXPR) + +BOOST_PRAGMA_MESSAGE("Test skipped because BOOST_NO_CXX11_CONSTEXPR is defined") + +#elif defined(BOOST_ENDIAN_NO_INTRINSICS) && defined(BOOST_NO_CXX14_CONSTEXPR) + +BOOST_PRAGMA_MESSAGE("Test skipped because BOOST_ENDIAN_NO_INTRINSICS and BOOST_NO_CXX14_CONSTEXPR are defined") + +#else + +using namespace boost::endian; + +#define STATIC_ASSERT(expr) static_assert(expr, #expr) + +STATIC_ASSERT( endian_reverse( static_cast( 0x01 ) ) == 0x01 ); +STATIC_ASSERT( endian_reverse( static_cast( 0x0102 ) ) == 0x0201 ); +STATIC_ASSERT( endian_reverse( static_cast( 0x01020304 ) ) == 0x04030201 ); +STATIC_ASSERT( endian_reverse( static_cast( 0x0102030405060708 ) ) == 0x0807060504030201 ); + +#endif