Fixed build errors with Boost 1.59

This commit is contained in:
Mathieu Champlon 2015-09-04 22:56:29 +02:00
parent dd866ab895
commit 1ab35d8912
7 changed files with 95 additions and 23 deletions

View file

@ -13,7 +13,9 @@
#include "constraint.hpp"
#include "detail/addressof.hpp"
#include <boost/ref.hpp>
#include <boost/version.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/common_type.hpp>
#include <boost/type_traits/is_convertible.hpp>
#include <boost/test/floating_point_comparison.hpp>
@ -30,24 +32,67 @@ 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_PERCENT_TOLERANCE() ) )
MOCK_NARY_CONSTRAINT( close_fraction, 2, ( expected, tolerance ),
( boost::test_tools::check_is_close(
actual, expected,
boost::test_tools::fraction_tolerance( tolerance ) ) ) )
( MOCK_FRACTION_TOLERANCE() ) )
#undef MOCK_PERCENT_TOLERANCE
#undef MOCK_FRACTION_TOLERANCE
#ifdef BOOST_MSVC
# pragma push_macro( "near" )

View file

@ -28,7 +28,7 @@ namespace detail
mock::reset();
}
};
BOOST_GLOBAL_FIXTURE( cleanup )
BOOST_GLOBAL_FIXTURE( cleanup );
}
} // mock

View file

@ -12,6 +12,7 @@
#include "config.hpp"
#ifdef MOCK_USE_BOOST_TEST
#include "exception.hpp"
#include <boost/version.hpp>
#include <boost/test/framework.hpp>
#include <boost/test/test_tools.hpp>
#include <boost/test/unit_test_suite.hpp>
@ -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 ) )