Generalized to MOCK_CONSTRAINT

git-svn-id: https://svn.code.sf.net/p/turtle/code/trunk@660 860be788-9bd5-4423-9f1e-828f051e677b
This commit is contained in:
mat007 2013-05-20 10:49:17 +00:00
parent 8a6edd531e
commit 400aaddf9a
7 changed files with 108 additions and 123 deletions

View file

@ -323,10 +323,10 @@ Constraints :
[[mock::greater( ['expected] )] [['actual] > ['expected]] [compares ['actual] to ['expected] using operator >]]
[[mock::less_equal( ['expected] )] [['actual] <= ['expected]] [compares ['actual] to ['expected] using operator <=]]
[[mock::greater_equal( ['expected] )] [['actual] >= ['expected]] [compares ['actual] to ['expected] using operator >=]]
[[mock::near] [std::abs( ['actual] - ['expected] ) < ['arg]] [checks whether ['actual] is near ['expected]]]
[[mock::close] [boost::test_tools::check_is_close( ['actual], ['expected], boost::test_tools::percent_tolerance( ['arg] ) )] [checks whether ['actual] is close to ['expected], see [@http://www.boost.org/libs/test/doc/html/utf/testing-tools/floating_point_comparison.html Floating-point comparison algorithms] ]]
[[mock::close_fraction] [boost::test_tools::check_is_close( ['actual], ['expected], boost::test_tools::fraction_tolerance( ['arg] ) )] [checks whether ['actual] is close to ['expected], see [@http://www.boost.org/libs/test/doc/html/utf/testing-tools/floating_point_comparison.html Floating-point comparison algorithms] ]]
[[mock::small] [boost::test_tools::check_is_small( ['actual], ['expected] ) )] [checks whether ['actual] is small with a tolerance of ['expected], see [@http://www.boost.org/libs/test/doc/html/utf/testing-tools/floating_point_comparison.html Floating-point comparison algorithms] ]]
[[mock::near( ['expected], ['tolerance] )] [std::abs( ['actual] - ['expected] ) < ['tolerance]] [checks whether ['actual] is near ['expected] within ['tolerance]]]
[[mock::close( ['expected], ['tolerance] )] [boost::test_tools::check_is_close( ['actual], ['expected], boost::test_tools::percent_tolerance( ['arg] ) )] [checks whether ['actual] is close to ['expected], see [@http://www.boost.org/libs/test/doc/html/utf/testing-tools/floating_point_comparison.html Floating-point comparison algorithms] ]]
[[mock::close_fraction( ['expected], ['tolerance] )] [boost::test_tools::check_is_close( ['actual], ['expected], boost::test_tools::fraction_tolerance( ['arg] ) )] [checks whether ['actual] is close to ['expected], see [@http://www.boost.org/libs/test/doc/html/utf/testing-tools/floating_point_comparison.html Floating-point comparison algorithms] ]]
[[mock::small( ['tolerance] )] [boost::test_tools::check_is_small( ['actual], ['expected] ) )] [checks whether ['actual] is small within ['tolerance], see [@http://www.boost.org/libs/test/doc/html/utf/testing-tools/floating_point_comparison.html Floating-point comparison algorithms] ]]
[[mock::call( ['expected] )] [['expected]( ['actual] )] [calls ['expected] as a functor returning a ['bool] and accepting ['actual] as parameter]]
[[mock::same( ['expected] )] [&['actual] == &['expected]] [compares ['actual] to ['expected] by comparing their pointers]]
[[mock::assign( ['expected] )] [['actual] = ['expected], true
@ -490,49 +490,27 @@ Example :
[section Helpers]
This section presents macros used to help with defining custom constraints.
This section presents various useful tools.
[section MOCK_UNARY_CONSTRAINT]
[section MOCK_CONSTRAINT]
Synopsis :
MOCK_UNARY_CONSTRAINT( name, expression ) // defines a constraint 'name' based on the given 'expression'
MOCK_CONSTRAINT( arity, name, expression ) // defines a constraint 'name' based on the given 'expression'
The expression manipulates the received parameter 'actual' in order to implement the constraint.
The expression manipulates the received parameter ['actual] in order to implement the constraint, as well as ['arity] extra expected arguments ['expected_0], ['expected_1], etc...
Example :
[note The type of all expected arguments must be copy-constructible and assignable.]
Example without any extra argument :
[helpers_example_1]
[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 :
Example with one extra argument :
[helpers_example_2]
[endsect]
[section MOCK_TERNARY_CONSTRAINT]
Synopsis :
MOCK_TERNARY_CONSTRAINT( name, expression ) // defines a constraint 'name' based on the given 'expression'
The expression manipulates the received parameter 'actual' as well as the passed arguments 'expected' and 'arg' in order to implement the constraint.
[note The types of expected and arg must be copy-constructible and assignable.]
Example :
Example with two extra arguments :
[helpers_example_3]