mirror of
https://github.com/mat007/turtle.git
synced 2026-06-22 12:13:43 +00:00
Enhance formatting in reference.cpp
Due to the maximum line length some line breaks made the examples ugly. Move the comments in front of the code for those.
This commit is contained in:
parent
3d5ac2b94a
commit
95ec79f8f1
1 changed files with 26 additions and 39 deletions
|
|
@ -88,8 +88,8 @@ class base
|
||||||
|
|
||||||
struct name : base, mock::object // equivalent to using MOCK_BASE_CLASS
|
struct name : base, mock::object // equivalent to using MOCK_BASE_CLASS
|
||||||
{
|
{
|
||||||
typedef base
|
// this is required for the shortest form of MOCK_METHOD to work when not using MOCK_BASE_CLASS
|
||||||
base_type; // this is required for the shortest form of MOCK_METHOD to work when not using MOCK_BASE_CLASS
|
using base_type = base;
|
||||||
};
|
};
|
||||||
//]
|
//]
|
||||||
} // namespace class_example_7
|
} // namespace class_example_7
|
||||||
|
|
@ -103,7 +103,7 @@ struct base
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct name : base<T>, mock::object
|
struct name : base<T>, mock::object
|
||||||
{
|
{
|
||||||
typedef base<T> base_type;
|
using base_type = base<T>;
|
||||||
};
|
};
|
||||||
//]
|
//]
|
||||||
} // namespace class_example_8
|
} // namespace class_example_8
|
||||||
|
|
@ -134,15 +134,10 @@ struct base_class
|
||||||
|
|
||||||
MOCK_BASE_CLASS(mock_class, base_class)
|
MOCK_BASE_CLASS(mock_class, base_class)
|
||||||
{
|
{
|
||||||
MOCK_METHOD(
|
// both the signature and identifier must be specified because of ambiguity due to overloading
|
||||||
method,
|
MOCK_METHOD(method, 2, void(int, const std::string&), identifier_1)
|
||||||
2,
|
// the identifier must differ from the previous one in order to fully disambiguate methods
|
||||||
void(int, const std::string&),
|
MOCK_METHOD(method, 1, void(float), identifier_2)
|
||||||
identifier_1) // both the signature and identifier must be specified because of ambiguity due to overloading
|
|
||||||
MOCK_METHOD(method,
|
|
||||||
1,
|
|
||||||
void(float),
|
|
||||||
identifier_2) // the identifier must differ from the previous one in order to fully disambiguate methods
|
|
||||||
};
|
};
|
||||||
//]
|
//]
|
||||||
} // namespace member_function_example_2
|
} // namespace member_function_example_2
|
||||||
|
|
@ -174,9 +169,10 @@ struct base_class
|
||||||
|
|
||||||
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
|
// this generates only the const version
|
||||||
MOCK_NON_CONST_METHOD(
|
MOCK_CONST_METHOD(method, 1, void(float), identifier_1)
|
||||||
method, 1, void(float), identifier_2) // this generates only the non-const version, with a different identifier
|
// this generates only the non-const version, with a different identifier
|
||||||
|
MOCK_NON_CONST_METHOD(method, 1, void(float), identifier_2)
|
||||||
};
|
};
|
||||||
//]
|
//]
|
||||||
} // namespace member_function_example_4
|
} // namespace member_function_example_4
|
||||||
|
|
@ -191,7 +187,7 @@ struct base_class
|
||||||
|
|
||||||
struct mock_class : base_class
|
struct mock_class : base_class
|
||||||
{
|
{
|
||||||
typedef base_class base_type; // this is required for MOCK_METHOD to work when not using MOCK_BASE_CLASS
|
using base_type = base_class; // this is required for MOCK_METHOD to work when not using MOCK_BASE_CLASS
|
||||||
|
|
||||||
MOCK_METHOD(method, 1)
|
MOCK_METHOD(method, 1)
|
||||||
};
|
};
|
||||||
|
|
@ -215,8 +211,8 @@ namespace member_function_example_7 {
|
||||||
template<typename T>
|
template<typename T>
|
||||||
MOCK_CLASS(mock_class)
|
MOCK_CLASS(mock_class)
|
||||||
{
|
{
|
||||||
MOCK_METHOD(method, 1,
|
// includes a template parameter of the class
|
||||||
void(const T&)) // includes a template parameter of the class
|
MOCK_METHOD(method, 1, void(const T&))
|
||||||
};
|
};
|
||||||
//]
|
//]
|
||||||
} // namespace member_function_example_7
|
} // namespace member_function_example_7
|
||||||
|
|
@ -240,10 +236,8 @@ namespace member_function_example_9 {
|
||||||
//[ member_function_example_9
|
//[ member_function_example_9
|
||||||
MOCK_CLASS(mock_class)
|
MOCK_CLASS(mock_class)
|
||||||
{
|
{
|
||||||
MOCK_METHOD(__stdcall method,
|
// all parameters must be provided when specifying a different calling convention
|
||||||
0,
|
MOCK_METHOD(__stdcall method, 0, void(), method)
|
||||||
void(),
|
|
||||||
method) // all parameters must be provided when specifying a different calling convention
|
|
||||||
};
|
};
|
||||||
//]
|
//]
|
||||||
} // namespace member_function_example_9
|
} // namespace member_function_example_9
|
||||||
|
|
@ -273,10 +267,8 @@ namespace static_member_function_example_3 {
|
||||||
//[ static_member_function_example_3
|
//[ static_member_function_example_3
|
||||||
MOCK_CLASS(mock_class)
|
MOCK_CLASS(mock_class)
|
||||||
{
|
{
|
||||||
MOCK_STATIC_METHOD(__stdcall method,
|
// all parameters must be provided when specifying a different calling convention
|
||||||
0,
|
MOCK_STATIC_METHOD(__stdcall method, 0, void(), method)
|
||||||
void(),
|
|
||||||
method) // all parameters must be provided when specifying a different calling convention
|
|
||||||
};
|
};
|
||||||
//]
|
//]
|
||||||
} // namespace static_member_function_example_3
|
} // namespace static_member_function_example_3
|
||||||
|
|
@ -381,10 +373,8 @@ BOOST_AUTO_TEST_CASE(demonstrates_instantiating_a_mock_function)
|
||||||
#ifdef BOOST_MSVC
|
#ifdef BOOST_MSVC
|
||||||
namespace function_example_2 {
|
namespace function_example_2 {
|
||||||
//[ function_example_2
|
//[ function_example_2
|
||||||
MOCK_FUNCTION(__stdcall f,
|
// all parameters must be provided when specifying a different calling convention
|
||||||
0,
|
MOCK_FUNCTION(__stdcall f, 0, void(), f)
|
||||||
void(),
|
|
||||||
f) // all parameters must be provided when specifying a different calling convention
|
|
||||||
//]
|
//]
|
||||||
} // namespace function_example_2
|
} // namespace function_example_2
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -898,11 +888,10 @@ BOOST_AUTO_TEST_CASE(mock_constraint_0_arity)
|
||||||
|
|
||||||
namespace helpers_example_2 {
|
namespace helpers_example_2 {
|
||||||
//[ helpers_example_2
|
//[ helpers_example_2
|
||||||
MOCK_CONSTRAINT(equal, expected, actual == expected) // this is how mock::equal could be defined
|
// this is how mock::equal could be defined
|
||||||
MOCK_CONSTRAINT(near,
|
MOCK_CONSTRAINT(equal, expected, actual == expected)
|
||||||
expected,
|
// this defines a 'near' constraint which can be used as 'near( 42 )'
|
||||||
std::abs(actual - expected) <
|
MOCK_CONSTRAINT(near, expected, std::abs(actual - expected) < 0.01)
|
||||||
0.01) // this defines a 'near' constraint which can be used as 'near( 42 )'
|
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(mock_constraint_1_arity)
|
BOOST_AUTO_TEST_CASE(mock_constraint_1_arity)
|
||||||
{
|
{
|
||||||
|
|
@ -915,10 +904,8 @@ BOOST_AUTO_TEST_CASE(mock_constraint_1_arity)
|
||||||
|
|
||||||
namespace helpers_example_3 {
|
namespace helpers_example_3 {
|
||||||
//[ helpers_example_3
|
//[ helpers_example_3
|
||||||
MOCK_CONSTRAINT(near,
|
// this is how mock::near could be defined
|
||||||
expected,
|
MOCK_CONSTRAINT(near, expected, tolerance, std::abs(actual - expected) <= tolerance)
|
||||||
tolerance,
|
|
||||||
std::abs(actual - expected) < tolerance) // this is how mock::near could be defined
|
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(mock_constraint_2_arity)
|
BOOST_AUTO_TEST_CASE(mock_constraint_2_arity)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue