Documented MOCK_UNARY_CONSTRAINT and MOCK_BINARY_CONSTRAINT

git-svn-id: https://svn.code.sf.net/p/turtle/code/trunk@628 860be788-9bd5-4423-9f1e-828f051e677b
This commit is contained in:
mat007 2013-04-23 22:48:45 +00:00
parent 2810694971
commit 9dcf6fb274
2 changed files with 40 additions and 0 deletions

View file

@ -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]

View file

@ -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]