diff --git a/README b/README index fdd44e5..ee8d121 100644 --- a/README +++ b/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, - 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 \ No newline at end of file diff --git a/test/endian_operations_test.cpp b/test/endian_operations_test.cpp index c9ae151..1b7a3f8 100644 --- a/test/endian_operations_test.cpp +++ b/test/endian_operations_test.cpp @@ -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 +#include +#include #include #include #include namespace be = boost::endian; +template +struct value_type +{ + typedef typename T::value_type type; +}; + +template<> struct value_type { typedef char type; }; +template<> struct value_type { typedef unsigned char type; }; +template<> struct value_type { typedef signed char type; }; +template<> struct value_type { typedef short type; }; +template<> struct value_type { typedef unsigned short type; }; +template<> struct value_type { typedef int type; }; +template<> struct value_type { typedef unsigned int type; }; +template<> struct value_type { typedef long type; }; +template<> struct value_type { typedef unsigned long type; }; +template<> struct value_type { typedef long long type; }; +template<> struct value_type { typedef unsigned long long type; }; +template<> struct value_type { typedef float type; }; +template<> struct value_type { typedef double type; }; +template<> struct value_type { typedef long double type; }; + template struct default_construct { @@ -83,19 +118,40 @@ struct assign } }; -template -struct relational +template +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 +struct do_relational +{ + static void test() + { + } +}; + +template +struct relational +{ + static void test() + { + do_relational::type>::value + == boost::is_signed::type>::value + >::test(); + // do_relational::test(); } };