My mock class looks like this:
struct StringEater {
MOCK_CONST_METHOD1( ExecuteCommand, void( const char* ) );
};
and the string consist of part that doesn't change, and small part that I can not set in test. Something like this :
Command 825 finished
but it can be
Command 123 finished
or "Command " + any number + " finished"
.
The method from the mock class is always called.
So, how do I set the test? This obviously can not be used:
StringEater mock;
EXPECT_CALL( mock, ExecuteCommand( StrEq( expectedJsonCmd ) ) ).Times( 1 );
What do I need to put for the matcher?
This works (thanks to J):
TEST( abc, some )
{
struct StringEater {
MOCK_CONST_METHOD1( ExecuteCommand, void( const char* ) );
};
StringEater eater;
EXPECT_CALL( eater, ExecuteCommand( MatchesRegex( "Command\\s([0-9]*)\\sfinished" ) ) ).Times( 1 );
eater.ExecuteCommand( "Command 643 finished" );
}