git-svn-id: https://svn.code.sf.net/p/turtle/code/trunk@156 860be788-9bd5-4423-9f1e-828f051e677b
This commit is contained in:
mat007 2010-05-08 08:34:07 +00:00
parent 5754f053d8
commit f9154334cf

View file

@ -26,15 +26,15 @@ namespace mock
struct exception : public boost::execution_aborted
{};
namespace detail
{
template< typename Result >
Result abort()
struct boost_test_error_policy
{
static Result abort()
{
throw boost::enable_current_exception( exception() );
}
inline void fail(
static void fail(
const std::string& message, const std::string& context,
const std::string& file = "unknown location", int line = 0 )
{
@ -46,70 +46,53 @@ namespace detail
<< "mock error: " << message << ": " << context
<< boost::unit_test::log::end();
}
}
template< typename Result >
struct boost_test_error_policy
{
#else // MOCK_USE_BOOST_TEST
struct exception
{};
namespace detail
{
template< typename Result >
Result abort()
struct basic_error_policy
{
static Result abort()
{
throw exception();
}
inline void fail(
static void fail(
const std::string& message, const std::string& context,
const std::string& file = "unknown location", int line = 0 )
{
std::cerr << file << '(' << line << "): "
<< "mock error: " << message << ": " << context << std::endl;
}
}
template< typename Result >
struct basic_error_policy
{
#endif // MOCK_USE_BOOST_TEST
static Result abort()
{
return mock::detail::abort< Result >();
}
static void missing_action( const std::string& context,
const std::string& file, int line )
{
mock::detail::fail( "missing action", context,
file, line );
fail( "missing action", context, file, line );
}
static void unexpected_call( const std::string& context )
{
mock::detail::fail( "unexpected call", context );
fail( "unexpected call", context );
}
static void sequence_failed( const std::string& context,
const std::string& /*file*/, int /*line*/ )
{
mock::detail::fail( "sequence failed", context );
fail( "sequence failed", context );
}
static void verification_failed( const std::string& context,
const std::string& file, int line )
{
mock::detail::fail( "verification failed", context, file, line );
fail( "verification failed", context, file, line );
}
static void untriggered_expectation( const std::string& context,
const std::string& file, int line )
{
mock::detail::fail( "untriggered expectation", context,
file, line );
fail( "untriggered expectation", context, file, line );
}
};
}