mirror of
https://github.com/boostorg/endian.git
synced 2025-08-01 13:34:39 +02:00
Only do relational tests if signedness is the same, to quiet GCC warnings. Start using lightweight test.
This commit is contained in:
68
README
68
README
@@ -1,33 +1,45 @@
|
||||
Boost Endian library
|
||||
|
||||
To experiment with the Endian library, various other boost libraries must be
|
||||
available. So you need to install a current version of Boost if you have not
|
||||
already done so.
|
||||
|
||||
Boost.Endian is a header-only library, so there is no need to run a build
|
||||
for it, but these instructions run a bootstrap so that b2 is available.
|
||||
|
||||
These instructions assume you want to use a fresh copy of boost. If you are
|
||||
going to use an existing copy, skip the svn export and bootstrap steps.
|
||||
|
||||
Windows
|
||||
-------
|
||||
=======
|
||||
|
||||
Prerequisites
|
||||
svn export --non-interactive --trust-server-cert ^
|
||||
http://svn.boost.org/svn/boost/trunk boost-root
|
||||
cd boost-root
|
||||
.\bootstrap
|
||||
cd libs
|
||||
git clone git://github.com/Beman/endian.git
|
||||
cd ..\boost
|
||||
mklink /d endian ..\libs\endian\include\boost\endian
|
||||
cd ..\libs\endian\test
|
||||
..\..\..\b2
|
||||
|
||||
Others
|
||||
======
|
||||
|
||||
BOOST_TRUNK environmental variable set to the path to a current Boost trunk checkout.
|
||||
Example:
|
||||
|
||||
setx BOOST_TRUNK=c:\boost\trunk
|
||||
|
||||
Boost libraries available in %BOOST_TRUNK%\stage\lib. Example:
|
||||
|
||||
cd %BOOST_TRUNK%
|
||||
.\bootstrap
|
||||
.\b2 --with-system --with-chrono --with-timer link=shared stage
|
||||
|
||||
path environmental variable set to include %BOOST_TRUNK%\stage\lib. Example:
|
||||
|
||||
path %path%;%BOOST_TRUNK%\stage\lib
|
||||
|
||||
The provided Visual Studio solution (endian/test/msvc2012/endian.sln) has these Property
|
||||
setups:
|
||||
|
||||
C/C++|General|Additional Include Directories: prefix ..\..\..\..\endian\include;$(BOOST_TRUNK);
|
||||
C/C++|Preprocessor: prefix BOOST_ALL_DYN_LINK;
|
||||
Linker|General|Additional Library Directories: $(BOOST_TRUNK)\stage\lib
|
||||
|
||||
IMPORTANT: If Preprocessor macros are supplied via a common property page,
|
||||
<inherit from parent or project defaults> must be set for each project!
|
||||
------------------------------------------------------------------------------------------
|
||||
svn export --non-interactive --trust-server-cert \
|
||||
http://svn.boost.org/svn/boost/trunk boost-root
|
||||
cd boost-root
|
||||
./bootstrap.sh
|
||||
cd libs
|
||||
git clone git://github.com/Beman/endian.git
|
||||
cd ../boost
|
||||
ln -s ../libs/endian/include/boost/endian endian
|
||||
cd ../libs/endian/test
|
||||
../../../b2
|
||||
|
||||
---------------------------
|
||||
Copyright Beman Dawes, 2013
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
See http://www.boost.org/LICENSE_1_0.txt
|
||||
http://www.boost.org/LICENSE_1_0.txt
|
@@ -14,6 +14,18 @@
|
||||
|
||||
// See endian_test for tests of endianess correctness, size, and value.
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
//----------------------------------------------------------------------------//
|
||||
//----------------------------------------------------------------------------//
|
||||
//----------------------------------------------------------------------------//
|
||||
//
|
||||
//
|
||||
// TODO: transition to BOOST_TEST; more testing can only help
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------//
|
||||
//----------------------------------------------------------------------------//
|
||||
//----------------------------------------------------------------------------//
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
#define _SCL_SECURE_NO_WARNINGS
|
||||
@@ -31,12 +43,35 @@
|
||||
#endif
|
||||
|
||||
#include <boost/endian/types.hpp>
|
||||
#include <boost/type_traits/is_signed.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/detail/lightweight_main.hpp>
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
|
||||
namespace be = boost::endian;
|
||||
|
||||
template <class T>
|
||||
struct value_type
|
||||
{
|
||||
typedef typename T::value_type type;
|
||||
};
|
||||
|
||||
template<> struct value_type<char> { typedef char type; };
|
||||
template<> struct value_type<unsigned char> { typedef unsigned char type; };
|
||||
template<> struct value_type<signed char> { typedef signed char type; };
|
||||
template<> struct value_type<short> { typedef short type; };
|
||||
template<> struct value_type<unsigned short> { typedef unsigned short type; };
|
||||
template<> struct value_type<int> { typedef int type; };
|
||||
template<> struct value_type<unsigned int> { typedef unsigned int type; };
|
||||
template<> struct value_type<long> { typedef long type; };
|
||||
template<> struct value_type<unsigned long> { typedef unsigned long type; };
|
||||
template<> struct value_type<long long> { typedef long long type; };
|
||||
template<> struct value_type<unsigned long long> { typedef unsigned long long type; };
|
||||
template<> struct value_type<float> { typedef float type; };
|
||||
template<> struct value_type<double> { typedef double type; };
|
||||
template<> struct value_type<long double> { typedef long double type; };
|
||||
|
||||
template <class T1, class T2>
|
||||
struct default_construct
|
||||
{
|
||||
@@ -83,19 +118,40 @@ struct assign
|
||||
}
|
||||
};
|
||||
|
||||
template <class T1, class T2>
|
||||
struct relational
|
||||
template <class T1, class T2, bool SameSignedness>
|
||||
struct do_relational
|
||||
{
|
||||
static void test()
|
||||
{
|
||||
T1 o1(1);
|
||||
T2 o2(2);
|
||||
if ( o1 == o2 ) return;
|
||||
if ( o1 != o2 ) return;
|
||||
if ( o1 < o2 ) return;
|
||||
if ( o1 <= o2 ) return;
|
||||
if ( o1 > o2 ) return;
|
||||
if ( o1 >= o2 ) return;
|
||||
BOOST_TEST( !(o1 == o2) );
|
||||
BOOST_TEST( o1 != o2 );
|
||||
BOOST_TEST( o1 < o2 );
|
||||
BOOST_TEST( o1 <= o2 );
|
||||
BOOST_TEST( !(o1 > o2) );
|
||||
BOOST_TEST( !(o1 >= o2 ) );
|
||||
}
|
||||
};
|
||||
|
||||
template <class T1, class T2>
|
||||
struct do_relational<T1, T2, false>
|
||||
{
|
||||
static void test()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
template <class T1, class T2>
|
||||
struct relational
|
||||
{
|
||||
static void test()
|
||||
{
|
||||
do_relational<T1, T2,
|
||||
boost::is_signed<typename value_type<T1>::type>::value
|
||||
== boost::is_signed<typename value_type<T2>::type>::value
|
||||
>::test();
|
||||
// do_relational<T1, T2, true>::test();
|
||||
}
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user