mirror of
https://github.com/mat007/turtle.git
synced 2026-06-22 12:13:43 +00:00
Added Boost.Test log info when an expectation is fulfilled
git-svn-id: https://svn.code.sf.net/p/turtle/code/trunk@164 860be788-9bd5-4423-9f1e-828f051e677b
This commit is contained in:
parent
e5513654af
commit
66268d74db
4 changed files with 30 additions and 0 deletions
|
|
@ -31,6 +31,8 @@ namespace mock
|
|||
{
|
||||
static Result abort()
|
||||
{
|
||||
boost::unit_test::framework::test_unit_aborted(
|
||||
boost::unit_test::framework::current_test_case() );
|
||||
throw boost::enable_current_exception( exception() );
|
||||
}
|
||||
|
||||
|
|
@ -47,6 +49,18 @@ namespace mock
|
|||
<< boost::unit_test::log::end();
|
||||
}
|
||||
|
||||
static void expected_call( const std::string& context,
|
||||
const std::string& file, int line )
|
||||
{
|
||||
boost::unit_test::framework::assertion_result( true );
|
||||
boost::unit_test::unit_test_log
|
||||
<< boost::unit_test::log::begin( file, (std::size_t)line )
|
||||
<< boost::unit_test::log_successful_tests
|
||||
<< boost::unit_test::lazy_ostream::instance()
|
||||
<< "mock expectation fulfilled: " << context
|
||||
<< boost::unit_test::log::end();
|
||||
}
|
||||
|
||||
#else // MOCK_USE_BOOST_TEST
|
||||
|
||||
struct exception
|
||||
|
|
@ -68,6 +82,10 @@ namespace mock
|
|||
<< "mock error: " << message << ": " << context << std::endl;
|
||||
}
|
||||
|
||||
static void expected_call( const std::string& /*context*/,
|
||||
const std::string& /*file*/, int /*line*/ )
|
||||
{}
|
||||
|
||||
#endif // MOCK_USE_BOOST_TEST
|
||||
|
||||
static void missing_action( const std::string& context,
|
||||
|
|
|
|||
|
|
@ -222,6 +222,7 @@ namespace mock
|
|||
ErrorPolicy::missing_action( MOCK_EXPECTATION_CONTEXT(n), it->file(), it->line() ); \
|
||||
return ErrorPolicy::abort(); \
|
||||
} \
|
||||
ErrorPolicy::expected_call( MOCK_EXPECTATION_CONTEXT(n), it->file(), it->line() ); \
|
||||
return it->functor()( BOOST_PP_ENUM_PARAMS(n, p) ); \
|
||||
} \
|
||||
valid_ = false; \
|
||||
|
|
@ -259,6 +260,8 @@ namespace mock
|
|||
it->file(), it->line() );
|
||||
return T::abort();
|
||||
}
|
||||
ErrorPolicy::expected_call( context( "" ),
|
||||
it->file(), it->line() );
|
||||
return it->functor()();
|
||||
}
|
||||
valid_ = false;
|
||||
|
|
|
|||
|
|
@ -36,6 +36,9 @@ namespace mock
|
|||
{
|
||||
++missing_action_count;
|
||||
}
|
||||
static void expected_call( const std::string& /*context*/,
|
||||
const std::string& /*file*/, int /*line*/ )
|
||||
{}
|
||||
static void unexpected_call( const std::string& /*context*/ )
|
||||
{
|
||||
++unexpected_call_count;
|
||||
|
|
@ -66,6 +69,9 @@ namespace mock
|
|||
{
|
||||
++missing_action_count;
|
||||
}
|
||||
static void expected_call( const std::string& /*context*/,
|
||||
const std::string& /*file*/, int /*line*/ )
|
||||
{}
|
||||
static void unexpected_call( const std::string& /*context*/ )
|
||||
{
|
||||
++unexpected_call_count;
|
||||
|
|
|
|||
|
|
@ -22,6 +22,9 @@ namespace mock
|
|||
{
|
||||
throw std::runtime_error( "abort" );
|
||||
}
|
||||
static void expected_call( const std::string& /*context*/,
|
||||
const std::string& /*file*/, int /*line*/ )
|
||||
{}
|
||||
static void unexpected_call( const std::string& /*context*/ )
|
||||
{}
|
||||
static void missing_action( const std::string& /*context*/,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue