Merged logging branch

git-svn-id: https://svn.code.sf.net/p/turtle/code/trunk@245 860be788-9bd5-4423-9f1e-828f051e677b
This commit is contained in:
mat007 2011-02-19 22:10:22 +00:00
parent 4450ea0330
commit 171accfe27
30 changed files with 1025 additions and 434 deletions

View file

@ -8,10 +8,9 @@
#include <turtle/format.hpp>
#include <boost/assign.hpp>
#include <ostream>
#include <vector>
#include <deque>
#include <list>
#include <vector>
#include <map>
#include <set>
@ -21,8 +20,6 @@
namespace
{
struct non_serializable_type {};
template< typename T >
std::string to_string( T t )
{
@ -32,65 +29,92 @@ namespace
}
}
BOOST_AUTO_TEST_CASE( type_not_serializable_in_standard_stream_yields_an_interrogation_mark_when_serialized )
{
BOOST_CHECK_EQUAL( "?", to_string( non_serializable_type() ) );
}
BOOST_AUTO_TEST_CASE( base_type_serializable_in_standard_stream_yields_its_value_when_serialized )
{
BOOST_CHECK_EQUAL( "42", to_string( 42 ) );
}
namespace
{
struct serializable_type {};
std::ostream& operator<<( std::ostream& s, const serializable_type& )
{
return s << "serializable_type";
}
struct non_serializable
{};
}
BOOST_AUTO_TEST_CASE( custom_type_serializable_in_standard_stream_yields_its_value_when_serialized )
BOOST_AUTO_TEST_CASE( non_serializable_type_yields_an_interrogation_mark_when_serialized )
{
BOOST_CHECK_EQUAL( "serializable_type", to_string( serializable_type() ) );
}
namespace
{
struct convertible_to_int
{
operator int() const { return 12; }
};
}
BOOST_AUTO_TEST_CASE( custom_type_convertible_to_base_type_yields_an_interrogation_mark_when_serialized )
{
BOOST_CHECK_EQUAL( "?", to_string( convertible_to_int() ) );
BOOST_CHECK_EQUAL( "?", to_string( non_serializable() ) );
}
namespace
{
struct serializable
{};
std::ostream& operator<<( std::ostream& s, const serializable& )
{
friend std::ostream& operator<<( std::ostream& s, const serializable& )
{
return s << "serializable";
}
};
struct convertible_to_serializable
{
operator serializable() const { return serializable(); }
};
return s << "serializable";
}
}
BOOST_AUTO_TEST_CASE( custom_type_convertible_to_another_type_serializable_in_standard_stream_yields_an_interrogation_mark_when_serialized )
BOOST_AUTO_TEST_CASE( serializable_type_yields_its_value_when_serialized )
{
BOOST_CHECK_EQUAL( "?", to_string( convertible_to_serializable() ) );
BOOST_CHECK_EQUAL( "serializable", to_string( serializable() ) );
}
BOOST_AUTO_TEST_CASE( booleans_are_serialized_as_booleans )
namespace
{
struct formattable {};
std::ostream& operator<<( std::ostream& s, const formattable& )
{
BOOST_FAIL( "should not be called" );
return s;
}
}
BOOST_AUTO_TEST_CASE( format_overrides_standard_stream_serialization_even_if_defined_after_being_used )
{
BOOST_CHECK_EQUAL( "formattable", to_string( formattable() ) );
}
namespace
{
void format( std::ostream& s, const formattable& )
{
s << "formattable";
}
}
namespace
{
struct formatterable {};
std::ostream& operator<<( std::ostream& s, const formatterable& )
{
BOOST_FAIL( "should not be called" );
return s;
}
void format( std::ostream&, const formatterable& )
{
BOOST_FAIL( "should not be called" );
}
}
BOOST_AUTO_TEST_CASE( formatter_overrides_standard_stream_serialization_and_format_even_if_defined_after_being_used )
{
BOOST_CHECK_EQUAL( "formatterable", to_string( formatterable() ) );
}
namespace
{
std::ostream& operator<<( std::ostream& s, const mock::formatter< formatterable >& )
{
return s << "formatterable";
}
}
BOOST_AUTO_TEST_CASE( base_type_yields_its_value_when_serialized )
{
BOOST_CHECK_EQUAL( "42", to_string( 42 ) );
}
BOOST_AUTO_TEST_CASE( booleans_are_serialized_as_bool_alpha )
{
BOOST_CHECK_EQUAL( "true", to_string( true ) );
BOOST_CHECK_EQUAL( "false", to_string( false ) );

View file

@ -20,11 +20,12 @@
#define CHECK_CALLS( calls ) \
BOOST_CHECK_EQUAL( calls, expected_call_count ); \
expected_call_count = 0;
#define CHECK_ERROR( expr, error, calls ) \
#define CHECK_ERROR( expr, error, calls, context ) \
BOOST_CHECK( verify() ); \
expr; \
BOOST_CHECK_EQUAL( 1, error##_count ); \
CHECK_CALLS( calls ); \
BOOST_CHECK_EQUAL( context, last_context ); \
reset();
namespace
@ -48,6 +49,7 @@ namespace
sequence_failed_count = 0;
verification_failed_count = 0;
untriggered_expectation_count = 0;
last_context.clear();
}
bool verify() const
{
@ -87,11 +89,11 @@ BOOST_FIXTURE_TEST_CASE( triggering_an_unconfigured_function_calls_unexpected_ca
{
{
mock::function< void() > f;
CHECK_ERROR( f(), unexpected_call, 0 );
CHECK_ERROR( f(), unexpected_call, 0, "?()" );
}
{
mock::function< int( int, const std::string& ) > f;
CHECK_ERROR( f( 1, "s" ), unexpected_call, 0 );
CHECK_ERROR( f( 1, "s" ), unexpected_call, 0, "?( 1, \"s\" )" );
}
}
@ -100,12 +102,12 @@ BOOST_FIXTURE_TEST_CASE( triggering_a_never_expectation_calls_unexpected_call_er
{
mock::function< void() > f;
f.expect().never();
CHECK_ERROR( f(), unexpected_call, 0 );
CHECK_ERROR( f(), unexpected_call, 0, "?()\nv never()" );
}
{
mock::function< int( int, const std::string& ) > f;
f.expect().never();
CHECK_ERROR( f( 1, "s" ), unexpected_call, 0 );
CHECK_ERROR( f( 1, "s" ), unexpected_call, 0, "?( 1, \"s\" )\nv never().with( any, any )" );
}
}
@ -133,13 +135,13 @@ BOOST_FIXTURE_TEST_CASE( triggering_a_once_expectation_calls_unexpected_call_err
mock::function< void() > f;
f.expect().once();
f();
CHECK_ERROR( f(), unexpected_call, 1 );
CHECK_ERROR( f(), unexpected_call, 1, "?()\nv once()" );
}
{
mock::function< void( int, const std::string& ) > f;
f.expect().once();
f( 1, "s" );
CHECK_ERROR( f( 1, "s" ), unexpected_call, 1 );
CHECK_ERROR( f( 1, "s" ), unexpected_call, 1, "?( 1, \"s\" )\nv once().with( any, any )" );
}
}
@ -206,12 +208,12 @@ BOOST_FIXTURE_TEST_CASE( verifying_a_once_expectation_before_the_call_fails, err
{
mock::function< void() > f;
f.expect().once();
CHECK_ERROR( BOOST_CHECK( ! f.verify() ), verification_failed, 0 );
CHECK_ERROR( BOOST_CHECK( ! f.verify() ), verification_failed, 0, "?\n. once()" );
}
{
mock::function< int( int, const std::string& ) > f;
f.expect().once();
CHECK_ERROR( BOOST_CHECK( ! f.verify() ), verification_failed, 0 );
CHECK_ERROR( BOOST_CHECK( ! f.verify() ), verification_failed, 0, "?\n. once().with( any, any )" );
}
}
@ -223,13 +225,13 @@ BOOST_FIXTURE_TEST_CASE( triggering_a_reset_function_calls_unexpected_call_error
mock::function< void() > f;
f.expect();
f.reset();
CHECK_ERROR( f(), unexpected_call, 0 );
CHECK_ERROR( f(), unexpected_call, 0, "?()" );
}
{
mock::function< int( int, const std::string& ) > f;
f.expect();
f.reset();
CHECK_ERROR( f( 1, "s" ), unexpected_call, 0 );
CHECK_ERROR( f( 1, "s" ), unexpected_call, 0, "?( 1, \"s\" )" );
}
}
@ -256,12 +258,12 @@ BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_with_wrong_parameter_value_in
{
mock::function< void( int ) > f;
f.expect().with( 42 );
CHECK_ERROR( f( 43 ), unexpected_call, 0 );
CHECK_ERROR( f( 43 ), unexpected_call, 0, "?( 43 )\n. unlimited().with( 42 )" );
}
{
mock::function< int( int, const std::string& ) > f;
f.expect().with( 42, "expected" );
CHECK_ERROR( f( 42, "actual" ), unexpected_call, 0 );
CHECK_ERROR( f( 42, "actual" ), unexpected_call, 0, "?( 42, \"actual\" )\n. unlimited().with( 42, \"expected\" )" );
}
}
@ -271,7 +273,7 @@ BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_with_wrong_parameter_value_in
f.expect().with( mock::equal( 42 ) || mock::less( 42 ) );
f( 41 );
f( 42 );
CHECK_ERROR( f( 43 ), unexpected_call, 2 );
CHECK_ERROR( f( 43 ), unexpected_call, 2, "?( 43 )\n. unlimited().with( ( equal( 42 ) || less( 42 ) ) )" );
}
BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_with_wrong_parameter_value_in_equal_and_not_less_constraint_calls_unexpected_call_error, error_fixture )
@ -279,7 +281,7 @@ BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_with_wrong_parameter_value_in
mock::function< void( int ) > f;
f.expect().with( mock::equal( 42 ) && ! mock::less( 41 ) );
f( 42 );
CHECK_ERROR( f( 43 ), unexpected_call, 1 );
CHECK_ERROR( f( 43 ), unexpected_call, 1, "?( 43 )\n. unlimited().with( ( equal( 42 ) && ! less( 41 ) ) )" );
}
namespace
@ -328,24 +330,22 @@ BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_with_failing_custom_constrain
{
mock::function< void( int ) > f;
f.expect().with( &custom_constraint );
CHECK_ERROR( f( 42 ), unexpected_call, 0 );
CHECK_ERROR( f( 42 ), unexpected_call, 0, "?( 42 )\n. unlimited().with( ? )" );
}
{
mock::function< int( int, const std::string& ) > f;
f.expect().with( &custom_constraint, "actual" );
CHECK_ERROR( f( 42, "actual" ), unexpected_call, 0 );
CHECK_ERROR( f( 42, "actual" ), unexpected_call, 0, "?( 42, \"actual\" )\n. unlimited().with( ?, \"actual\" )" );
}
}
/*
BOOST_FIXTURE_TEST_CASE( literal_zero_can_be_used_in_place_of_null_pointers_in_constraints, error_fixture )
{
mock::function< void( int* ) > f;
f.expect().with( 0 );
f.reset();
CHECK_CALLS( 1 );
}
*/
//BOOST_FIXTURE_TEST_CASE( literal_zero_can_be_used_in_place_of_null_pointers_in_constraints, error_fixture )
//{
// mock::function< void( int* ) > f;
// f.expect().with( 0 );
// f.reset();
// CHECK_CALLS( 1 );
//}
// result handling
@ -354,17 +354,17 @@ BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_with_no_return_set_calls_miss
{
mock::function< int() > f;
f.expect();
CHECK_ERROR( f(), missing_action, 0 );
CHECK_ERROR( f(), missing_action, 0, "?()\n. unlimited()" );
}
{
mock::function< int&() > f;
f.expect();
CHECK_ERROR( f(), missing_action, 0 );
CHECK_ERROR( f(), missing_action, 0, "?()\n. unlimited()" );
}
{
mock::function< const std::string&() > f;
f.expect();
CHECK_ERROR( f(), missing_action, 0 );
CHECK_ERROR( f(), missing_action, 0, "?()\n. unlimited()" );
}
}
@ -582,7 +582,7 @@ BOOST_FIXTURE_TEST_CASE( expecting_twice_a_single_expectation_makes_it_callable_
f.expect().once();
f();
f();
CHECK_ERROR( f(), unexpected_call, 2 );
CHECK_ERROR( f(), unexpected_call, 2, "?()\nv once()\nv once()" );
}
{
mock::function< void( const std::string& ) > f;
@ -590,7 +590,7 @@ BOOST_FIXTURE_TEST_CASE( expecting_twice_a_single_expectation_makes_it_callable_
f.expect().once().with( "second" );
f( "first" );
f( "second" );
CHECK_ERROR( f( "third"), unexpected_call, 2 );
CHECK_ERROR( f( "third"), unexpected_call, 2, "?( \"third\" )\nv once().with( \"first\" )\nv once().with( \"second\" )" );
}
}
@ -602,7 +602,7 @@ BOOST_FIXTURE_TEST_CASE( best_expectation_is_selected_first, error_fixture )
f.expect().once().with( 2 );
f( 2 );
f( 1 );
CHECK_ERROR( f( 3 ), unexpected_call, 2 );
CHECK_ERROR( f( 3 ), unexpected_call, 2, "?( 3 )\nv once().with( 1 )\nv once().with( 2 )" );
}
{
mock::function< void( const std::string& ) > f;
@ -610,7 +610,7 @@ BOOST_FIXTURE_TEST_CASE( best_expectation_is_selected_first, error_fixture )
f.expect().once().with( "second" );
f( "second" );
f( "first" );
CHECK_ERROR( f( "third"), unexpected_call, 2 );
CHECK_ERROR( f( "third"), unexpected_call, 2, "?( \"third\" )\nv once().with( \"first\" )\nv once().with( \"second\" )" );
}
}
@ -714,28 +714,28 @@ BOOST_FIXTURE_TEST_CASE( expectation_with_remaining_untriggered_matches_upon_des
{
std::auto_ptr< mock::function< void() > > f( new mock::function< void() > );
f->expect().once();
CHECK_ERROR( f.reset(), untriggered_expectation, 0 );
CHECK_ERROR( f.reset(), untriggered_expectation, 0, "?\n. once()" );
}
BOOST_FIXTURE_TEST_CASE( verifying_expectation_with_remaining_matches_disables_the_automatic_verification_upon_destruction, error_fixture )
{
mock::function< void() > f;
f.expect().once();
CHECK_ERROR( f.verify(), verification_failed, 0 );
CHECK_ERROR( f.verify(), verification_failed, 0, "?\n. once()" );
}
BOOST_FIXTURE_TEST_CASE( triggering_unexpected_call_call_disables_the_automatic_verification_upon_destruction, error_fixture )
{
mock::function< void() > f;
CHECK_ERROR( f(), unexpected_call, 0 );
CHECK_ERROR( f(), unexpected_call, 0, "?()" );
}
BOOST_FIXTURE_TEST_CASE( adding_a_expectation_reactivates_the_verification_upon_destruction, error_fixture )
{
std::auto_ptr< mock::function< void() > > f( new mock::function< void() > );
CHECK_ERROR( (*f)(), unexpected_call, 0 );
CHECK_ERROR( (*f)(), unexpected_call, 0, "?()" );
f->expect().once();
CHECK_ERROR( f.reset(), untriggered_expectation, 0 );
CHECK_ERROR( f.reset(), untriggered_expectation, 0, "?\n. once()" );
}
BOOST_FIXTURE_TEST_CASE( throwing_an_exception_disables_the_automatic_verification_upon_destruction, error_fixture )

View file

@ -329,6 +329,41 @@ BOOST_AUTO_TEST_CASE( boost_optional_on_base_class_reference_as_return_type_is_s
b.method();
}
namespace
{
bool serialized = false;
struct custom_argument
{
friend std::ostream& operator<<( std::ostream& s, const custom_argument& )
{
serialized = true;
return s;
}
};
struct custom_constraint
{
template< typename Actual >
bool operator()( Actual ) const
{
return true;
}
friend std::ostream& operator<<( std::ostream& s, const custom_constraint& )
{
serialized = true;
return s;
}
};
}
BOOST_AUTO_TEST_CASE( constraints_and_arguments_are_serialized_lazily )
{
MOCK_FUNCTOR( void( custom_argument ) ) f;
MOCK_EXPECT( f, _ ).with( custom_constraint() );
f( custom_argument() );
BOOST_CHECK( ! serialized );
}
namespace
{
template< typename Expected >

View file

@ -0,0 +1,72 @@
//
// Copyright Mathieu Champlon 2011
//
// 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)
//
#include <turtle/is_comparable.hpp>
#include <boost/test/auto_unit_test.hpp>
#define BOOST_LIB_NAME boost_unit_test_framework
#include <boost/config/auto_link.hpp>
namespace
{
struct declared_but_not_defined;
struct non_comparable
{};
struct comparable
{};
bool operator==( const comparable&, int );
bool operator==( int, const comparable& );
struct derived_from_comparable : comparable
{};
struct convertible_to_comparable
{
operator comparable() const;
};
template< typename T >
struct template_comparable
{};
template< typename T >
bool operator==( const template_comparable< T >&, int );
template< typename T >
bool operator==( int, const template_comparable< T >& );
struct comparable_to_everything
{
template< typename T >
bool operator==( const T& ) const;
};
}
BOOST_MPL_ASSERT_NOT(( mock::detail::is_comparable< int, declared_but_not_defined > ));
BOOST_MPL_ASSERT_NOT(( mock::detail::is_comparable< declared_but_not_defined, int > ));
BOOST_MPL_ASSERT_NOT(( mock::detail::is_comparable< int, non_comparable > ));
BOOST_MPL_ASSERT_NOT(( mock::detail::is_comparable< non_comparable, int > ));
BOOST_MPL_ASSERT(( mock::detail::is_comparable< int, comparable > ));
BOOST_MPL_ASSERT(( mock::detail::is_comparable< int, comparable& > ));
BOOST_MPL_ASSERT(( mock::detail::is_comparable< int, const comparable& > ));
BOOST_MPL_ASSERT(( mock::detail::is_comparable< comparable, int > ));
BOOST_MPL_ASSERT(( mock::detail::is_comparable< const comparable&, int > ));
BOOST_MPL_ASSERT(( mock::detail::is_comparable< int, template_comparable< int > > ));
BOOST_MPL_ASSERT(( mock::detail::is_comparable< template_comparable< int >, int > ));
BOOST_MPL_ASSERT(( mock::detail::is_comparable< int, derived_from_comparable > ));
BOOST_MPL_ASSERT(( mock::detail::is_comparable< derived_from_comparable, int > ));
BOOST_MPL_ASSERT(( mock::detail::is_comparable< int, convertible_to_comparable > ));
BOOST_MPL_ASSERT(( mock::detail::is_comparable< convertible_to_comparable, int > ));
BOOST_MPL_ASSERT_NOT(( mock::detail::is_comparable< int, comparable_to_everything > ));
BOOST_MPL_ASSERT(( mock::detail::is_comparable< comparable_to_everything, int > ));

View file

@ -0,0 +1,61 @@
//
// Copyright Mathieu Champlon 2011
//
// 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)
//
#include <turtle/is_formattable.hpp>
#include <boost/test/auto_unit_test.hpp>
#define BOOST_LIB_NAME boost_unit_test_framework
#include <boost/config/auto_link.hpp>
BOOST_STATIC_ASSERT(( ! mock::detail::is_formattable< std::ostream, int >::value ));
namespace
{
struct non_formattable {};
}
BOOST_STATIC_ASSERT(( ! mock::detail::is_formattable< std::ostream, non_formattable >::value ));
namespace
{
struct formattable {};
void format( std::ostream&, const formattable& );
}
BOOST_STATIC_ASSERT(( mock::detail::is_formattable< std::ostream, formattable >::value ));
namespace nm
{
struct formattable {};
}
namespace mock
{
void format( std::ostream&, nm::formattable );
}
BOOST_STATIC_ASSERT(( mock::detail::is_formattable< std::ostream, nm::formattable >::value ));
namespace
{
struct derived_from_formattable : formattable
{};
}
BOOST_STATIC_ASSERT(( mock::detail::is_formattable< std::ostream, derived_from_formattable >::value ));
namespace
{
struct convertible_to_formattable
{
operator formattable() const;
};
}
BOOST_STATIC_ASSERT(( mock::detail::is_formattable< std::ostream, convertible_to_formattable >::value ));

View file

@ -10,12 +10,12 @@
#include <boost/function.hpp>
#include <boost/bind.hpp>
#ifdef _MSC_VER
# pragma warning( push, 0 )
#pragma warning( push, 0 )
#endif
#include <boost/lambda/lambda.hpp>
#include <boost/spirit/home/phoenix.hpp>
#ifdef _MSC_VER
# pragma warning( pop )
#pragma warning( pop )
#endif
#include <boost/test/auto_unit_test.hpp>
@ -24,12 +24,13 @@
namespace
{
BOOST_STATIC_ASSERT( sizeof( mock::detail::yes_type ) != sizeof( mock::detail::no_type ) );
struct declared_but_not_defined;
BOOST_MPL_ASSERT_NOT(( mock::detail::is_functor< declared_but_not_defined > ));
template< typename T >
void check( T )
{
BOOST_STATIC_ASSERT(( mock::detail::is_functor< T >::type::value ));
BOOST_MPL_ASSERT(( mock::detail::is_functor< T > ));
}
void f0 () {}

View file

@ -0,0 +1,91 @@
//
// Copyright Mathieu Champlon 2011
//
// 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)
//
#include <turtle/is_serializable.hpp>
#include <boost/static_assert.hpp>
#include <boost/test/auto_unit_test.hpp>
#define BOOST_LIB_NAME boost_unit_test_framework
#include <boost/config/auto_link.hpp>
BOOST_STATIC_ASSERT(( mock::detail::protect::is_serializable< std::ostream, int >::value ));
BOOST_STATIC_ASSERT(( mock::detail::protect::is_serializable< std::ostream, std::string >::value ));
namespace
{
struct declared_but_not_defined;
}
BOOST_STATIC_ASSERT(( ! mock::detail::protect::is_serializable< std::ostream, declared_but_not_defined >::value ));
namespace
{
struct non_serializable
{};
}
BOOST_STATIC_ASSERT(( ! mock::detail::protect::is_serializable< std::ostream, non_serializable >::value ));
namespace
{
struct serializable
{};
std::ostream& operator<<( std::ostream& s, const serializable& );
}
BOOST_STATIC_ASSERT(( mock::detail::protect::is_serializable< std::ostream, serializable >::value ));
namespace
{
template< typename T >
struct template_serializable {};
template< typename T >
std::ostream& operator<<( std::ostream& s, const template_serializable< T >& );
}
BOOST_STATIC_ASSERT(( mock::detail::protect::is_serializable< std::ostream, template_serializable< int > >::value ));
namespace
{
struct convertible_to_base
{
operator int() const;
};
}
BOOST_STATIC_ASSERT(( mock::detail::protect::is_serializable< std::ostream, convertible_to_base >::value ));
namespace
{
struct convertible_to_string
{
operator std::string() const;
};
}
BOOST_STATIC_ASSERT(( ! mock::detail::protect::is_serializable< std::ostream, convertible_to_string >::value ));
namespace
{
struct convertible_to_serializable
{
operator serializable() const;
};
}
BOOST_STATIC_ASSERT(( mock::detail::protect::is_serializable< std::ostream, convertible_to_serializable >::value ));
namespace
{
struct derived_from_serializable : serializable
{};
}
BOOST_STATIC_ASSERT(( mock::detail::protect::is_serializable< std::ostream, derived_from_serializable >::value ));

View file

@ -10,6 +10,7 @@
#define MOCK_TEST_MOCK_ERROR_HPP_INCLUDED
#include <boost/type_traits/remove_reference.hpp>
#include <boost/lexical_cast.hpp>
#include <string>
namespace
@ -20,6 +21,8 @@ namespace
int sequence_failed_count = 0;
int verification_failed_count = 0;
int untriggered_expectation_count = 0;
std::string last_context;
}
namespace mock
{
@ -32,33 +35,45 @@ namespace mock
return r;
}
static void missing_action( const std::string& /*context*/,
template< typename Context >
static void missing_action( const Context& context,
const std::string& /*file*/, int /*line*/ )
{
last_context = boost::lexical_cast< std::string >( context );
++missing_action_count;
}
static void expected_call( const std::string& /*context*/,
template< typename Context >
static void expected_call( const Context& context,
const std::string& /*file*/, int /*line*/ )
{
last_context = boost::lexical_cast< std::string >( context );
++expected_call_count;
}
static void unexpected_call( const std::string& /*context*/ )
template< typename Context >
static void unexpected_call( const Context& context )
{
last_context = boost::lexical_cast< std::string >( context );
++unexpected_call_count;
}
static void sequence_failed( const std::string& /*context*/,
template< typename Context >
static void sequence_failed( const Context& context,
const std::string& /*file*/, int /*line*/ )
{
last_context = boost::lexical_cast< std::string >( context );
++sequence_failed_count;
}
static void verification_failed( const std::string& /*context*/,
template< typename Context >
static void verification_failed( const Context& context,
const std::string& /*file*/, int /*line*/ )
{
last_context = boost::lexical_cast< std::string >( context );
++verification_failed_count;
}
static void untriggered_expectation( const std::string& /*context*/,
template< typename Context >
static void untriggered_expectation( const Context& context,
const std::string& /*file*/, int /*line*/ )
{
last_context = boost::lexical_cast< std::string >( context );
++untriggered_expectation_count;
}
};
@ -67,33 +82,45 @@ namespace mock
{
static void abort()
{}
static void missing_action( const std::string& /*context*/,
template< typename Context >
static void missing_action( const Context& context,
const std::string& /*file*/, int /*line*/ )
{
last_context = boost::lexical_cast< std::string >( context );
++missing_action_count;
}
static void expected_call( const std::string& /*context*/,
template< typename Context >
static void expected_call( const Context& context,
const std::string& /*file*/, int /*line*/ )
{
last_context = boost::lexical_cast< std::string >( context );
++expected_call_count;
}
static void unexpected_call( const std::string& /*context*/ )
template< typename Context >
static void unexpected_call( const Context& context )
{
last_context = boost::lexical_cast< std::string >( context );
++unexpected_call_count;
}
static void sequence_failed( const std::string& /*context*/,
template< typename Context >
static void sequence_failed( const Context& context,
const std::string& /*file*/, int /*line*/ )
{
last_context = boost::lexical_cast< std::string >( context );
++sequence_failed_count;
}
static void verification_failed( const std::string& /*context*/,
template< typename Context >
static void verification_failed( const Context& context,
const std::string& /*file*/, int /*line*/ )
{
last_context = boost::lexical_cast< std::string >( context );
++verification_failed_count;
}
static void untriggered_expectation( const std::string& /*context*/,
template< typename Context >
static void untriggered_expectation( const Context& context,
const std::string& /*file*/, int /*line*/ )
{
last_context = boost::lexical_cast< std::string >( context );
++untriggered_expectation_count;
}
};

View file

@ -10,7 +10,6 @@
#define MOCK_TEST_SILENT_ERROR_HPP_INCLUDED
#include <string>
#include <sstream>
#include <stdexcept>
namespace mock
@ -22,21 +21,27 @@ namespace mock
{
throw std::runtime_error( "abort" );
}
static void expected_call( const std::string& /*context*/,
template< typename Context >
static void expected_call( const Context& /*context*/,
const std::string& /*file*/, int /*line*/ )
{}
static void unexpected_call( const std::string& /*context*/ )
template< typename Context >
static void unexpected_call( const Context& /*context*/ )
{}
static void missing_action( const std::string& /*context*/,
template< typename Context >
static void missing_action( const Context& /*context*/,
const std::string& /*file*/, int /*line*/ )
{}
static void sequence_failed( const std::string& /*context*/,
template< typename Context >
static void sequence_failed( const Context& /*context*/,
const std::string& /*file*/, int /*line*/ )
{}
static void verification_failed( const std::string& /*context*/,
template< typename Context >
static void verification_failed( const Context& /*context*/,
const std::string& /*file*/, int /*line*/ )
{}
static void untriggered_expectation( const std::string& /*context*/,
template< typename Context >
static void untriggered_expectation( const Context& /*context*/,
const std::string& /*file*/, int /*line*/ )
{}
};