mirror of
https://github.com/mat007/turtle.git
synced 2026-06-22 12:13:43 +00:00
Fixed crash when comparing null pointers to const char* arguments in matcher
This commit is contained in:
parent
77a4816c56
commit
b40680a32a
3 changed files with 9 additions and 2 deletions
|
|
@ -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]
|
||||
|
||||
|
|
|
|||
|
|
@ -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 )
|
||||
|
|
|
|||
|
|
@ -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 )
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue