diff --git a/.travis.yml b/.travis.yml index b2f4c0a..d8f0cfe 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,45 +9,44 @@ # and how it can be used with Boost libraries. # +sudo: false + os: - linux env: - - CXX_STANDARD=c++98 - - CXX_STANDARD=c++0x + - CXX_STANDARD=c++98 BRANCH_TO_TEST=boost-1.56.0 + - CXX_STANDARD=c++0x BRANCH_TO_TEST=boost-1.56.0 + - CXX_STANDARD=c++98 BRANCH_TO_TEST=boost-1.58.0 + - CXX_STANDARD=c++0x BRANCH_TO_TEST=boost-1.58.0 + - CXX_STANDARD=c++98 BRANCH_TO_TEST=boost-1.59.0 + - CXX_STANDARD=c++0x BRANCH_TO_TEST=boost-1.59.0 + - CXX_STANDARD=c++98 BRANCH_TO_TEST=master + - CXX_STANDARD=c++0x BRANCH_TO_TEST=master + +addons: + apt: + packages: + - xsltproc before_install: # Set this to the name of your Boost library # Autodetect library name by using the following code: - PROJECT_TO_TEST=$(basename $(pwd)) - PROJECT_TO_TEST=$(basename $(pwd)) - # Autodetect Boost branch by using the following code: - BRANCH_TO_TEST=`git rev-parse --abbrev-ref HEAD` - # or by - BRANCH_TO_TEST=$TRAVIS_BRANCH or just directly specify it - - BRANCH_TO_TEST=master - # Files, which coverage results must be ignored (files from other projects). Example: - IGNORE_COVERAGE='*/boost/progress.hpp */filesystem/src/path.cpp' - IGNORE_COVERAGE='*/boost-local/*' # From this point and below code is same for all the Boost libs # Cloning Boost libraries (fast nondeep cloning) - PROJECT_DIR=`pwd` - - BOOST=$HOME/boost-local - - git init $BOOST + - git --version + - BOOST=$HOME/boost + - git clone -b $BRANCH_TO_TEST https://github.com/boostorg/boost.git $BOOST - cd $BOOST - - git remote add --no-tags -t $BRANCH_TO_TEST origin https://github.com/boostorg/boost.git - - git fetch --depth=1 - - git checkout $BRANCH_TO_TEST - git submodule update --init --merge - - git remote set-branches --add origin $BRANCH_TO_TEST - - git pull --recurse-submodules - - git submodule update --init - - git checkout $BRANCH_TO_TEST - - git submodule foreach "git reset --quiet --hard; git clean -fxd" - - git reset --hard; git clean -fxd - - git status - ./bootstrap.sh - ./b2 headers - - sudo apt-get install -qq xsltproc script: - if [ "$CCFLAGS" != "" ]; then FLAGS="cxxflags=\"$CCFLAGS\" linkflags=\"$LINKFLAGS\""; else FLAGS=""; fi diff --git a/build/vc100/.gitignore b/build/vc100/.gitignore index bacfd8c..b6f8d86 100644 --- a/build/vc100/.gitignore +++ b/build/vc100/.gitignore @@ -1,3 +1,4 @@ /*.opensdf /*.sdf /*.suo +*.ipch \ No newline at end of file diff --git a/build/vc100/turtle.vcxproj b/build/vc100/turtle.vcxproj index cc9280e..2fc8585 100644 --- a/build/vc100/turtle.vcxproj +++ b/build/vc100/turtle.vcxproj @@ -102,6 +102,18 @@ ../../out/vc100/$(Configuration)/libraries/$(ProjectName)\ ../../out/vc100_x64/$(Configuration)/libraries/$(ProjectName)\ + + C:\dev\home\boost;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include; + + + C:\dev\home\boost;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include; + + + C:\dev\home\boost;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include; + + + C:\dev\home\boost;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include; + /Zm179 %(AdditionalOptions) diff --git a/build/vc100/turtle_test.vcxproj b/build/vc100/turtle_test.vcxproj index 82f561e..a6aed44 100644 --- a/build/vc100/turtle_test.vcxproj +++ b/build/vc100/turtle_test.vcxproj @@ -88,26 +88,26 @@ ../../out/vc100_x64/$(Configuration)/tests/$(ProjectName)\ - c:\dev\include;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include; - c:\dev\lib\vc100_x64;$(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(WindowsSdkDir)lib;$(FrameworkSDKDir)\lib + C:\dev\home\boost;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include; + C:\dev\home\boost\stage\lib;$(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(WindowsSdkDir)lib;$(FrameworkSDKDir)\lib - c:\dev\include;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include; - c:\dev\lib\vc100_x64;$(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(WindowsSdkDir)lib;$(FrameworkSDKDir)\lib + C:\dev\home\boost;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include; + C:\dev\home\boost\stage\lib;$(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(WindowsSdkDir)lib;$(FrameworkSDKDir)\lib - c:\dev\include;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include; - c:\dev\lib\vc100_x64;$(VCInstallDir)lib\amd64;$(VCInstallDir)atlmfc\lib\amd64;$(WindowsSdkDir)lib\x64; + C:\dev\home\boost;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include; + C:\dev\home\boost\stage\lib;$(VCInstallDir)lib\amd64;$(VCInstallDir)atlmfc\lib\amd64;$(WindowsSdkDir)lib\x64; - c:\dev\include;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include; - c:\dev\lib\vc100_x64;$(VCInstallDir)lib\amd64;$(VCInstallDir)atlmfc\lib\amd64;$(WindowsSdkDir)lib\x64; + C:\dev\home\boost;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include; + C:\dev\home\boost\stage\lib;$(VCInstallDir)lib\amd64;$(VCInstallDir)atlmfc\lib\amd64;$(WindowsSdkDir)lib\x64; /Zm172 %(AdditionalOptions) Disabled - ../..; ../../include;%(AdditionalIncludeDirectories) + ../../include;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebugDLL @@ -140,7 +140,7 @@ /Zm172 %(AdditionalOptions) Disabled - ../..;../../include;%(AdditionalIncludeDirectories) + ../../include;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebugDLL @@ -172,7 +172,7 @@ /Zm162 %(AdditionalOptions) MaxSpeed - ../..; ../../include;%(AdditionalIncludeDirectories) + ../../include;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) Default MultiThreadedDLL @@ -205,7 +205,7 @@ /Zm162 %(AdditionalOptions) MaxSpeed - ../..;../../include;%(AdditionalIncludeDirectories) + ../../include;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) Default MultiThreadedDLL diff --git a/doc/changelog.qbk b/doc/changelog.qbk index f5dcd63..87bec51 100644 --- a/doc/changelog.qbk +++ b/doc/changelog.qbk @@ -11,6 +11,7 @@ Not yet released * Fixed missing thread synchronization in mock::sequence +* Fixed build errors with Boost 1.59 [endsect] diff --git a/include/turtle/constraints.hpp b/include/turtle/constraints.hpp index bc7ea28..6a814a2 100644 --- a/include/turtle/constraints.hpp +++ b/include/turtle/constraints.hpp @@ -13,7 +13,9 @@ #include "constraint.hpp" #include "detail/addressof.hpp" #include +#include #include +#include #include #include @@ -30,30 +32,73 @@ namespace mock MOCK_NARY_CONSTRAINT( less_equal, 1, ( expected ), actual <= expected ) MOCK_NARY_CONSTRAINT( greater_equal, 1, ( expected ), actual >= expected ) +#if BOOST_VERSION < 105900 + +# define MOCK_SMALL() \ + boost::test_tools::check_is_small( actual, tolerance ) +# define MOCK_PERCENT_TOLERANCE() \ + boost::test_tools::check_is_close( \ + actual, \ + expected, \ + boost::test_tools::percent_tolerance( tolerance ) ) +# define MOCK_FRACTION_TOLERANCE() \ + boost::test_tools::check_is_close( \ + actual, \ + expected, \ + boost::test_tools::fraction_tolerance( tolerance ) ) + +#else // BOOST_VERSION < 105900 + +namespace detail +{ + template< typename T, typename Tolerance > + bool is_small( const T& t, const Tolerance& tolerance ) + { + return boost::math::fpc::small_with_tolerance< T >( tolerance )( t ); + } + + template< typename T1, typename T2, typename Tolerance > + bool is_close( const T1& t1, const T2& t2, const Tolerance& tolerance ) + { + typedef typename boost::common_type< T1, T2 >::type common_type; + return boost::math::fpc::close_at_tolerance< common_type >( + tolerance, boost::math::fpc::FPC_STRONG )( t1, t2 ); + } +} + +# define MOCK_SMALL() \ + detail::is_small( actual, tolerance ) +# define MOCK_PERCENT_TOLERANCE() \ + detail::is_close( actual, expected, boost::math::fpc::percent_tolerance( tolerance ) ) +# define MOCK_FRACTION_TOLERANCE() \ + detail::is_close( actual, expected, tolerance ) + +#endif // BOOST_VERSION < 105900 + #ifdef BOOST_MSVC # pragma push_macro( "small" ) # undef small #endif - MOCK_NARY_CONSTRAINT( small, 1, ( expected ), \ - ( boost::test_tools::check_is_small( actual, expected ) ) ) + MOCK_NARY_CONSTRAINT( small, 1, ( tolerance ), + ( MOCK_SMALL() ) ) #ifdef BOOST_MSVC # pragma pop_macro( "small" ) #endif - MOCK_NARY_CONSTRAINT( close, 2, ( expected, tolerance ), \ - ( boost::test_tools::check_is_close( \ - actual, expected, \ - boost::test_tools::percent_tolerance( tolerance ) ) ) ) - MOCK_NARY_CONSTRAINT( close_fraction, 2, ( expected, tolerance ), \ - ( boost::test_tools::check_is_close( \ - actual, expected, \ - boost::test_tools::fraction_tolerance( tolerance ) ) ) ) + MOCK_NARY_CONSTRAINT( close, 2, ( expected, tolerance ), + ( MOCK_PERCENT_TOLERANCE() ) ) + + MOCK_NARY_CONSTRAINT( close_fraction, 2, ( expected, tolerance ), + ( MOCK_FRACTION_TOLERANCE() ) ) + +#undef MOCK_PERCENT_TOLERANCE +#undef MOCK_FRACTION_TOLERANCE #ifdef BOOST_MSVC # pragma push_macro( "near" ) # undef near #endif - MOCK_NARY_CONSTRAINT( near, 2, ( expected, tolerance ), \ + MOCK_NARY_CONSTRAINT( near, 2, ( expected, tolerance ), std::abs( actual - expected ) < tolerance ) #ifdef BOOST_MSVC # pragma pop_macro( "near" ) diff --git a/include/turtle/detail/cleanup.hpp b/include/turtle/detail/cleanup.hpp index ca5d212..87cc5fb 100644 --- a/include/turtle/detail/cleanup.hpp +++ b/include/turtle/detail/cleanup.hpp @@ -28,7 +28,7 @@ namespace detail mock::reset(); } }; - BOOST_GLOBAL_FIXTURE( cleanup ) + BOOST_GLOBAL_FIXTURE( cleanup ); } } // mock diff --git a/include/turtle/error.hpp b/include/turtle/error.hpp index 7b04ad3..95be42c 100644 --- a/include/turtle/error.hpp +++ b/include/turtle/error.hpp @@ -12,6 +12,7 @@ #include "config.hpp" #ifdef MOCK_USE_BOOST_TEST #include "exception.hpp" +#include #include #include #include @@ -39,7 +40,13 @@ namespace mock static void fail( const char* message, const Context& context, const char* file = "unknown location", int line = 0 ) { - boost::unit_test::framework::assertion_result( false ); + boost::unit_test::framework::assertion_result( +#if BOOST_VERSION < 105900 + false +#else + boost::unit_test::AR_FAILED +#endif + ); boost::unit_test::unit_test_log << boost::unit_test::log::begin( file, static_cast< std::size_t >( line ) ) @@ -51,7 +58,13 @@ namespace mock template< typename Context > static void call( const Context& context, const char* file, int line ) { - boost::unit_test::framework::assertion_result( true ); + boost::unit_test::framework::assertion_result( +#if BOOST_VERSION < 105900 + true +#else + boost::unit_test::AR_PASSED +#endif + ); boost::unit_test::unit_test_log << boost::unit_test::log::begin( file, static_cast< std::size_t >( line ) ) diff --git a/test/Jamfile.jam b/test/Jamfile.jam index 274f689..8bc7a52 100644 --- a/test/Jamfile.jam +++ b/test/Jamfile.jam @@ -30,7 +30,7 @@ rule run-test ( name ) run $(name) undefined.cpp /boost//unit_test_framework : : : MOCK_USE_CONVERSIONS : $(name)_use_conversions ; run $(name) undefined.cpp /boost//unit_test_framework : : : MOCK_NO_DECLTYPE : $(name)_no_decltype ; run $(name) undefined.cpp /boost//unit_test_framework : : : MOCK_NO_VARIADIC_MACROS : $(name)_no_variadic_macros ; - run $(name) undefined.cpp /boost//unit_test_framework /boost//thread : : : MOCK_THREAD_SAFE BOOST_THREAD_USES_MOVE : $(name)_thread_safe ; + run $(name) undefined.cpp /boost//unit_test_framework /boost//thread : : : MOCK_THREAD_SAFE BOOST_THREAD_USES_MOVE multi : $(name)_thread_safe ; } rule run-tests