Better error diagnostic

git-svn-id: https://svn.code.sf.net/p/turtle/code/trunk@69 860be788-9bd5-4423-9f1e-828f051e677b
This commit is contained in:
mat007 2009-12-08 21:52:51 +00:00
parent a21ded7948
commit d0bda73778

View file

@ -10,26 +10,34 @@
#define MOCK_TEST_SILENT_ERROR_HPP_INCLUDED
#include <string>
#include <exception>
#include <sstream>
#include <stdexcept>
namespace mock
{
template< typename Result >
struct silent_error
{
static Result no_match( const std::string& /*context*/ )
static std::string to_string( int i )
{
throw std::exception();
std::stringstream s;
s << i;
return s.str();
}
static Result missing_result_specification( const std::string& /*context*/,
const std::string& /*file*/, int /*line*/ )
static Result no_match( const std::string& context )
{
throw std::exception();
throw std::runtime_error( "no_match : " + context );
}
static void sequence_failed( const std::string& /*context*/,
const std::string& /*file*/, int /*line*/ )
static Result missing_result_specification( const std::string& context,
const std::string& file, int line )
{
throw std::exception();
throw std::runtime_error( "missing_result_specification : " + context + " " + file + "(" + to_string( line ) + ")" );
}
static void sequence_failed( const std::string& context,
const std::string& file, int line )
{
throw std::runtime_error( "sequence_failed : " + context + " " + file + "(" + to_string( line ) + ")" );
}
static void verification_failed( const std::string& /*context*/,
const std::string& /*file*/, int /*line*/ )