mirror of
https://github.com/mat007/turtle.git
synced 2026-06-22 12:13:43 +00:00
Updated documentation
git-svn-id: https://svn.code.sf.net/p/turtle/code/trunk@731 860be788-9bd5-4423-9f1e-828f051e677b
This commit is contained in:
parent
086a42e432
commit
7cc5feeea0
3 changed files with 23 additions and 9 deletions
20
build/boost/doc/example/rationale.cpp
Normal file
20
build/boost/doc/example/rationale.cpp
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
// http://turtle.sourceforge.net
|
||||
//
|
||||
// Copyright Mathieu Champlon 2014
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <turtle/mock.hpp>
|
||||
#include "calculator.hpp"
|
||||
#include "mock_view.hpp"
|
||||
|
||||
//[ overflow_throws
|
||||
BOOST_AUTO_TEST_CASE( overflow_throws )
|
||||
{
|
||||
mock_view v;
|
||||
calculator c( v );
|
||||
BOOST_CHECK_THROW( c.add( std::numeric_limits< int >::max(), 1 ), std::exception );
|
||||
}
|
||||
//]
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
[quickbook 1.5]
|
||||
[/ [authors [Champlon, Mathieu]] ]
|
||||
[authors [,A C++ mock object library for Boost]]
|
||||
[copyright 2008-2013 Mathieu Champlon]
|
||||
[copyright 2008-2014 Mathieu Champlon]
|
||||
[license
|
||||
Distributed under the [@http://www.boost.org/LICENSE_1_0.txt Boost Software License, Version 1.0].
|
||||
]
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
[section:rationale Rationale]
|
||||
[import example/rationale.cpp]
|
||||
|
||||
This section explains some of the design and implementation choices.
|
||||
|
||||
|
|
@ -14,14 +15,12 @@ Several design choices follow the same motivation :
|
|||
* both const and non-const versions of a method are mocked by default
|
||||
* the short-cuts for adding constraints cover 95% of the use cases
|
||||
* non-serializable types do not yield compilation errors but are logged as '?' by default
|
||||
* etc..
|
||||
|
||||
At the same time customizing any aspect of the library should require minimum effort, for instance :
|
||||
|
||||
* custom constraints can be any functors, including free functions
|
||||
* customizing the logging of a type is done by defining a serialization operator
|
||||
* integrating into a test framework is made possible by writing a simple custom policy
|
||||
* etc..
|
||||
|
||||
[endsect]
|
||||
|
||||
|
|
@ -29,12 +28,7 @@ At the same time customizing any aspect of the library should require minimum ef
|
|||
|
||||
By design the exceptions thrown upon error should not inherit from std::exception, for instance consider the following test case based on the example from the [link turtle.motivation motivation] section :
|
||||
|
||||
BOOST_AUTO_TEST_CASE( overflow_throws )
|
||||
{
|
||||
mock_view v;
|
||||
calculator c( v );
|
||||
BOOST_CHECK_THROW( c.add( std::numeric_limits< int >::max(), 1 ), std::exception );
|
||||
}
|
||||
[overflow_throws]
|
||||
|
||||
Any call to 'v' will be unexpected and yield an exception, which if it were an std::exception would erroneously make the test succeed whereas it is supposed to pass only if the operation overflows (thus not triggering 'v').
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue