diff --git a/doc/example/customization.cpp b/doc/example/customization.cpp index fcd1a78..d9f6cb7 100644 --- a/doc/example/customization.cpp +++ b/doc/example/customization.cpp @@ -87,7 +87,7 @@ struct near_constraint template< typename Actual > bool operator()( Actual actual ) const { - return std::abs( actual - mock::unwrap_ref(expected_) ) < mock::unwrap_ref(threshold_) ; + return std::abs( actual - mock::unwrap_ref(expected_) ) <= mock::unwrap_ref(threshold_) ; } friend std::ostream& operator<<( std::ostream& s, const near_constraint& c ) @@ -157,7 +157,8 @@ BOOST_AUTO_TEST_CASE( near_constraint_works_with_with_float_wrapper_and_cref ) MOCK_EXPECT( v.display ).once().with( near( std::cref( expected ), std::cref( threshold ) ) ); expected = 42; threshold = 1; - c.add( 41, 1 ); + c.add(0, 0); + c.add(41, 1); } } diff --git a/include/turtle/constraints.hpp b/include/turtle/constraints.hpp index af18b65..f29495a 100644 --- a/include/turtle/constraints.hpp +++ b/include/turtle/constraints.hpp @@ -106,7 +106,7 @@ namespace detail # define MOCK_NEAR_DEFINED #endif MOCK_NARY_CONSTRAINT( near, 2, ( expected, tolerance ), - std::abs( actual - expected ) < tolerance ) + std::abs( actual - expected ) <= tolerance ) #ifdef MOCK_NEAR_DEFINED # pragma pop_macro( "near" ) #endif