From 7cc5feeea0432f0bed4ab38aed31f71b4fc113b4 Mon Sep 17 00:00:00 2001 From: mat007 Date: Tue, 20 May 2014 05:56:37 +0000 Subject: [PATCH] Updated documentation git-svn-id: https://svn.code.sf.net/p/turtle/code/trunk@731 860be788-9bd5-4423-9f1e-828f051e677b --- build/boost/doc/example/rationale.cpp | 20 ++++++++++++++++++++ build/boost/doc/mock.qbk | 2 +- build/boost/doc/rationale.qbk | 10 ++-------- 3 files changed, 23 insertions(+), 9 deletions(-) create mode 100644 build/boost/doc/example/rationale.cpp diff --git a/build/boost/doc/example/rationale.cpp b/build/boost/doc/example/rationale.cpp new file mode 100644 index 0000000..8c0ce77 --- /dev/null +++ b/build/boost/doc/example/rationale.cpp @@ -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 +#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 ); +} +//] diff --git a/build/boost/doc/mock.qbk b/build/boost/doc/mock.qbk index 68ac685..2fc0638 100644 --- a/build/boost/doc/mock.qbk +++ b/build/boost/doc/mock.qbk @@ -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]. ] diff --git a/build/boost/doc/rationale.qbk b/build/boost/doc/rationale.qbk index 89dc17d..8f1ebbf 100644 --- a/build/boost/doc/rationale.qbk +++ b/build/boost/doc/rationale.qbk @@ -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').