From 9dcf6fb274b3f31fc51c9726a60ce8e2379cab40 Mon Sep 17 00:00:00 2001 From: mat007 Date: Tue, 23 Apr 2013 22:48:45 +0000 Subject: [PATCH] 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 --- build/boost/doc/customisation.qbk | 2 ++ build/boost/doc/reference.qbk | 38 +++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) 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]