mirror of
https://github.com/mat007/turtle.git
synced 2026-06-22 12:13:43 +00:00
Add macros to StatementMacros
This commit is contained in:
parent
e1ac66a4c1
commit
035ad716bf
35 changed files with 5224 additions and 1208 deletions
|
|
@ -99,7 +99,10 @@ public:
|
|||
};
|
||||
//]
|
||||
|
||||
MOCK_BASE_CLASS(mock_view, view){ MOCK_METHOD(display, 1) };
|
||||
MOCK_BASE_CLASS(mock_view, view)
|
||||
{
|
||||
MOCK_METHOD(display, 1)
|
||||
};
|
||||
|
||||
class calculator
|
||||
{
|
||||
|
|
|
|||
|
|
@ -22,14 +22,16 @@ namespace limitations_comma_in_macro_solution_1 {
|
|||
//[ limitations_comma_in_macro_solution_1
|
||||
typedef my_base_class<int, int> my_base_type;
|
||||
|
||||
MOCK_BASE_CLASS(my_mock, my_base_type){};
|
||||
MOCK_BASE_CLASS(my_mock, my_base_type)
|
||||
{};
|
||||
//]
|
||||
} // namespace limitations_comma_in_macro_solution_1
|
||||
|
||||
namespace limitations_comma_in_macro_solution_2 {
|
||||
//[ limitations_comma_in_macro_solution_2
|
||||
template<typename T1, typename T2>
|
||||
MOCK_BASE_CLASS(my_mock, my_base_class<T1 BOOST_PP_COMMA() T2>){};
|
||||
MOCK_BASE_CLASS(my_mock, my_base_class<T1 BOOST_PP_COMMA() T2>)
|
||||
{};
|
||||
//]
|
||||
} // namespace limitations_comma_in_macro_solution_2
|
||||
|
||||
|
|
|
|||
|
|
@ -34,10 +34,10 @@ void derived::method(int) {}
|
|||
|
||||
namespace limitations_const_parameter_warning_solution {
|
||||
//[ limitations_const_parameter_warning_solution
|
||||
MOCK_BASE_CLASS(mock_base, base){ void method(const int i){ method_stub(i);
|
||||
} // namespace limitations_const_parameter_warning_solution
|
||||
MOCK_METHOD(method_stub, 1, void(int), method)
|
||||
}
|
||||
;
|
||||
MOCK_BASE_CLASS(mock_base, base)
|
||||
{
|
||||
void method(const int i) { method_stub(i); } // namespace limitations_const_parameter_warning_solution
|
||||
MOCK_METHOD(method_stub, 1, void(int), method)
|
||||
};
|
||||
//]
|
||||
}
|
||||
} // namespace limitations_const_parameter_warning_solution
|
||||
|
|
|
|||
|
|
@ -18,7 +18,10 @@ public:
|
|||
virtual void method(int* i) = 0;
|
||||
};
|
||||
|
||||
MOCK_BASE_CLASS(mock_base, base){ MOCK_METHOD(method, 1) };
|
||||
MOCK_BASE_CLASS(mock_base, base)
|
||||
{
|
||||
MOCK_METHOD(method, 1)
|
||||
};
|
||||
//]
|
||||
} // namespace
|
||||
|
||||
|
|
|
|||
|
|
@ -20,5 +20,8 @@ public:
|
|||
//]
|
||||
|
||||
//[ limitations_non_virtual_method_problem_2
|
||||
MOCK_BASE_CLASS(mock_base, base){ MOCK_METHOD(method, 0) };
|
||||
MOCK_BASE_CLASS(mock_base, base)
|
||||
{
|
||||
MOCK_METHOD(method, 0)
|
||||
};
|
||||
//]
|
||||
|
|
|
|||
|
|
@ -23,6 +23,10 @@ private:
|
|||
//]
|
||||
|
||||
//[ limitations_protected_private_method_solution
|
||||
MOCK_BASE_CLASS(mock_base, base){ MOCK_METHOD(method_1, 0, void()) MOCK_METHOD(method_2, 0, void()) };
|
||||
MOCK_BASE_CLASS(mock_base, base)
|
||||
{
|
||||
MOCK_METHOD(method_1, 0, void())
|
||||
MOCK_METHOD(method_2, 0, void())
|
||||
};
|
||||
//]
|
||||
} // namespace
|
||||
|
|
|
|||
|
|
@ -24,6 +24,9 @@ public:
|
|||
|
||||
//[ limitations_template_base_class_method_solution
|
||||
template<typename T>
|
||||
MOCK_BASE_CLASS(mock_base, base<T>){ MOCK_METHOD(method, 1, void()) };
|
||||
MOCK_BASE_CLASS(mock_base, base<T>)
|
||||
{
|
||||
MOCK_METHOD(method, 1, void())
|
||||
};
|
||||
//]
|
||||
} // namespace
|
||||
|
|
|
|||
|
|
@ -29,8 +29,11 @@ void function_under_test(T t) // T is supposed to model the previous concept
|
|||
//]
|
||||
|
||||
//[ limitations_template_method_solution
|
||||
MOCK_CLASS(mock_concept){ MOCK_METHOD(method, 1, void(int), method_int)
|
||||
MOCK_METHOD(method, 1, void(const char*), method_string) };
|
||||
MOCK_CLASS(mock_concept)
|
||||
{
|
||||
MOCK_METHOD(method, 1, void(int), method_int)
|
||||
MOCK_METHOD(method, 1, void(const char*), method_string)
|
||||
};
|
||||
//]
|
||||
} // namespace limitations_template_method_problem
|
||||
|
||||
|
|
|
|||
|
|
@ -21,10 +21,10 @@ struct base_class
|
|||
//]
|
||||
|
||||
//[ limitations_throw_specifier_solution
|
||||
MOCK_BASE_CLASS(mock_class, base_class){ void method() throw(){ method_proxy();
|
||||
} // namespace
|
||||
MOCK_METHOD(method_proxy, 0, void(), method)
|
||||
}
|
||||
;
|
||||
MOCK_BASE_CLASS(mock_class, base_class)
|
||||
{
|
||||
void method() throw() { method_proxy(); } // namespace
|
||||
MOCK_METHOD(method_proxy, 0, void(), method)
|
||||
};
|
||||
//]
|
||||
}
|
||||
} // namespace
|
||||
|
|
|
|||
|
|
@ -17,6 +17,6 @@ MOCK_BASE_CLASS(mock_view, view) // declare a 'mock_view' class implementing 'vi
|
|||
{
|
||||
MOCK_METHOD(display, 1) // implement the 'display' method from 'view' (taking 1 argument)
|
||||
};
|
||||
//]
|
||||
//]
|
||||
|
||||
#endif // MOCK_VIEW
|
||||
|
|
|
|||
|
|
@ -43,7 +43,10 @@ void check(bool& condition, F flush, int attempts = 100, int sleep = 100)
|
|||
}
|
||||
}
|
||||
|
||||
MOCK_BASE_CLASS(mock_base_class, base_class){ MOCK_METHOD(method, 0) };
|
||||
MOCK_BASE_CLASS(mock_base_class, base_class)
|
||||
{
|
||||
MOCK_METHOD(method, 0)
|
||||
};
|
||||
void set_bool(bool& b)
|
||||
{
|
||||
b = true;
|
||||
|
|
|
|||
|
|
@ -27,8 +27,11 @@ void function(base_class&); // the function will call 'method' with a functor to
|
|||
#include <boost/test/auto_unit_test.hpp>
|
||||
|
||||
namespace {
|
||||
MOCK_BASE_CLASS(mock_class, base_class){ MOCK_METHOD(method, 1) };
|
||||
}
|
||||
MOCK_BASE_CLASS(mock_class, base_class)
|
||||
{
|
||||
MOCK_METHOD(method, 1)
|
||||
};
|
||||
} // namespace
|
||||
|
||||
BOOST_AUTO_TEST_CASE(how_to_invoke_a_functor_passed_as_parameter_of_a_mock_method)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -25,7 +25,8 @@ std::ostream& operator<<(std::ostream& os, const my_class& c) // my_class is ser
|
|||
return os << "my_class( " << c.data_ << " )";
|
||||
}
|
||||
|
||||
MOCK_CLASS(my_mock){
|
||||
MOCK_CLASS(my_mock)
|
||||
{
|
||||
MOCK_METHOD(method, 1, void(const my_class&)) // how to simply write a custom constraint ?
|
||||
};
|
||||
} // namespace
|
||||
|
|
|
|||
|
|
@ -31,8 +31,11 @@ public:
|
|||
#include <boost/test/auto_unit_test.hpp>
|
||||
|
||||
namespace {
|
||||
MOCK_BASE_CLASS(mock_base_class, base_class){ MOCK_METHOD(method, 1) };
|
||||
}
|
||||
MOCK_BASE_CLASS(mock_base_class, base_class)
|
||||
{
|
||||
MOCK_METHOD(method, 1)
|
||||
};
|
||||
} // namespace
|
||||
|
||||
BOOST_AUTO_TEST_CASE(method_is_called_two_times_with_the_same_value)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -12,7 +12,8 @@
|
|||
|
||||
namespace class_example_1 {
|
||||
//[ class_example_1
|
||||
MOCK_CLASS(mock_class){};
|
||||
MOCK_CLASS(mock_class)
|
||||
{};
|
||||
|
||||
BOOST_AUTO_TEST_CASE(demonstrates_instantiating_a_mock_class)
|
||||
{
|
||||
|
|
@ -24,7 +25,8 @@ BOOST_AUTO_TEST_CASE(demonstrates_instantiating_a_mock_class)
|
|||
namespace class_example_2 {
|
||||
//[ class_example_2
|
||||
template<typename T>
|
||||
MOCK_CLASS(mock_class){};
|
||||
MOCK_CLASS(mock_class)
|
||||
{};
|
||||
|
||||
BOOST_AUTO_TEST_CASE(demonstrates_instantiating_a_template_mock_class)
|
||||
{
|
||||
|
|
@ -38,7 +40,8 @@ namespace class_example_3 {
|
|||
struct base_class
|
||||
{};
|
||||
|
||||
MOCK_BASE_CLASS(mock_class, base_class){};
|
||||
MOCK_BASE_CLASS(mock_class, base_class)
|
||||
{};
|
||||
|
||||
BOOST_AUTO_TEST_CASE(demonstrates_instantiating_a_derived_mock_class)
|
||||
{
|
||||
|
|
@ -54,7 +57,8 @@ struct base_class
|
|||
{};
|
||||
|
||||
template<typename T>
|
||||
MOCK_BASE_CLASS(mock_class, base_class<T>){};
|
||||
MOCK_BASE_CLASS(mock_class, base_class<T>)
|
||||
{};
|
||||
|
||||
BOOST_AUTO_TEST_CASE(demonstrates_instantiating_a_template_derived_mock_class)
|
||||
{
|
||||
|
|
@ -113,7 +117,8 @@ struct base_class
|
|||
virtual void method(int) = 0;
|
||||
};
|
||||
|
||||
MOCK_BASE_CLASS(mock_class, base_class){
|
||||
MOCK_BASE_CLASS(mock_class, base_class)
|
||||
{
|
||||
MOCK_METHOD(method, 1) // only possible when referring unambiguously to a base class method
|
||||
};
|
||||
//]
|
||||
|
|
@ -128,7 +133,8 @@ struct base_class
|
|||
virtual void method(float) = 0;
|
||||
};
|
||||
|
||||
MOCK_BASE_CLASS(mock_class, base_class){
|
||||
MOCK_BASE_CLASS(mock_class, base_class)
|
||||
{
|
||||
MOCK_METHOD(
|
||||
method,
|
||||
2,
|
||||
|
|
@ -151,7 +157,8 @@ struct base_class
|
|||
virtual void method(float) const = 0;
|
||||
};
|
||||
|
||||
MOCK_BASE_CLASS(mock_class, base_class){
|
||||
MOCK_BASE_CLASS(mock_class, base_class)
|
||||
{
|
||||
MOCK_METHOD(method, 1, void(float)) // this generates both const and non-const versions
|
||||
};
|
||||
//]
|
||||
|
|
@ -166,7 +173,8 @@ struct base_class
|
|||
virtual void method(float) const = 0;
|
||||
};
|
||||
|
||||
MOCK_BASE_CLASS(mock_class, base_class){
|
||||
MOCK_BASE_CLASS(mock_class, base_class)
|
||||
{
|
||||
MOCK_CONST_METHOD(method, 1, void(float), identifier_1) // this generates only the const version
|
||||
MOCK_NON_CONST_METHOD(method,
|
||||
1,
|
||||
|
|
@ -195,7 +203,8 @@ struct mock_class : base_class
|
|||
|
||||
namespace member_function_example_6 {
|
||||
//[ member_function_example_6
|
||||
MOCK_CLASS(mock_class){
|
||||
MOCK_CLASS(mock_class)
|
||||
{
|
||||
MOCK_NON_CONST_METHOD(operator=,
|
||||
1,
|
||||
mock_class &(const mock_class&),
|
||||
|
|
@ -207,7 +216,8 @@ MOCK_CLASS(mock_class){
|
|||
namespace member_function_example_7 {
|
||||
//[ member_function_example_7
|
||||
template<typename T>
|
||||
MOCK_CLASS(mock_class){
|
||||
MOCK_CLASS(mock_class)
|
||||
{
|
||||
MOCK_METHOD_TPL(
|
||||
method,
|
||||
1,
|
||||
|
|
@ -218,11 +228,11 @@ MOCK_CLASS(mock_class){
|
|||
|
||||
namespace member_function_example_8 {
|
||||
//[ member_function_example_8
|
||||
MOCK_CLASS(mock_class){
|
||||
MOCK_METHOD(method,
|
||||
0,
|
||||
BOOST_IDENTITY_TYPE((std::map<int, int>()))) // the signature must be wrapped in BOOST_IDENTITY_TYPE if
|
||||
// the return type contains a comma
|
||||
MOCK_CLASS(mock_class)
|
||||
{
|
||||
MOCK_METHOD(
|
||||
method, 0, BOOST_IDENTITY_TYPE((std::map<int, int>()))) // the signature must be wrapped in BOOST_IDENTITY_TYPE if
|
||||
// the return type contains a comma
|
||||
};
|
||||
//]
|
||||
} // namespace member_function_example_8
|
||||
|
|
@ -230,7 +240,8 @@ MOCK_CLASS(mock_class){
|
|||
#ifdef BOOST_MSVC
|
||||
namespace member_function_example_9 {
|
||||
//[ member_function_example_9
|
||||
MOCK_CLASS(mock_class){
|
||||
MOCK_CLASS(mock_class)
|
||||
{
|
||||
MOCK_METHOD(__stdcall method,
|
||||
0,
|
||||
void(),
|
||||
|
|
@ -242,21 +253,28 @@ MOCK_CLASS(mock_class){
|
|||
|
||||
namespace static_member_function_example_1 {
|
||||
//[ static_member_function_example_1
|
||||
MOCK_CLASS(mock_class){ MOCK_STATIC_METHOD(method, 1, float(int)) };
|
||||
MOCK_CLASS(mock_class)
|
||||
{
|
||||
MOCK_STATIC_METHOD(method, 1, float(int))
|
||||
};
|
||||
//]
|
||||
} // namespace static_member_function_example_1
|
||||
|
||||
namespace static_member_function_example_2 {
|
||||
//[ static_member_function_example_2
|
||||
template<typename T>
|
||||
MOCK_CLASS(mock_class){ MOCK_STATIC_METHOD_TPL(method, 1, void(T)) };
|
||||
MOCK_CLASS(mock_class)
|
||||
{
|
||||
MOCK_STATIC_METHOD_TPL(method, 1, void(T))
|
||||
};
|
||||
//]
|
||||
} // namespace static_member_function_example_2
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
namespace static_member_function_example_3 {
|
||||
//[ static_member_function_example_3
|
||||
MOCK_CLASS(mock_class){
|
||||
MOCK_CLASS(mock_class)
|
||||
{
|
||||
MOCK_STATIC_METHOD(__stdcall method,
|
||||
0,
|
||||
void(),
|
||||
|
|
@ -268,55 +286,74 @@ MOCK_CLASS(mock_class){
|
|||
|
||||
namespace constructor_example_1 {
|
||||
//[ constructor_example_1
|
||||
MOCK_CLASS(mock_class){ MOCK_CONSTRUCTOR(mock_class, 2, (int, const std::string&), identifier) };
|
||||
MOCK_CLASS(mock_class)
|
||||
{
|
||||
MOCK_CONSTRUCTOR(mock_class, 2, (int, const std::string&), identifier)
|
||||
};
|
||||
//]
|
||||
} // namespace constructor_example_1
|
||||
|
||||
namespace constructor_example_2 {
|
||||
//[ constructor_example_2
|
||||
template<typename T>
|
||||
MOCK_CLASS(mock_class){ MOCK_CONSTRUCTOR(mock_class, 2, (int, const std::string&), identifier)
|
||||
MOCK_CONSTRUCTOR_TPL(mock_class, 2, (T, const std::string&), identifier_2) };
|
||||
MOCK_CLASS(mock_class)
|
||||
{
|
||||
MOCK_CONSTRUCTOR(mock_class, 2, (int, const std::string&), identifier)
|
||||
MOCK_CONSTRUCTOR_TPL(mock_class, 2, (T, const std::string&), identifier_2)
|
||||
};
|
||||
//]
|
||||
} // namespace constructor_example_2
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
namespace constructor_example_3 {
|
||||
//[ constructor_example_3
|
||||
MOCK_CLASS(mock_class){ MOCK_CONSTRUCTOR(__stdcall mock_class, 0, (), constructor) };
|
||||
MOCK_CLASS(mock_class)
|
||||
{
|
||||
MOCK_CONSTRUCTOR(__stdcall mock_class, 0, (), constructor)
|
||||
};
|
||||
//]
|
||||
} // namespace constructor_example_3
|
||||
#endif
|
||||
|
||||
namespace destructor_example_1 {
|
||||
//[ destructor_example_1
|
||||
MOCK_CLASS(mock_class){ MOCK_DESTRUCTOR(~mock_class, destructor) };
|
||||
MOCK_CLASS(mock_class)
|
||||
{
|
||||
MOCK_DESTRUCTOR(~mock_class, destructor)
|
||||
};
|
||||
//]
|
||||
} // namespace destructor_example_1
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
namespace destructor_example_2 {
|
||||
//[ destructor_example_2
|
||||
MOCK_CLASS(mock_class){ MOCK_DESTRUCTOR(__stdcall ~mock_class, destructor) };
|
||||
MOCK_CLASS(mock_class)
|
||||
{
|
||||
MOCK_DESTRUCTOR(__stdcall ~mock_class, destructor)
|
||||
};
|
||||
//]
|
||||
} // namespace destructor_example_2
|
||||
#endif
|
||||
|
||||
namespace conversion_operator_example_1 {
|
||||
//[ conversion_operator_example_1
|
||||
MOCK_CLASS(mock_class){ MOCK_CONVERSION_OPERATOR(operator, int, conversion_to_int)
|
||||
MOCK_CONST_CONVERSION_OPERATOR(operator, const std::string&, conversion_to_string) };
|
||||
MOCK_CLASS(mock_class)
|
||||
{
|
||||
MOCK_CONVERSION_OPERATOR(operator, int, conversion_to_int)
|
||||
MOCK_CONST_CONVERSION_OPERATOR(operator, const std::string&, conversion_to_string)
|
||||
};
|
||||
//]
|
||||
} // namespace conversion_operator_example_1
|
||||
|
||||
namespace conversion_operator_example_2 {
|
||||
//[ conversion_operator_example_2
|
||||
template<typename T>
|
||||
MOCK_CLASS(mock_class){
|
||||
MOCK_CLASS(mock_class)
|
||||
{
|
||||
MOCK_CONVERSION_OPERATOR_TPL(operator, T, conversion_to_T) // the _TPL variants must be used if the signature
|
||||
// includes a template parameter of the class
|
||||
MOCK_CONST_CONVERSION_OPERATOR(operator, const std::string&, const_conversion_to_string)
|
||||
MOCK_NON_CONST_CONVERSION_OPERATOR(operator, const std::string&, non_const_conversion_to_string)
|
||||
MOCK_NON_CONST_CONVERSION_OPERATOR(operator, const std::string&, non_const_conversion_to_string)
|
||||
};
|
||||
//]
|
||||
} // namespace conversion_operator_example_2
|
||||
|
|
@ -324,7 +361,10 @@ MOCK_CLASS(mock_class){
|
|||
#ifdef BOOST_MSVC
|
||||
namespace conversion_operator_example_3 {
|
||||
//[ conversion_operator_example_3
|
||||
MOCK_CLASS(mock_class){ MOCK_CONVERSION_OPERATOR(__stdcall operator, int, conversion_to_int) };
|
||||
MOCK_CLASS(mock_class)
|
||||
{
|
||||
MOCK_CONVERSION_OPERATOR(__stdcall operator, int, conversion_to_int)
|
||||
};
|
||||
//]
|
||||
} // namespace conversion_operator_example_3
|
||||
#endif
|
||||
|
|
@ -379,8 +419,11 @@ BOOST_AUTO_TEST_CASE(demonstrates_instantiating_a_mock_functor)
|
|||
|
||||
namespace expectation_example_1 {
|
||||
//[ expectation_example_1
|
||||
MOCK_CLASS(mock_class){ MOCK_METHOD(method, 1, int(int), method)
|
||||
MOCK_METHOD(method, 2, void(const std::string&, float), method2) };
|
||||
MOCK_CLASS(mock_class)
|
||||
{
|
||||
MOCK_METHOD(method, 1, int(int), method)
|
||||
MOCK_METHOD(method, 2, void(const std::string&, float), method2)
|
||||
};
|
||||
|
||||
BOOST_AUTO_TEST_CASE(demonstrates_configuring_mock_objects)
|
||||
{
|
||||
|
|
@ -395,7 +438,10 @@ BOOST_AUTO_TEST_CASE(demonstrates_configuring_mock_objects)
|
|||
|
||||
namespace invocation_example_1 {
|
||||
//[ invocation_example_1
|
||||
MOCK_CLASS(mock_class){ MOCK_METHOD(method, 2, void(int, const std::string&)) };
|
||||
MOCK_CLASS(mock_class)
|
||||
{
|
||||
MOCK_METHOD(method, 2, void(int, const std::string&))
|
||||
};
|
||||
|
||||
BOOST_AUTO_TEST_CASE(demonstrates_setting_up_invocations_on_a_mock_method)
|
||||
{
|
||||
|
|
@ -429,7 +475,10 @@ BOOST_AUTO_TEST_CASE(demonstrates_setting_up_an_invocation_on_a_mock_function)
|
|||
|
||||
namespace invocation_example_4 {
|
||||
//[ invocation_example_4
|
||||
MOCK_CLASS(mock_class){ MOCK_STATIC_METHOD(method, 1, void(int)) };
|
||||
MOCK_CLASS(mock_class)
|
||||
{
|
||||
MOCK_STATIC_METHOD(method, 1, void(int))
|
||||
};
|
||||
|
||||
BOOST_AUTO_TEST_CASE(demonstrates_setting_up_an_invocation_on_a_mock_static_method)
|
||||
{
|
||||
|
|
@ -442,7 +491,10 @@ BOOST_AUTO_TEST_CASE(demonstrates_setting_up_an_invocation_on_a_mock_static_meth
|
|||
|
||||
namespace constraints_example_1 {
|
||||
//[ constraints_example_1
|
||||
MOCK_CLASS(mock_class){ MOCK_METHOD(method, 2, void(int, const std::string&)) };
|
||||
MOCK_CLASS(mock_class)
|
||||
{
|
||||
MOCK_METHOD(method, 2, void(int, const std::string&))
|
||||
};
|
||||
|
||||
BOOST_AUTO_TEST_CASE(demonstrates_adding_builtin_constraints)
|
||||
{
|
||||
|
|
@ -455,7 +507,10 @@ BOOST_AUTO_TEST_CASE(demonstrates_adding_builtin_constraints)
|
|||
|
||||
namespace constraints_example_2 {
|
||||
//[ constraints_example_2
|
||||
MOCK_CLASS(mock_class){ MOCK_METHOD(method, 1, void(int)) };
|
||||
MOCK_CLASS(mock_class)
|
||||
{
|
||||
MOCK_METHOD(method, 1, void(int))
|
||||
};
|
||||
|
||||
bool custom_constraint(int actual)
|
||||
{
|
||||
|
|
@ -472,7 +527,10 @@ BOOST_AUTO_TEST_CASE(demonstrates_adding_a_custom_constraint_with_a_free_functio
|
|||
|
||||
namespace constraints_example_3 {
|
||||
//[ constraints_example_3
|
||||
MOCK_CLASS(mock_class){ MOCK_METHOD(method, 1, void(int)) };
|
||||
MOCK_CLASS(mock_class)
|
||||
{
|
||||
MOCK_METHOD(method, 1, void(int))
|
||||
};
|
||||
|
||||
bool custom_constraint(int expected, int actual)
|
||||
{
|
||||
|
|
@ -490,7 +548,10 @@ BOOST_AUTO_TEST_CASE(demonstrates_adding_a_custom_constraint_with_a_standard_lib
|
|||
|
||||
namespace constraints_example_4 {
|
||||
//[ constraints_example_4
|
||||
MOCK_CLASS(mock_class){ MOCK_METHOD(method, 1, void(int)) };
|
||||
MOCK_CLASS(mock_class)
|
||||
{
|
||||
MOCK_METHOD(method, 1, void(int))
|
||||
};
|
||||
|
||||
bool custom_constraint(int expected, int actual)
|
||||
{
|
||||
|
|
@ -511,7 +572,10 @@ BOOST_AUTO_TEST_CASE(demonstrates_adding_a_custom_constraint_with_boost_bind)
|
|||
|
||||
namespace constraints_example_5 {
|
||||
//[ constraints_example_5
|
||||
MOCK_CLASS(mock_class){ MOCK_METHOD(method, 1, void(int)) };
|
||||
MOCK_CLASS(mock_class)
|
||||
{
|
||||
MOCK_METHOD(method, 1, void(int))
|
||||
};
|
||||
|
||||
BOOST_AUTO_TEST_CASE(demonstrates_adding_a_custom_constraint_with_boost_lambda)
|
||||
{
|
||||
|
|
@ -527,7 +591,10 @@ BOOST_AUTO_TEST_CASE(demonstrates_adding_a_custom_constraint_with_boost_lambda)
|
|||
|
||||
namespace constraints_example_6 {
|
||||
//[ constraints_example_6
|
||||
MOCK_CLASS(mock_class){ MOCK_METHOD(method, 1, void(int)) };
|
||||
MOCK_CLASS(mock_class)
|
||||
{
|
||||
MOCK_METHOD(method, 1, void(int))
|
||||
};
|
||||
|
||||
BOOST_AUTO_TEST_CASE(demonstrates_adding_a_custom_constraint_with_boost_phoenix)
|
||||
{
|
||||
|
|
@ -542,7 +609,10 @@ BOOST_AUTO_TEST_CASE(demonstrates_adding_a_custom_constraint_with_boost_phoenix)
|
|||
|
||||
namespace constraints_example_7 {
|
||||
//[ constraints_example_7
|
||||
MOCK_CLASS(mock_class){ MOCK_METHOD(method, 1, void(int)) };
|
||||
MOCK_CLASS(mock_class)
|
||||
{
|
||||
MOCK_METHOD(method, 1, void(int))
|
||||
};
|
||||
|
||||
BOOST_AUTO_TEST_CASE(demonstrates_adding_a_constraint_with_cxx11_lambda)
|
||||
{
|
||||
|
|
@ -556,7 +626,10 @@ BOOST_AUTO_TEST_CASE(demonstrates_adding_a_constraint_with_cxx11_lambda)
|
|||
|
||||
namespace constraints_example_8 {
|
||||
//[ constraints_example_8
|
||||
MOCK_CLASS(mock_class){ MOCK_METHOD(method, 2, void(int, const std::string&)) };
|
||||
MOCK_CLASS(mock_class)
|
||||
{
|
||||
MOCK_METHOD(method, 2, void(int, const std::string&))
|
||||
};
|
||||
|
||||
BOOST_AUTO_TEST_CASE(demonstrates_combining_constraints)
|
||||
{
|
||||
|
|
@ -568,7 +641,10 @@ BOOST_AUTO_TEST_CASE(demonstrates_combining_constraints)
|
|||
|
||||
namespace constraints_example_9 {
|
||||
//[ constraints_example_9
|
||||
MOCK_CLASS(mock_class){ MOCK_METHOD(method, 2, void(const std::string&, std::size_t)) };
|
||||
MOCK_CLASS(mock_class)
|
||||
{
|
||||
MOCK_METHOD(method, 2, void(const std::string&, std::size_t))
|
||||
};
|
||||
|
||||
bool custom_constraint(const std::string& actual_1, std::size_t actual_2)
|
||||
{
|
||||
|
|
@ -585,11 +661,20 @@ BOOST_AUTO_TEST_CASE(demonstrates_one_constraint_for_all_arguments)
|
|||
|
||||
namespace sequence_example_1 {
|
||||
//[ sequence_example_1
|
||||
MOCK_CLASS(mock_class_1){ MOCK_METHOD(method_1, 0, void()) };
|
||||
MOCK_CLASS(mock_class_1)
|
||||
{
|
||||
MOCK_METHOD(method_1, 0, void())
|
||||
};
|
||||
|
||||
MOCK_CLASS(mock_class_2){ MOCK_METHOD(method_2, 0, void()) };
|
||||
MOCK_CLASS(mock_class_2)
|
||||
{
|
||||
MOCK_METHOD(method_2, 0, void())
|
||||
};
|
||||
|
||||
MOCK_CLASS(mock_class_3){ MOCK_METHOD(method_3, 0, void()) };
|
||||
MOCK_CLASS(mock_class_3)
|
||||
{
|
||||
MOCK_METHOD(method_3, 0, void())
|
||||
};
|
||||
|
||||
BOOST_AUTO_TEST_CASE(demonstrates_enforcing_several_expectation_orders)
|
||||
{
|
||||
|
|
@ -609,7 +694,10 @@ BOOST_AUTO_TEST_CASE(demonstrates_enforcing_several_expectation_orders)
|
|||
|
||||
namespace action_example_1 {
|
||||
//[ action_example_1
|
||||
MOCK_CLASS(mock_class){ MOCK_METHOD(method, 1, int(int)) };
|
||||
MOCK_CLASS(mock_class)
|
||||
{
|
||||
MOCK_METHOD(method, 1, int(int))
|
||||
};
|
||||
|
||||
int function(int i)
|
||||
{
|
||||
|
|
@ -634,7 +722,10 @@ BOOST_AUTO_TEST_CASE(demonstrates_configuring_actions)
|
|||
|
||||
namespace action_example_2 {
|
||||
//[ action_example_2
|
||||
MOCK_CLASS(mock_class){ MOCK_METHOD(method, 0, int&()) };
|
||||
MOCK_CLASS(mock_class)
|
||||
{
|
||||
MOCK_METHOD(method, 0, int&())
|
||||
};
|
||||
|
||||
BOOST_AUTO_TEST_CASE(demonstrates_configuring_actions_with_references)
|
||||
{
|
||||
|
|
@ -649,7 +740,10 @@ BOOST_AUTO_TEST_CASE(demonstrates_configuring_actions_with_references)
|
|||
|
||||
namespace verification_example_1 {
|
||||
//[ verification_example_1
|
||||
MOCK_CLASS(mock_class){ MOCK_METHOD(method, 0, void()) };
|
||||
MOCK_CLASS(mock_class)
|
||||
{
|
||||
MOCK_METHOD(method, 0, void())
|
||||
};
|
||||
|
||||
BOOST_AUTO_TEST_CASE(demonstrates_verifying_a_mock_method)
|
||||
{
|
||||
|
|
@ -687,7 +781,10 @@ BOOST_AUTO_TEST_CASE(demonstrates_verifying_a_mock_function)
|
|||
|
||||
namespace verification_example_4 {
|
||||
//[ verification_example_4
|
||||
MOCK_CLASS(mock_class){ MOCK_STATIC_METHOD(method, 0, void()) };
|
||||
MOCK_CLASS(mock_class)
|
||||
{
|
||||
MOCK_STATIC_METHOD(method, 0, void())
|
||||
};
|
||||
|
||||
BOOST_AUTO_TEST_CASE(demonstrates_verifying_a_static_mock_method)
|
||||
{
|
||||
|
|
@ -701,7 +798,10 @@ BOOST_AUTO_TEST_CASE(demonstrates_verifying_a_static_mock_method)
|
|||
|
||||
namespace reset_example_1 {
|
||||
//[ reset_example_1
|
||||
MOCK_CLASS(mock_class){ MOCK_METHOD(method, 0, void()) };
|
||||
MOCK_CLASS(mock_class)
|
||||
{
|
||||
MOCK_METHOD(method, 0, void())
|
||||
};
|
||||
|
||||
BOOST_AUTO_TEST_CASE(demonstrates_resetting_a_mock_method)
|
||||
{
|
||||
|
|
@ -739,7 +839,10 @@ BOOST_AUTO_TEST_CASE(demonstrates_resetting_a_mock_function)
|
|||
|
||||
namespace reset_example_4 {
|
||||
//[ reset_example_4
|
||||
MOCK_CLASS(mock_class){ MOCK_STATIC_METHOD(method, 0, void()) };
|
||||
MOCK_CLASS(mock_class)
|
||||
{
|
||||
MOCK_STATIC_METHOD(method, 0, void())
|
||||
};
|
||||
|
||||
BOOST_AUTO_TEST_CASE(demonstrates_resetting_a_static_mock_method)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue