Error policy now customizable and missing result specifications now reported with file name and line

git-svn-id: https://svn.code.sf.net/p/turtle/code/trunk@67 860be788-9bd5-4423-9f1e-828f051e677b
This commit is contained in:
mat007 2009-11-24 22:45:27 +00:00
parent 51379e7844
commit 6ff9fc5564
14 changed files with 380 additions and 271 deletions

View file

@ -0,0 +1,79 @@
//
// Copyright Mathieu Champlon 2008
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef MOCK_TEST_MOCK_ERROR_HPP_INCLUDED
#define MOCK_TEST_MOCK_ERROR_HPP_INCLUDED
#include <boost/type_traits/remove_reference.hpp>
#include <string>
namespace
{
int missing_result_specification_count = 0;
int no_match_count = 0;
int sequence_failed_count = 0;
int verification_failed_count = 0;
int untriggered_expectation_count = 0;
}
namespace mock
{
template< typename Result >
struct mock_error
{
static Result missing_result_specification( const std::string& /*context*/, const std::string& /*file*/, int /*line*/ )
{
++missing_result_specification_count;
static BOOST_DEDUCED_TYPENAME boost::remove_reference< Result >::type r;
return r;
}
static Result no_match( const std::string& /*context*/ )
{
++no_match_count;
static BOOST_DEDUCED_TYPENAME boost::remove_reference< Result >::type r;
return r;
}
static void sequence_failed( const std::string& /*context*/, const std::string& /*file*/, int /*line*/ )
{
++sequence_failed_count;
}
static void verification_failed( const std::string& /*context*/, const std::string& /*file*/, int /*line*/ )
{
++verification_failed_count;
}
static void untriggered_expectation( const std::string& /*context*/, const std::string& /*file*/, int /*line*/ )
{
++untriggered_expectation_count;
}
};
template<>
struct mock_error< void >
{
static void missing_result_specification( const std::string& /*context*/, const std::string& /*file*/, int /*line*/ )
{
++missing_result_specification_count;
}
static void no_match( const std::string& /*context*/ )
{
++no_match_count;
}
static void sequence_failed( const std::string& /*context*/, const std::string& /*file*/, int /*line*/ )
{
++sequence_failed_count;
}
static void verification_failed( const std::string& /*context*/, const std::string& /*file*/, int /*line*/ )
{
++verification_failed_count;
}
static void untriggered_expectation( const std::string& /*context*/, const std::string& /*file*/, int /*line*/ )
{
++untriggered_expectation_count;
}
};
}
#endif // #ifndef MOCK_TEST_MOCK_ERROR_HPP_INCLUDED