From d0bda7377830ac56d8e6f65a430f88e64934cf82 Mon Sep 17 00:00:00 2001 From: mat007 Date: Tue, 8 Dec 2009 21:52:51 +0000 Subject: [PATCH] Better error diagnostic git-svn-id: https://svn.code.sf.net/p/turtle/code/trunk@69 860be788-9bd5-4423-9f1e-828f051e677b --- src/tests/turtle_test/silent_error.hpp | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/tests/turtle_test/silent_error.hpp b/src/tests/turtle_test/silent_error.hpp index 631e526..8528ab6 100644 --- a/src/tests/turtle_test/silent_error.hpp +++ b/src/tests/turtle_test/silent_error.hpp @@ -10,26 +10,34 @@ #define MOCK_TEST_SILENT_ERROR_HPP_INCLUDED #include -#include +#include +#include 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*/ )