This commit is contained in:
Mathieu Champlon 2015-08-09 14:29:49 +00:00
commit 809d649a74
3 changed files with 9 additions and 2 deletions

View file

@ -11,6 +11,7 @@
Not yet released
* Fixed missing thread synchronization in mock::sequence
* Fixed crash when comparing null pointers to const char* arguments in matcher
[endsect]

View file

@ -48,7 +48,9 @@ namespace mock
{}
bool operator()( const char* actual )
{
return std::strcmp( actual, expected_ ) == 0;
return actual == expected_
|| actual && expected_
&& std::strcmp( actual, expected_ ) == 0;
}
friend std::ostream& operator<<(
std::ostream& s, const matcher& m )

View file

@ -54,7 +54,11 @@ BOOST_FIXTURE_TEST_CASE( const_char_pointer_and_const_char_pointer_can_be_compar
const char* expected = "same text";
BOOST_CHECK( match( expected, actual ) );
const char* unexpected = "different text";
BOOST_CHECK( ! match( actual, unexpected ) );
BOOST_CHECK( ! match( unexpected, actual ) );
const char* null = 0;
BOOST_CHECK( ! match( expected, null ) );
BOOST_CHECK( ! match( null, actual ) );
BOOST_CHECK( match( null, null ) );
}
BOOST_FIXTURE_TEST_CASE( const_char_pointer_and_string_literal_can_be_compared, fixture )