forked from boostorg/endian
Merge branch 'develop' into feature/endian-load-store
This commit is contained in:
13
appveyor.yml
13
appveyor.yml
@ -1,4 +1,4 @@
|
||||
# Copyright 2016, 2017 Peter Dimov
|
||||
# Copyright 2016-2019 Peter Dimov
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
|
||||
|
||||
@ -18,13 +18,19 @@ environment:
|
||||
TOOLSET: msvc-9.0,msvc-10.0,msvc-11.0,msvc-12.0
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
TOOLSET: msvc-14.0
|
||||
ADDRMD: 32,64
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
TOOLSET: msvc-14.1
|
||||
CXXSTD: 14,17
|
||||
ADDRMD: 32,64
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
|
||||
ADDPATH: C:\cygwin\bin;
|
||||
TOOLSET: gcc
|
||||
CXXSTD: 03,11,14,1z
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
|
||||
ADDPATH: C:\cygwin64\bin;
|
||||
TOOLSET: gcc
|
||||
CXXSTD: 03,11,14,1z
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
|
||||
ADDPATH: C:\mingw\bin;
|
||||
TOOLSET: gcc
|
||||
@ -41,7 +47,7 @@ install:
|
||||
- git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
- cd boost-root
|
||||
- git submodule update --init tools/boostdep
|
||||
- xcopy /s /e /q %APPVEYOR_BUILD_FOLDER% libs\endian
|
||||
- xcopy /s /e /q %APPVEYOR_BUILD_FOLDER% libs\endian\
|
||||
- python tools/boostdep/depinst/depinst.py endian
|
||||
- cmd /c bootstrap
|
||||
- b2 -d0 headers
|
||||
@ -51,4 +57,5 @@ build: off
|
||||
test_script:
|
||||
- PATH=%ADDPATH%%PATH%
|
||||
- if not "%CXXSTD%" == "" set CXXSTD=cxxstd=%CXXSTD%
|
||||
- b2 -j3 libs/endian/test toolset=%TOOLSET% %CXXSTD% variant=debug,release
|
||||
- if not "%ADDRMD%" == "" set ADDRMD=address-model=%ADDRMD%
|
||||
- b2 -j3 libs/endian/test toolset=%TOOLSET% %CXXSTD% %ADDRMD% variant=debug,release
|
||||
|
@ -282,6 +282,20 @@ namespace endian
|
||||
# endif
|
||||
}
|
||||
|
||||
// overloads for char and char16_t, which otherwise use int32_t
|
||||
|
||||
inline char endian_reverse(char x) BOOST_NOEXCEPT
|
||||
{
|
||||
return static_cast<char>( endian_reverse( static_cast<uint8_t>(x) ) );
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_CHAR16_T)
|
||||
inline char16_t endian_reverse(char16_t x) BOOST_NOEXCEPT
|
||||
{
|
||||
return static_cast<char16_t>( endian_reverse( static_cast<uint16_t>(x) ) );
|
||||
}
|
||||
#endif
|
||||
|
||||
template <class EndianReversible >
|
||||
inline EndianReversible big_to_native(EndianReversible x) BOOST_NOEXCEPT
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
# Boost Endian Library test Jamfile
|
||||
|
||||
# Copyright Beman Dawes 2006, 2013
|
||||
# Copyright 2018 Peter Dimov
|
||||
# Copyright 2018, 2019 Peter Dimov
|
||||
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# See http://www.boost.org/LICENSE_1_0.txt
|
||||
@ -43,3 +43,14 @@ run conversion_test.cpp : : : <define>BOOST_ENDIAN_NO_INTRINSICS : conversion_te
|
||||
run intrinsic_test.cpp ;
|
||||
|
||||
run quick.cpp ;
|
||||
|
||||
local allow-warnings =
|
||||
"-<toolset>msvc:<warnings-as-errors>on"
|
||||
"-<toolset>gcc:<warnings-as-errors>on"
|
||||
"-<toolset>clang:<warnings-as-errors>on" ;
|
||||
|
||||
compile spirit_conflict_test.cpp
|
||||
: $(allow-warnings) ;
|
||||
|
||||
run endian_reverse_test.cpp ;
|
||||
run endian_reverse_test.cpp : : : <define>BOOST_ENDIAN_NO_INTRINSICS : endian_reverse_test_ni ;
|
||||
|
156
test/endian_reverse_test.cpp
Normal file
156
test/endian_reverse_test.cpp
Normal file
@ -0,0 +1,156 @@
|
||||
// Copyright 2019 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma warning( disable: 4309 ) // static_cast: truncation of constant value
|
||||
#endif
|
||||
|
||||
#include <boost/endian/conversion.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <cstddef>
|
||||
|
||||
template<class T, std::size_t N = sizeof(T)> struct test_value
|
||||
{
|
||||
};
|
||||
|
||||
template<class T> struct test_value<T, 1>
|
||||
{
|
||||
static const T v1 = static_cast<T>( 0x1F );
|
||||
static const T w1 = static_cast<T>( 0x1F );
|
||||
|
||||
static const T v2 = static_cast<T>( 0xF1 );
|
||||
static const T w2 = static_cast<T>( 0xF1 );
|
||||
};
|
||||
|
||||
template<class T> T const test_value<T, 1>::v1;
|
||||
template<class T> T const test_value<T, 1>::w1;
|
||||
template<class T> T const test_value<T, 1>::v2;
|
||||
template<class T> T const test_value<T, 1>::w2;
|
||||
|
||||
template<class T> struct test_value<T, 2>
|
||||
{
|
||||
static const T v1 = static_cast<T>( 0x1F2E );
|
||||
static const T w1 = static_cast<T>( 0x2E1F );
|
||||
|
||||
static const T v2 = static_cast<T>( 0xF1E2 );
|
||||
static const T w2 = static_cast<T>( 0xE2F1 );
|
||||
};
|
||||
|
||||
template<class T> T const test_value<T, 2>::v1;
|
||||
template<class T> T const test_value<T, 2>::w1;
|
||||
template<class T> T const test_value<T, 2>::v2;
|
||||
template<class T> T const test_value<T, 2>::w2;
|
||||
|
||||
template<class T> struct test_value<T, 4>
|
||||
{
|
||||
static const T v1 = static_cast<T>( 0x1F2E3D4C );
|
||||
static const T w1 = static_cast<T>( 0x4C3D2E1F );
|
||||
|
||||
static const T v2 = static_cast<T>( 0xF1E2D3C4 );
|
||||
static const T w2 = static_cast<T>( 0xC4D3E2F1 );
|
||||
};
|
||||
|
||||
template<class T> T const test_value<T, 4>::v1;
|
||||
template<class T> T const test_value<T, 4>::w1;
|
||||
template<class T> T const test_value<T, 4>::v2;
|
||||
template<class T> T const test_value<T, 4>::w2;
|
||||
|
||||
template<class T> struct test_value<T, 8>
|
||||
{
|
||||
static const T v1 = static_cast<T>( 0x1F2E3D4C5B6A7988ull );
|
||||
static const T w1 = static_cast<T>( 0x88796A5B4C3D2E1Full );
|
||||
|
||||
static const T v2 = static_cast<T>( 0xF1E2D3C4B5A69788ull );
|
||||
static const T w2 = static_cast<T>( 0x8897A6B5C4D3E2F1ull );
|
||||
};
|
||||
|
||||
template<class T> T const test_value<T, 8>::v1;
|
||||
template<class T> T const test_value<T, 8>::w1;
|
||||
template<class T> T const test_value<T, 8>::v2;
|
||||
template<class T> T const test_value<T, 8>::w2;
|
||||
|
||||
template<class T> void test()
|
||||
{
|
||||
using boost::endian::endian_reverse;
|
||||
using boost::endian::endian_reverse_inplace;
|
||||
|
||||
{
|
||||
T t1 = test_value<T>::v1;
|
||||
|
||||
T t2 = endian_reverse( t1 );
|
||||
BOOST_TEST_EQ( t2, test_value<T>::w1 );
|
||||
|
||||
T t3 = endian_reverse( t2 );
|
||||
BOOST_TEST_EQ( t3, t1 );
|
||||
|
||||
T t4 = t1;
|
||||
|
||||
endian_reverse_inplace( t4 );
|
||||
BOOST_TEST_EQ( t4, test_value<T>::w1 );
|
||||
|
||||
endian_reverse_inplace( t4 );
|
||||
BOOST_TEST_EQ( t4, t1 );
|
||||
}
|
||||
|
||||
{
|
||||
T t1 = test_value<T>::v2;
|
||||
|
||||
T t2 = endian_reverse( t1 );
|
||||
BOOST_TEST_EQ( t2, test_value<T>::w2 );
|
||||
|
||||
T t3 = endian_reverse( t2 );
|
||||
BOOST_TEST_EQ( t3, t1 );
|
||||
|
||||
T t4 = t1;
|
||||
|
||||
endian_reverse_inplace( t4 );
|
||||
BOOST_TEST_EQ( t4, test_value<T>::w2 );
|
||||
|
||||
endian_reverse_inplace( t4 );
|
||||
BOOST_TEST_EQ( t4, t1 );
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test<boost::int8_t>();
|
||||
test<boost::uint8_t>();
|
||||
|
||||
test<boost::int16_t>();
|
||||
test<boost::uint16_t>();
|
||||
|
||||
test<boost::int32_t>();
|
||||
test<boost::uint32_t>();
|
||||
|
||||
test<boost::int64_t>();
|
||||
test<boost::uint64_t>();
|
||||
|
||||
test<char>();
|
||||
test<unsigned char>();
|
||||
test<signed char>();
|
||||
|
||||
test<short>();
|
||||
test<unsigned short>();
|
||||
|
||||
test<int>();
|
||||
test<unsigned int>();
|
||||
|
||||
// test<long>();
|
||||
// test<unsigned long>();
|
||||
|
||||
// test<long long>();
|
||||
// test<unsigned long long>();
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_CHAR16_T)
|
||||
test<char16_t>();
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_CHAR32_T)
|
||||
test<char32_t>();
|
||||
#endif
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
23
test/spirit_conflict_test.cpp
Normal file
23
test/spirit_conflict_test.cpp
Normal file
@ -0,0 +1,23 @@
|
||||
// Copyright 2019 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma warning( disable: 4510 ) // default constructor not generated
|
||||
# pragma warning( disable: 4512 ) // assignment operator not generated
|
||||
# pragma warning( disable: 4610 ) // class can never be instantiated
|
||||
#endif
|
||||
|
||||
#include <boost/spirit/include/qi.hpp>
|
||||
#include <boost/endian/arithmetic.hpp>
|
||||
|
||||
struct record
|
||||
{
|
||||
boost::endian::big_int16_t type;
|
||||
|
||||
record( boost::int16_t t )
|
||||
{
|
||||
type = t;
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user