diff --git a/build/boost/doc/customisation.qbk b/build/boost/doc/customisation.qbk index 6020120..245605a 100644 --- a/build/boost/doc/customisation.qbk +++ b/build/boost/doc/customisation.qbk @@ -97,6 +97,8 @@ See [link turtle.reference.expectation.constraints constraints] for an explanati For more information about the serialization operator and the use of mock::format, refer to [link turtle.customisation.logging loggin]. +[note The [link turtle.reference.helpers.MOCK_UNARY_CONSTRAINT MOCK_UNARY_CONSTRAINT] and [link turtle.reference.helpers.MOCK_BINARY_CONSTRAINT MOCK_BINARY_CONSTRAINT] macros replace the need to write the constraints explicitly for the most trivial cases] + [endsect] [section Number of arguments] diff --git a/build/boost/doc/reference.qbk b/build/boost/doc/reference.qbk index 40663e4..5d93ec4 100644 --- a/build/boost/doc/reference.qbk +++ b/build/boost/doc/reference.qbk @@ -810,4 +810,42 @@ Example : [endsect] +[section Helpers] + +This section presents macros used to help with defining custom constraints. + +[section MOCK_UNARY_CONSTRAINT] + +Synopsis : + + MOCK_UNARY_CONSTRAINT( name, expression ) // defines a constraint 'name' based on the given 'expression' + +The expression manipulates the received parameter 'actual' in order to implement the constraint. + +Example : + + MOCK_UNARY_CONSTRAINT( any, true ) // this is (almost) how mock::any is defined + MOCK_UNARY_CONSTRAINT( forty_two, actual == 42 ) // this defines a 'forty_two' constraint + +[endsect] + +[section MOCK_BINARY_CONSTRAINT] + +Synopsis : + + MOCK_BINARY_CONSTRAINT( name, expression ) // defines a constraint 'name' based on the given 'expression' + +The expression manipulates the received parameter 'actual' as well as the passed argument 'expected' in order to implement the constraint. + +[note The type of expected must be copy-constructible and assignable] + +Example : + + MOCK_BINARY_CONSTRAINT( equal, actual == expected ) // this is how mock::equal is defined + MOCK_BINARY_CONSTRAINT( near, std::abs( actual - expected ) < 0.01 ) // this defines a 'near' constraint which can be used as 'near( 42 )' + +[endsect] + +[endsect] + [endsect]