Added floating point comparison constraints

git-svn-id: https://svn.code.sf.net/p/turtle/code/trunk@659 860be788-9bd5-4423-9f1e-828f051e677b
This commit is contained in:
mat007 2013-05-20 10:49:09 +00:00
parent c8072405c8
commit 8a6edd531e
4 changed files with 56 additions and 11 deletions

View file

@ -16,6 +16,7 @@
#include <boost/utility/enable_if.hpp>
#include <boost/utility/addressof.hpp>
#include <boost/type_traits/is_convertible.hpp>
#include <boost/test/floating_point_comparison.hpp>
namespace mock
{
@ -30,6 +31,21 @@ namespace mock
MOCK_BINARY_CONSTRAINT( less_equal, actual <= expected )
MOCK_BINARY_CONSTRAINT( greater_equal, actual >= expected )
MOCK_BINARY_CONSTRAINT( small, \
( boost::test_tools::check_is_small( actual, expected ) ) );
MOCK_TERNARY_CONSTRAINT( close, \
( boost::test_tools::check_is_close( \
actual, expected, \
boost::test_tools::percent_tolerance( arg ) ) ) );
MOCK_TERNARY_CONSTRAINT( close_fraction, \
( boost::test_tools::check_is_close( \
actual, expected, \
boost::test_tools::fraction_tolerance( arg ) ) ) );
MOCK_TERNARY_CONSTRAINT( near, std::abs( actual - expected ) < arg );
namespace detail
{
template< typename Expected >