mirror of
https://github.com/mat007/turtle.git
synced 2026-06-22 12:13:43 +00:00
Change the threshold param of near to be inclusive
I.e. it means the maximum allowed difference, similar to how other testing frameworks handle this and it allows a threshold of 0 to mean "equal"
This commit is contained in:
parent
e26601672e
commit
98541eb5a7
2 changed files with 4 additions and 3 deletions
|
|
@ -87,7 +87,7 @@ struct near_constraint
|
||||||
template< typename Actual >
|
template< typename Actual >
|
||||||
bool operator()( Actual actual ) const
|
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 )
|
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 ) ) );
|
MOCK_EXPECT( v.display ).once().with( near( std::cref( expected ), std::cref( threshold ) ) );
|
||||||
expected = 42;
|
expected = 42;
|
||||||
threshold = 1;
|
threshold = 1;
|
||||||
c.add( 41, 1 );
|
c.add(0, 0);
|
||||||
|
c.add(41, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -106,7 +106,7 @@ namespace detail
|
||||||
# define MOCK_NEAR_DEFINED
|
# define MOCK_NEAR_DEFINED
|
||||||
#endif
|
#endif
|
||||||
MOCK_NARY_CONSTRAINT( near, 2, ( expected, tolerance ),
|
MOCK_NARY_CONSTRAINT( near, 2, ( expected, tolerance ),
|
||||||
std::abs( actual - expected ) < tolerance )
|
std::abs( actual - expected ) <= tolerance )
|
||||||
#ifdef MOCK_NEAR_DEFINED
|
#ifdef MOCK_NEAR_DEFINED
|
||||||
# pragma pop_macro( "near" )
|
# pragma pop_macro( "near" )
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue