From c71910ee542f58e3db0ef583b521602ff996b212 Mon Sep 17 00:00:00 2001 From: mat007 Date: Fri, 8 Apr 2011 21:32:33 +0000 Subject: [PATCH] More test traces to analyse git-svn-id: https://svn.code.sf.net/p/turtle/code/trunk@287 860be788-9bd5-4423-9f1e-828f051e677b --- build/build.xml | 11 ++++---- ...pp => constraint_value_not_comparable.cpp} | 8 +++--- ...ue_of_wrong_type_in_builtin_constraint.cpp | 22 +++++++++++++++ ...tom_constraint_call_operator_not_const.cpp | 27 +++++++++++++++++++ .../mismatch_type_in_returns_int_action.cpp | 22 +++++++++++++++ ...mismatch_type_in_returns_string_action.cpp | 22 +++++++++++++++ .../mismatch_type_in_returns_void_action.cpp | 22 +++++++++++++++ .../wrong_number_of_arguments_in_with.cpp | 22 +++++++++++++++ 8 files changed, 147 insertions(+), 9 deletions(-) rename src/tests/errors_test/{mismatch_type_in_returns_action.cpp => constraint_value_not_comparable.cpp} (58%) create mode 100644 src/tests/errors_test/constraint_value_of_wrong_type_in_builtin_constraint.cpp create mode 100644 src/tests/errors_test/custom_constraint_call_operator_not_const.cpp create mode 100644 src/tests/errors_test/mismatch_type_in_returns_int_action.cpp create mode 100644 src/tests/errors_test/mismatch_type_in_returns_string_action.cpp create mode 100644 src/tests/errors_test/mismatch_type_in_returns_void_action.cpp create mode 100644 src/tests/errors_test/wrong_number_of_arguments_in_with.cpp diff --git a/build/build.xml b/build/build.xml index 9acf571..ef66d5d 100644 --- a/build/build.xml +++ b/build/build.xml @@ -17,7 +17,7 @@ - + @@ -26,19 +26,20 @@ - - + + - + + ${file} - + diff --git a/src/tests/errors_test/mismatch_type_in_returns_action.cpp b/src/tests/errors_test/constraint_value_not_comparable.cpp similarity index 58% rename from src/tests/errors_test/mismatch_type_in_returns_action.cpp rename to src/tests/errors_test/constraint_value_not_comparable.cpp index 36fc444..96e8dac 100644 --- a/src/tests/errors_test/mismatch_type_in_returns_action.cpp +++ b/src/tests/errors_test/constraint_value_not_comparable.cpp @@ -10,13 +10,13 @@ namespace { - MOCK_CLASS( cl ) + MOCK_CLASS( my_class ) { - MOCK_METHOD_EXT( m, 0, int(), m ) // add another test with void() and another with std::string() + MOCK_METHOD_EXT( my_method, 0, void( int ), my_method ) }; void test_case() { - cl c; - MOCK_EXPECT( c, m ).returns( "42" ); + my_class c; + MOCK_EXPECT( c, my_method ).with( "42" ); } } diff --git a/src/tests/errors_test/constraint_value_of_wrong_type_in_builtin_constraint.cpp b/src/tests/errors_test/constraint_value_of_wrong_type_in_builtin_constraint.cpp new file mode 100644 index 0000000..117ecf3 --- /dev/null +++ b/src/tests/errors_test/constraint_value_of_wrong_type_in_builtin_constraint.cpp @@ -0,0 +1,22 @@ +// +// 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 + +namespace +{ + MOCK_CLASS( my_class ) + { + MOCK_METHOD_EXT( my_method, 0, void( int ), my_method ) + }; + void test_case() + { + my_class c; + MOCK_EXPECT( c, my_method ).with( mock::equal( "42" ) ); + } +} diff --git a/src/tests/errors_test/custom_constraint_call_operator_not_const.cpp b/src/tests/errors_test/custom_constraint_call_operator_not_const.cpp new file mode 100644 index 0000000..3fb264e --- /dev/null +++ b/src/tests/errors_test/custom_constraint_call_operator_not_const.cpp @@ -0,0 +1,27 @@ +// +// 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 + +namespace +{ + MOCK_CLASS( my_class ) + { + MOCK_METHOD_EXT( my_method, 0, void( int ), my_method ) + }; + struct custom_constraint + { + template< typename Actual > + bool operator()( Actual actual ); + }; + void test_case() + { + my_class c; + MOCK_EXPECT( c, my_method ).with( mock::constraint< custom_constraint >( custom_constraint() ) ); + } +} diff --git a/src/tests/errors_test/mismatch_type_in_returns_int_action.cpp b/src/tests/errors_test/mismatch_type_in_returns_int_action.cpp new file mode 100644 index 0000000..0522a31 --- /dev/null +++ b/src/tests/errors_test/mismatch_type_in_returns_int_action.cpp @@ -0,0 +1,22 @@ +// +// 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 + +namespace +{ + MOCK_CLASS( my_class ) + { + MOCK_METHOD_EXT( my_method, 0, int(), my_method ) + }; + void test_case() + { + my_class c; + MOCK_EXPECT( c, my_method ).returns( "42" ); + } +} diff --git a/src/tests/errors_test/mismatch_type_in_returns_string_action.cpp b/src/tests/errors_test/mismatch_type_in_returns_string_action.cpp new file mode 100644 index 0000000..c8f3449 --- /dev/null +++ b/src/tests/errors_test/mismatch_type_in_returns_string_action.cpp @@ -0,0 +1,22 @@ +// +// 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 + +namespace +{ + MOCK_CLASS( my_class ) + { + MOCK_METHOD_EXT( my_method, 0, std::string(), my_method ) + }; + void test_case() + { + my_class c; + MOCK_EXPECT( c, my_method ).returns( 42 ); + } +} diff --git a/src/tests/errors_test/mismatch_type_in_returns_void_action.cpp b/src/tests/errors_test/mismatch_type_in_returns_void_action.cpp new file mode 100644 index 0000000..9168c14 --- /dev/null +++ b/src/tests/errors_test/mismatch_type_in_returns_void_action.cpp @@ -0,0 +1,22 @@ +// +// 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 + +namespace +{ + MOCK_CLASS( my_class ) + { + MOCK_METHOD_EXT( my_method, 0, void(), my_method ) + }; + void test_case() + { + my_class c; + MOCK_EXPECT( c, my_method ).returns( "42" ); + } +} diff --git a/src/tests/errors_test/wrong_number_of_arguments_in_with.cpp b/src/tests/errors_test/wrong_number_of_arguments_in_with.cpp new file mode 100644 index 0000000..d7645c6 --- /dev/null +++ b/src/tests/errors_test/wrong_number_of_arguments_in_with.cpp @@ -0,0 +1,22 @@ +// +// 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 + +namespace +{ + MOCK_CLASS( my_class ) + { + MOCK_METHOD_EXT( my_method, 0, void( int ), my_method ) + }; + void test_case() + { + my_class c; + MOCK_EXPECT( c, my_method ).with( 42, 42 ); + } +}