diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..132530c
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+bin
+out
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..b1adf89
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,85 @@
+# Use, modification, and distribution are
+# subject to 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)
+#
+# Copyright Antony Polukhin 2014.
+
+#
+# See https://svn.boost.org/trac/boost/wiki/TravisCoverals for description of this file
+# and how it can be used with Boost libraries.
+#
+
+os:
+ - linux
+
+env:
+ - CXX_STANDARD=c++98
+ - CXX_STANDARD=c++0x
+
+before_install:
+ # Set this to the name of your Boost library
+ # Autodetect library name by using the following code: - PROJECT_TO_TEST=$(basename $(pwd))
+ - PROJECT_TO_TEST=$(basename $(pwd))
+
+ # Autodetect Boost branch by using the following code: - BRANCH_TO_TEST=`git rev-parse --abbrev-ref HEAD`
+ # or by - BRANCH_TO_TEST=$TRAVIS_BRANCH or just directly specify it
+ - BRANCH_TO_TEST=master
+
+ # Files, which coverage results must be ignored (files from other projects). Example: - IGNORE_COVERAGE='*/boost/progress.hpp */filesystem/src/path.cpp'
+ - IGNORE_COVERAGE='*/boost/progress.hpp */filesystem/src/path.cpp */numeric/conversion/converter_policies.hpp'
+
+ # From this point and below code is same for all the Boost libs
+ # Cloning Boost libraries (fast nondeep cloning)
+ - PROJECT_DIR=`pwd`
+ - BOOST=$HOME/boost-local
+ - git init $BOOST
+ - cd $BOOST
+ - git remote add --no-tags -t $BRANCH_TO_TEST origin https://github.com/boostorg/boost.git
+ - git fetch --depth=1
+ - git checkout $BRANCH_TO_TEST
+ - git submodule update --init --merge
+ - git remote set-branches --add origin $BRANCH_TO_TEST
+ - git pull --recurse-submodules
+ - git submodule update --init
+ - git checkout $BRANCH_TO_TEST
+ - git submodule foreach "git reset --quiet --hard; git clean -fxd"
+ - git reset --hard; git clean -fxd
+ - git status
+ - ./bootstrap.sh
+ - ./b2 headers
+ - sudo apt-get install -qq xsltproc
+
+script:
+ - if [ "$CCFLAGS" != "" ]; then FLAGS="cxxflags=\"$CCFLAGS\" linkflags=\"$LINKFLAGS\""; else FLAGS=""; fi
+ - cd $PROJECT_DIR/build
+ # `--coverage` flags required to generate coverage info for Coveralls
+ # ../../../b2 -q cxxflags="--coverage -std=$CXX_STANDARD" linkflags="--coverage"
+ - export BOOST_ROOT=$BOOST
+ - ./build.sh cxxflags="--coverage -std=$CXX_STANDARD" linkflags="--coverage"
+
+after_success:
+ - COVERALS_DIR=$PROJECT_DIR/coverals
+
+ # Copying Coveralls data to a separate folder
+ - mkdir -p $COVERALS_DIR
+ - find ../test/bin/ -name "*.gcda" -exec cp "{}" $COVERALS_DIR/ \;
+ - find ../test/bin/ -name "*.gcno" -exec cp "{}" $COVERALS_DIR/ \;
+
+ # Preparing Coveralls data by
+ # ... installing the tools
+ - sudo apt-get install -qq python-yaml lcov
+ # ... changind data format to a readable one
+ - lcov --directory $COVERALS_DIR --base-directory ./ --capture --output-file $COVERALS_DIR/coverage.info
+
+ # ... erasing /test/ /example/ folder data
+ - lcov --remove $COVERALS_DIR/coverage.info "/usr*" "/test/*" $IGNORE_COVERAGE "tests/*" "*/doc/examples/*" -o $COVERALS_DIR/coverage.info
+
+ # ... erasing data that is not related to this project directly
+ - OTHER_LIBS=`grep "submodule .*" .gitmodules | sed 's/\[submodule\ "\(.*\)"\]/"\*\/boost\/\1\.hpp" "\*\/boost\/\1\/\*"/g'| sed "/\"\*\/boost\/$PROJECT_TO_TEST\/\*\"/d" | sed ':a;N;$!ba;s/\n/ /g'`
+ - echo $OTHER_LIBS
+ - eval "lcov --remove $COVERALS_DIR/coverage.info $OTHER_LIBS -o $COVERALS_DIR/coverage.info"
+
+ # Sending data to Coveralls
+ - cd $PROJECT_DIR
+ - gem install coveralls-lcov
+ - coveralls-lcov coverals/coverage.info
diff --git a/build/boost/Jamfile.v2 b/Jamfile.v2
similarity index 100%
rename from build/boost/Jamfile.v2
rename to Jamfile.v2
diff --git a/build/boost/Jamroot.jam b/Jamroot.jam
similarity index 53%
rename from build/boost/Jamroot.jam
rename to Jamroot.jam
index 869d2c8..8797198 100644
--- a/build/boost/Jamroot.jam
+++ b/Jamroot.jam
@@ -1,3 +1,8 @@
+# Copyright Rene Rivera 2007.
+#
+# 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)
import modules ;
diff --git a/build/boost/LICENSE_1_0.txt b/LICENSE_1_0.txt
similarity index 100%
rename from build/boost/LICENSE_1_0.txt
rename to LICENSE_1_0.txt
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..5f6d44c
--- /dev/null
+++ b/README.md
@@ -0,0 +1,13 @@
+#[Turtle](http://turtle.sourceforge.net)
+Turtle is a C++ mock object library based on Boost with a focus on usability, simplicity and flexibility.
+
+### Test results
+
+[](https://travis-ci.org/mat007/turtle)
+[](https://coveralls.io/r/mat007/turtle)
+
+[Open Issues](https://sourceforge.net/p/turtle/tickets)
+
+### License
+
+Distributed under the [Boost Software License, Version 1.0](http://boost.org/LICENSE_1_0.txt).
diff --git a/build/boost/doc/html/boost-no-inspect b/build/boost/doc/html/boost-no-inspect
deleted file mode 100644
index e69de29..0000000
diff --git a/build/build.bat b/build/build.bat
new file mode 100644
index 0000000..e747db4
--- /dev/null
+++ b/build/build.bat
@@ -0,0 +1,37 @@
+@echo off
+
+rem Copyright (C) 2015 Mathieu Champlon
+rem
+rem Distributed under the Boost Software License, Version 1.0.
+rem (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+
+setlocal
+goto Start
+
+:Error
+color 00
+goto :eof
+
+:Start
+
+rem error if BOOST_ROOT not set
+set BOOST=%BOOST_ROOT%
+
+pushd ..\test
+%BOOST%\b2 -q %*
+popd
+if errorlevel 1 goto Error
+
+set BOOSTBOOK_DIR=..\bin\turtle\boostbook
+xcopy /Y /S /Q /I %BOOST%\tools\boostbook\xsl %BOOSTBOOK_DIR%\xsl
+xcopy /Y /S /Q /I %BOOST%\tools\boostbook\dtd %BOOSTBOOK_DIR%\dtd
+xcopy /Y /S /Q /I boostbook %BOOSTBOOK_DIR%
+xcopy /Y /S /Q /I %BOOST%\doc\src\boostbook.css ..\doc\html
+xcopy /Y /S /Q /I %BOOST%\doc\src\images\*.png ..\doc\html\images
+xcopy /Y /S /Q /I %BOOST%\doc\src\images\callouts\*.png ..\doc\html\images\callouts
+if errorlevel 1 goto Error
+pushd ..\doc
+%BOOST%\b2 -q %*
+popd
+
+:End
\ No newline at end of file
diff --git a/build/build.properties b/build/build.properties
index 25ba777..623180f 100644
--- a/build/build.properties
+++ b/build/build.properties
@@ -1,5 +1 @@
-extensions = svn,headers,check
-src.dir = ${root.dir}
-tests.dir = ${root.dir}
-libraries.dir = ${root.dir}
-boost.dir = ${out.dir}/../boost
+extensions = headers,check,run
diff --git a/build/build.sh b/build/build.sh
new file mode 100755
index 0000000..3683544
--- /dev/null
+++ b/build/build.sh
@@ -0,0 +1,40 @@
+#!/bin/sh
+
+# Copyright (C) 2015 Mathieu Champlon
+#
+# Distributed under the Boost Software License, Version 1.0.
+# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+
+run()
+{
+ echo $@
+ $@
+ r=$?
+ if test $r -ne 0 ; then
+ exit $r
+ fi
+}
+
+copy()
+{
+ for dir; do true; done
+ run mkdir -p $dir
+ run cp $@
+}
+
+run export BOOST=$BOOST_ROOT
+
+run cd ../test
+run $BOOST/b2 -q "$@"
+run cd ../build
+
+run export BOOSTBOOK_DIR=../bin/turtle/boostbook
+run copy -r "$BOOST"/tools/boostbook/xsl $BOOSTBOOK_DIR
+run copy -r "$BOOST"/tools/boostbook/dtd $BOOSTBOOK_DIR
+run copy -r boostbook/* $BOOSTBOOK_DIR
+run copy "$BOOST"/doc/src/boostbook.css ../doc/html
+run copy "$BOOST"/doc/src/images/*.png ../doc/html/images
+run copy "$BOOST"/doc/src/images/callouts/*.png ../doc/html/images/callouts
+run cd ../doc
+run $BOOST/b2 -q "$@"
+run cd ../build
diff --git a/build/build.xml b/build/build.xml
index 633a2c4..dceaa60 100644
--- a/build/build.xml
+++ b/build/build.xml
@@ -1,173 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ${file}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ${file}
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
+
+
-
-
-
+
+
+
+
+
+
+
+
+
+
-
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
+
-
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -214,55 +101,23 @@
-
-
-
-
-
+
+
-
-
-
-
-
-
-
+
-
-
+
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
diff --git a/build/vc100/.gitignore b/build/vc100/.gitignore
new file mode 100644
index 0000000..bacfd8c
--- /dev/null
+++ b/build/vc100/.gitignore
@@ -0,0 +1,3 @@
+/*.opensdf
+/*.sdf
+/*.suo
diff --git a/build/vc100/turtle.vcxproj b/build/vc100/turtle.vcxproj
index 48ffd07..cc9280e 100644
--- a/build/vc100/turtle.vcxproj
+++ b/build/vc100/turtle.vcxproj
@@ -19,45 +19,45 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
{831F2DEE-1E35-4533-A3B2-12C01BA8DA1D}
diff --git a/build/vc100/turtle.vcxproj.filters b/build/vc100/turtle.vcxproj.filters
index 762be52..db9e20b 100644
--- a/build/vc100/turtle.vcxproj.filters
+++ b/build/vc100/turtle.vcxproj.filters
@@ -10,121 +10,121 @@
-
+
Source Files
-
+
Source Files
-
+
Source Files
-
+
Source Files
-
+
Source Files
-
+
Source Files
-
+
Source Files
-
+
Source Files
-
- Source Files\detail
-
-
- Source Files\detail
-
-
- Source Files\detail
-
-
- Source Files\detail
-
-
- Source Files\detail
-
-
- Source Files\detail
-
-
- Source Files\detail
-
-
- Source Files\detail
-
-
- Source Files\detail
-
-
- Source Files\detail
-
-
- Source Files\detail
-
-
- Source Files\detail
-
-
- Source Files\detail
-
-
- Source Files\detail
-
-
- Source Files\detail
-
-
- Source Files\detail
-
-
- Source Files\detail
-
-
+
Source Files
-
+
Source Files
-
+
Source Files
-
+
Source Files
-
- Source Files\detail
-
-
- Source Files\detail
-
-
- Source Files\detail
-
-
- Source Files\detail
-
-
- Source Files\detail
-
-
+
Source Files
-
+
Source Files
-
+
Source Files\detail
-
+
Source Files\detail
-
+
+ Source Files\detail
+
+
+ Source Files\detail
+
+
+ Source Files\detail
+
+
+ Source Files\detail
+
+
+ Source Files\detail
+
+
+ Source Files\detail
+
+
+ Source Files\detail
+
+
+ Source Files\detail
+
+
+ Source Files\detail
+
+
+ Source Files\detail
+
+
+ Source Files\detail
+
+
+ Source Files\detail
+
+
+ Source Files\detail
+
+
+ Source Files\detail
+
+
+ Source Files\detail
+
+
+ Source Files\detail
+
+
+ Source Files\detail
+
+
+ Source Files\detail
+
+
+ Source Files\detail
+
+
+ Source Files\detail
+
+
+ Source Files\detail
+
+
+ Source Files\detail
+
+
Source Files\detail
diff --git a/build/boost/doc/Jamfile.jam b/doc/Jamfile.jam
similarity index 100%
rename from build/boost/doc/Jamfile.jam
rename to doc/Jamfile.jam
diff --git a/build/boost/doc/acknowledgements.qbk b/doc/acknowledgements.qbk
similarity index 100%
rename from build/boost/doc/acknowledgements.qbk
rename to doc/acknowledgements.qbk
diff --git a/build/boost/doc/changelog.qbk b/doc/changelog.qbk
similarity index 99%
rename from build/boost/doc/changelog.qbk
rename to doc/changelog.qbk
index b789ed9..2dd926a 100644
--- a/build/boost/doc/changelog.qbk
+++ b/doc/changelog.qbk
@@ -7,7 +7,7 @@
[section Changelog]
-[section trunk]
+[section unreleased]
Not yet released
* Dropped support for obsolete Boost.Phoenix V2
diff --git a/build/boost/doc/customization.qbk b/doc/customization.qbk
similarity index 100%
rename from build/boost/doc/customization.qbk
rename to doc/customization.qbk
diff --git a/build/boost/doc/example/calculator.hpp b/doc/example/calculator.hpp
similarity index 100%
rename from build/boost/doc/example/calculator.hpp
rename to doc/example/calculator.hpp
diff --git a/build/boost/doc/example/customization.cpp b/doc/example/customization.cpp
similarity index 100%
rename from build/boost/doc/example/customization.cpp
rename to doc/example/customization.cpp
diff --git a/build/boost/doc/example/getting_started.cpp b/doc/example/getting_started.cpp
similarity index 100%
rename from build/boost/doc/example/getting_started.cpp
rename to doc/example/getting_started.cpp
diff --git a/build/boost/doc/example/limitations_comma_in_macro.cpp b/doc/example/limitations_comma_in_macro.cpp
similarity index 95%
rename from build/boost/doc/example/limitations_comma_in_macro.cpp
rename to doc/example/limitations_comma_in_macro.cpp
index 6ae1e50..c19ebdf 100644
--- a/build/boost/doc/example/limitations_comma_in_macro.cpp
+++ b/doc/example/limitations_comma_in_macro.cpp
@@ -1,48 +1,48 @@
-// 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)
-
-#define BOOST_AUTO_TEST_MAIN
-#include
-#include
-
-namespace
-{
-//[ limitations_comma_in_macro_problem
- template< typename T1, typename T2 >
- struct my_base_class
- {};
-//]
-}
-
-namespace limitations_comma_in_macro_solution_1
-{
-//[ limitations_comma_in_macro_solution_1
- typedef my_base_class< int, int > my_base_type;
-
- MOCK_BASE_CLASS( my_mock, my_base_type )
- {};
-//]
-}
-
-namespace limitations_comma_in_macro_solution_2
-{
-//[ limitations_comma_in_macro_solution_2
- template< typename T1, typename T2 >
- MOCK_BASE_CLASS( my_mock, my_base_class< T1 BOOST_PP_COMMA() T2 > )
- {};
-//]
-}
-
-namespace limitations_comma_in_macro_solution_3
-{
-//[ limitations_comma_in_macro_solution_3
- template< typename T1, typename T2 >
- struct my_mock : my_base_class< T1, T2 >, mock::object
- {};
-//]
-}
+// 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)
+
+#define BOOST_AUTO_TEST_MAIN
+#include
+#include
+
+namespace
+{
+//[ limitations_comma_in_macro_problem
+ template< typename T1, typename T2 >
+ struct my_base_class
+ {};
+//]
+}
+
+namespace limitations_comma_in_macro_solution_1
+{
+//[ limitations_comma_in_macro_solution_1
+ typedef my_base_class< int, int > my_base_type;
+
+ MOCK_BASE_CLASS( my_mock, my_base_type )
+ {};
+//]
+}
+
+namespace limitations_comma_in_macro_solution_2
+{
+//[ limitations_comma_in_macro_solution_2
+ template< typename T1, typename T2 >
+ MOCK_BASE_CLASS( my_mock, my_base_class< T1 BOOST_PP_COMMA() T2 > )
+ {};
+//]
+}
+
+namespace limitations_comma_in_macro_solution_3
+{
+//[ limitations_comma_in_macro_solution_3
+ template< typename T1, typename T2 >
+ struct my_mock : my_base_class< T1, T2 >, mock::object
+ {};
+//]
+}
diff --git a/build/boost/doc/example/limitations_const_parameter_warning.cpp b/doc/example/limitations_const_parameter_warning.cpp
similarity index 95%
rename from build/boost/doc/example/limitations_const_parameter_warning.cpp
rename to doc/example/limitations_const_parameter_warning.cpp
index 871e033..531bba2 100644
--- a/build/boost/doc/example/limitations_const_parameter_warning.cpp
+++ b/doc/example/limitations_const_parameter_warning.cpp
@@ -1,50 +1,50 @@
-// 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)
-
-#define BOOST_AUTO_TEST_MAIN
-#include
-#include
-
-namespace
-{
-//[ limitations_const_parameter_warning_problem
- class base
- {
- public:
- virtual void method( const int ) = 0;
- };
-//]
-}
-
-namespace limitations_const_parameter_warning_explanation
-{
-//[ limitations_const_parameter_warning_explanation
- class derived : public base
- {
- public:
- virtual void method( const int );
- };
-
- void derived::method( int )
- {}
-//]
-}
-
-namespace limitations_const_parameter_warning_solution
-{
-//[ limitations_const_parameter_warning_solution
- MOCK_BASE_CLASS( mock_base, base )
- {
- void method( const int i )
- {
- method_stub( i );
- }
- MOCK_METHOD( method_stub, 1, void( int ), method )
- };
-//]
-}
+// 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)
+
+#define BOOST_AUTO_TEST_MAIN
+#include
+#include
+
+namespace
+{
+//[ limitations_const_parameter_warning_problem
+ class base
+ {
+ public:
+ virtual void method( const int ) = 0;
+ };
+//]
+}
+
+namespace limitations_const_parameter_warning_explanation
+{
+//[ limitations_const_parameter_warning_explanation
+ class derived : public base
+ {
+ public:
+ virtual void method( const int );
+ };
+
+ void derived::method( int )
+ {}
+//]
+}
+
+namespace limitations_const_parameter_warning_solution
+{
+//[ limitations_const_parameter_warning_solution
+ MOCK_BASE_CLASS( mock_base, base )
+ {
+ void method( const int i )
+ {
+ method_stub( i );
+ }
+ MOCK_METHOD( method_stub, 1, void( int ), method )
+ };
+//]
+}
diff --git a/build/boost/doc/example/limitations_literal_zero.cpp b/doc/example/limitations_literal_zero.cpp
similarity index 95%
rename from build/boost/doc/example/limitations_literal_zero.cpp
rename to doc/example/limitations_literal_zero.cpp
index 08c2c05..463f4ea 100644
--- a/build/boost/doc/example/limitations_literal_zero.cpp
+++ b/doc/example/limitations_literal_zero.cpp
@@ -1,43 +1,43 @@
-// 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)
-
-#define BOOST_AUTO_TEST_MAIN
-#include
-#include
-
-namespace
-{
-//[ limitations_literal_zero_problem
- class base
- {
- public:
- virtual void method( int* i ) = 0;
- };
-
- MOCK_BASE_CLASS( mock_base, base )
- {
- MOCK_METHOD( method, 1 )
- };
-//]
-}
-
-BOOST_AUTO_TEST_CASE( literal_zero )
-{
- mock_base m;
-//[ limitations_literal_zero_solution_1
- MOCK_EXPECT( m.method ).with( mock::equal< int* >( 0 ) ); // this compiles
-//]
-//[ limitations_literal_zero_solution_2
- MOCK_EXPECT( m.method ).with( mock::negate );
-//]
-#ifdef MOCK_NULLPTR
-//[ limitations_literal_zero_solution_3
- MOCK_EXPECT( m.method ).with( nullptr );
-//]
-#endif
-}
+// 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)
+
+#define BOOST_AUTO_TEST_MAIN
+#include
+#include
+
+namespace
+{
+//[ limitations_literal_zero_problem
+ class base
+ {
+ public:
+ virtual void method( int* i ) = 0;
+ };
+
+ MOCK_BASE_CLASS( mock_base, base )
+ {
+ MOCK_METHOD( method, 1 )
+ };
+//]
+}
+
+BOOST_AUTO_TEST_CASE( literal_zero )
+{
+ mock_base m;
+//[ limitations_literal_zero_solution_1
+ MOCK_EXPECT( m.method ).with( mock::equal< int* >( 0 ) ); // this compiles
+//]
+//[ limitations_literal_zero_solution_2
+ MOCK_EXPECT( m.method ).with( mock::negate );
+//]
+#ifdef MOCK_NULLPTR
+//[ limitations_literal_zero_solution_3
+ MOCK_EXPECT( m.method ).with( nullptr );
+//]
+#endif
+}
diff --git a/build/boost/doc/example/limitations_non_virtual_method.cpp b/doc/example/limitations_non_virtual_method.cpp
similarity index 95%
rename from build/boost/doc/example/limitations_non_virtual_method.cpp
rename to doc/example/limitations_non_virtual_method.cpp
index 019a59e..b6f0457 100644
--- a/build/boost/doc/example/limitations_non_virtual_method.cpp
+++ b/doc/example/limitations_non_virtual_method.cpp
@@ -1,27 +1,27 @@
-// 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)
-
-#define BOOST_AUTO_TEST_MAIN
-#include
-#include
-
-//[ limitations_non_virtual_method_problem
-class base
-{
-public:
- void method() // the method is not virtual
- {}
-};
-//]
-
-//[ limitations_non_virtual_method_problem_2
-MOCK_BASE_CLASS( mock_base, base )
-{
- MOCK_METHOD( method, 0 )
-};
-//]
+// 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)
+
+#define BOOST_AUTO_TEST_MAIN
+#include
+#include
+
+//[ limitations_non_virtual_method_problem
+class base
+{
+public:
+ void method() // the method is not virtual
+ {}
+};
+//]
+
+//[ limitations_non_virtual_method_problem_2
+MOCK_BASE_CLASS( mock_base, base )
+{
+ MOCK_METHOD( method, 0 )
+};
+//]
diff --git a/build/boost/doc/example/limitations_private_method.cpp b/doc/example/limitations_private_method.cpp
similarity index 95%
rename from build/boost/doc/example/limitations_private_method.cpp
rename to doc/example/limitations_private_method.cpp
index e1bf2c6..b03c086 100644
--- a/build/boost/doc/example/limitations_private_method.cpp
+++ b/doc/example/limitations_private_method.cpp
@@ -1,29 +1,29 @@
-// 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)
-
-#define BOOST_AUTO_TEST_MAIN
-#include
-#include
-
-namespace
-{
-//[ limitations_private_method_problem
- class base
- {
- private:
- virtual void method() = 0;
- };
-//]
-
-//[ limitations_private_method_solution
- MOCK_BASE_CLASS( mock_base, base )
- {
- MOCK_METHOD( method, 0, void() )
- };
-//]
-}
+// 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)
+
+#define BOOST_AUTO_TEST_MAIN
+#include
+#include
+
+namespace
+{
+//[ limitations_private_method_problem
+ class base
+ {
+ private:
+ virtual void method() = 0;
+ };
+//]
+
+//[ limitations_private_method_solution
+ MOCK_BASE_CLASS( mock_base, base )
+ {
+ MOCK_METHOD( method, 0, void() )
+ };
+//]
+}
diff --git a/build/boost/doc/example/limitations_template_method.cpp b/doc/example/limitations_template_method.cpp
similarity index 81%
rename from build/boost/doc/example/limitations_template_method.cpp
rename to doc/example/limitations_template_method.cpp
index f89d1fe..c5c0fa7 100644
--- a/build/boost/doc/example/limitations_template_method.cpp
+++ b/doc/example/limitations_template_method.cpp
@@ -1,83 +1,83 @@
-// 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)
-
-#define BOOST_AUTO_TEST_MAIN
-#include
-#include
-
-namespace limitations_template_method_problem
-{
-//[ limitations_template_method_problem
-class concept
-{
-public:
- template< typename T >
- void method( T t )
- {}
-};
-
-template< typename T >
-void function_under_test( T t ) // T is supposed to model the previous concept
-{
- t.method( 42 );
- t.method( "string" );
-}
-//]
-
-//[ limitations_template_method_solution
-MOCK_CLASS( mock_concept )
-{
- MOCK_METHOD( method, 1, void( int ), method_int )
- MOCK_METHOD( method, 1, void( const char* ), method_string )
-};
-//]
-}
-
-namespace limitations_template_method_problem_2
-{
-//[ limitations_template_method_problem_2
-class concept
-{
-public:
- template< typename T >
- T create()
- {
- return T();
- }
-};
-
-template< typename T >
-void function_under_test( T t ) // T is supposed to model the previous concept
-{
- t.create< int >();
- t.create< std::string >();
-}
-//]
-
-//[ limitations_template_method_solution_2
-MOCK_CLASS( mock_concept )
-{
- template< typename T >
- T create();
-
- template<>
- int create< int >()
- {
- return create_int();
- }
- template<>
- std::string create< std::string >()
- {
- return create_string();
- }
-
- MOCK_METHOD( create_int, 0, int(), create_int )
- MOCK_METHOD( create_string, 0, std::string(), create_string )
-};
-//]
-}
+// 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)
+
+#define BOOST_AUTO_TEST_MAIN
+#include
+#include
+
+namespace limitations_template_method_problem
+{
+//[ limitations_template_method_problem
+class concept
+{
+public:
+ template< typename T >
+ void method( T t )
+ {}
+};
+
+template< typename T >
+void function_under_test( T t ) // T is supposed to model the previous concept
+{
+ t.method( 42 );
+ t.method( "string" );
+}
+//]
+
+//[ limitations_template_method_solution
+MOCK_CLASS( mock_concept )
+{
+ MOCK_METHOD( method, 1, void( int ), method_int )
+ MOCK_METHOD( method, 1, void( const char* ), method_string )
+};
+//]
+}
+
+namespace limitations_template_method_problem_2
+{
+//[ limitations_template_method_problem_2
+class concept
+{
+public:
+ template< typename T >
+ T create()
+ {
+ return T();
+ }
+};
+
+template< typename T >
+void function_under_test( T t ) // T is supposed to model the previous concept
+{
+ t.template create< int >();
+ t.template create< std::string >();
+}
+//]
+
+//[ limitations_template_method_solution_2
+MOCK_CLASS( mock_concept )
+{
+ template< typename T >
+ T create();
+
+ MOCK_METHOD( create_int, 0, int(), create_int )
+ MOCK_METHOD( create_string, 0, std::string(), create_string )
+};
+
+template<>
+int mock_concept::create< int >()
+{
+ return create_int();
+}
+template<>
+std::string mock_concept::create< std::string >()
+{
+ return create_string();
+}
+//]
+}
diff --git a/build/boost/doc/example/limitations_throw_specifier.cpp b/doc/example/limitations_throw_specifier.cpp
similarity index 95%
rename from build/boost/doc/example/limitations_throw_specifier.cpp
rename to doc/example/limitations_throw_specifier.cpp
index 89e3913..01e70fe 100644
--- a/build/boost/doc/example/limitations_throw_specifier.cpp
+++ b/doc/example/limitations_throw_specifier.cpp
@@ -1,35 +1,35 @@
-// 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)
-
-#define BOOST_AUTO_TEST_MAIN
-#include
-#include
-
-namespace
-{
-//[ limitations_throw_specifier_problem
- struct base_class
- {
- virtual ~base_class()
- {}
-
- virtual void method() throw ();
- };
-//]
-
-//[ limitations_throw_specifier_solution
- MOCK_BASE_CLASS( mock_class, base_class )
- {
- void method() throw ()
- {
- method_proxy();
- }
- MOCK_METHOD( method_proxy, 0, void(), method )
- };
-//]
-}
+// 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)
+
+#define BOOST_AUTO_TEST_MAIN
+#include
+#include
+
+namespace
+{
+//[ limitations_throw_specifier_problem
+ struct base_class
+ {
+ virtual ~base_class()
+ {}
+
+ virtual void method() throw ();
+ };
+//]
+
+//[ limitations_throw_specifier_solution
+ MOCK_BASE_CLASS( mock_class, base_class )
+ {
+ void method() throw ()
+ {
+ method_proxy();
+ }
+ MOCK_METHOD( method_proxy, 0, void(), method )
+ };
+//]
+}
diff --git a/build/boost/doc/example/mock_view.hpp b/doc/example/mock_view.hpp
similarity index 100%
rename from build/boost/doc/example/mock_view.hpp
rename to doc/example/mock_view.hpp
diff --git a/build/boost/doc/example/motivation.cpp b/doc/example/motivation.cpp
similarity index 93%
rename from build/boost/doc/example/motivation.cpp
rename to doc/example/motivation.cpp
index 89a6bce..9aef368 100644
--- a/build/boost/doc/example/motivation.cpp
+++ b/doc/example/motivation.cpp
@@ -1,76 +1,76 @@
-// 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)
-
-#define BOOST_AUTO_TEST_MAIN
-#include
-#include
-#include "calculator.hpp"
-#include "mock_view.hpp"
-
-namespace simple
-{
-//[ simple_calculator
-class calculator
-{
-public:
- int add( int a, int b );
-};
-//]
-
-//[ simple_zero_plus_zero_is_zero
-BOOST_AUTO_TEST_CASE( zero_plus_zero_is_zero )
-{
- calculator c;
- BOOST_CHECK_EQUAL( 0, c.add( 0, 0 ) );
-}
-//]
-}
-
-namespace without_mock_object
-{
-//[ my_view
-class my_view : public view
-{
-public:
- my_view()
- : called( false )
- {}
- virtual void display( int result )
- {
- called = true;
- value = result;
- }
- bool called;
- int value;
-};
-//]
-
-//[ zero_plus_zero_is_zero_without_mock_object
-BOOST_AUTO_TEST_CASE( zero_plus_zero_is_zero )
-{
- my_view v;
- calculator c( v );
- c.add( 0, 0 );
- BOOST_REQUIRE( v.called );
- BOOST_CHECK_EQUAL( 0, v.value );
-}
-//]
-}
-
-namespace with_mock_object
-{
-//[ zero_plus_zero_is_zero_with_mock_object
-BOOST_AUTO_TEST_CASE( zero_plus_zero_is_zero )
-{
- mock_view v;
- calculator c( v );
- MOCK_EXPECT( v.display ).once().with( 0 ); // expect the 'display' method to be called once (and only once) with a parameter value equal to 0
- c.add( 0, 0 );
-}
-//]
-}
+// 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)
+
+#define BOOST_AUTO_TEST_MAIN
+#include
+#include
+#include "calculator.hpp"
+#include "mock_view.hpp"
+
+namespace simple
+{
+//[ simple_calculator
+class calculator
+{
+public:
+ int add( int a, int b );
+};
+//]
+
+//[ simple_zero_plus_zero_is_zero
+BOOST_AUTO_TEST_CASE( zero_plus_zero_is_zero )
+{
+ calculator c;
+ BOOST_CHECK_EQUAL( 0, c.add( 0, 0 ) );
+}
+//]
+}
+
+namespace without_mock_object
+{
+//[ my_view
+class my_view : public view
+{
+public:
+ my_view()
+ : called( false )
+ {}
+ virtual void display( int result )
+ {
+ called = true;
+ value = result;
+ }
+ bool called;
+ int value;
+};
+//]
+
+//[ zero_plus_zero_is_zero_without_mock_object
+BOOST_AUTO_TEST_CASE( zero_plus_zero_is_zero )
+{
+ my_view v;
+ calculator c( v );
+ c.add( 0, 0 );
+ BOOST_REQUIRE( v.called );
+ BOOST_CHECK_EQUAL( 0, v.value );
+}
+//]
+}
+
+namespace with_mock_object
+{
+//[ zero_plus_zero_is_zero_with_mock_object
+BOOST_AUTO_TEST_CASE( zero_plus_zero_is_zero )
+{
+ mock_view v;
+ calculator c( v );
+ MOCK_EXPECT( v.display ).once().with( 0 ); // expect the 'display' method to be called once (and only once) with a parameter value equal to 0
+ c.add( 0, 0 );
+}
+//]
+}
diff --git a/build/boost/doc/example/patterns_async_call.cpp b/doc/example/patterns_async_call.cpp
similarity index 67%
rename from build/boost/doc/example/patterns_async_call.cpp
rename to doc/example/patterns_async_call.cpp
index 83df2ed..888be3e 100644
--- a/build/boost/doc/example/patterns_async_call.cpp
+++ b/doc/example/patterns_async_call.cpp
@@ -1,61 +1,62 @@
-// 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)
-
-//[ async_call_problem
-namespace
-{
- class base_class
- {
- public:
- virtual void method() = 0;
- };
-
- class my_class
- {
- public:
- explicit my_class( base_class& );
-
- void flush(); // repetitively calling this method will in turn call base_class::method at some point
- };
-}
-//]
-
-//[ async_call_solution
-#define BOOST_AUTO_TEST_MAIN
-#include
-#include
-#include
-#include
-
-namespace
-{
- template< typename F >
- void wait( bool& condition, F flush, int timeout = 100, int sleep = 100 )
- {
- while( !condition && timeout > 0 )
- {
- --timeout;
- boost::this_thread::sleep( boost::posix_time::milliseconds( sleep ) );
- flush();
- }
- }
- MOCK_BASE_CLASS( mock_base_class, base_class )
- {
- MOCK_METHOD( method, 0 )
- };
-}
-
-BOOST_AUTO_TEST_CASE( method_is_called )
-{
- mock_base_class mock;
- my_class c( mock );
- bool done = false;
- MOCK_EXPECT( mock.method ).once().calls( boost::lambda::var( done ) = true ); // when method is called it will set done to true
- wait( done, boost::bind( &my_class::flush, &c ) ); // just wait on done, flushing from time to time
-}
-//]
+// 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)
+
+//[ async_call_problem
+namespace
+{
+ class base_class
+ {
+ public:
+ virtual void method() = 0;
+ };
+
+ class my_class
+ {
+ public:
+ explicit my_class( base_class& );
+
+ void flush(); // repetitively calling this method will in turn call base_class::method at some point
+ };
+}
+//]
+
+//[ async_call_solution
+#define BOOST_AUTO_TEST_MAIN
+#include
+#include
+#include
+#include
+
+namespace
+{
+ template< typename F >
+ void check( bool& condition, F flush, int attempts = 100, int sleep = 100 )
+ {
+ while( !condition && attempts > 0 )
+ {
+ --attempts;
+ boost::this_thread::sleep( boost::posix_time::milliseconds( sleep ) );
+ flush();
+ }
+ }
+
+ MOCK_BASE_CLASS( mock_base_class, base_class )
+ {
+ MOCK_METHOD( method, 0 )
+ };
+}
+
+BOOST_AUTO_TEST_CASE( method_is_called )
+{
+ mock_base_class m;
+ my_class c( m );
+ bool done = false;
+ MOCK_EXPECT( m.method ).once().calls( boost::lambda::var( done ) = true ); // when method is called it will set done to true
+ check( done, boost::bind( &my_class::flush, &c ) ); // just wait on done, flushing from time to time
+}
+//]
diff --git a/build/boost/doc/example/patterns_invoke_functor.cpp b/doc/example/patterns_invoke_functor.cpp
similarity index 96%
rename from build/boost/doc/example/patterns_invoke_functor.cpp
rename to doc/example/patterns_invoke_functor.cpp
index 0faf8e9..a7e0676 100644
--- a/build/boost/doc/example/patterns_invoke_functor.cpp
+++ b/doc/example/patterns_invoke_functor.cpp
@@ -1,44 +1,44 @@
-// 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)
-
-//[ invoke_functor_problem
-#include
-
-namespace
-{
- class base_class
- {
- public:
- virtual void method( boost::function< void( int ) > functor ) = 0;
- };
-
- void function( base_class& ); // the function will call 'method' with a functor to be applied
-}
-//]
-
-//[ invoke_functor_solution
-#define BOOST_AUTO_TEST_MAIN
-#include
-#include
-#include
-
-namespace
-{
- MOCK_BASE_CLASS( mock_class, base_class )
- {
- MOCK_METHOD( method, 1 )
- };
-}
-
-BOOST_AUTO_TEST_CASE( how_to_invoke_a_functor_passed_as_parameter_of_a_mock_method )
-{
- mock_class mock;
- MOCK_EXPECT( mock.method ).calls( boost::bind( boost::apply< void >(), _1, 42 ) ); // whenever 'method' is called, invoke the functor with 42
- function( mock );
-}
-//]
+// 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)
+
+//[ invoke_functor_problem
+#include
+
+namespace
+{
+ class base_class
+ {
+ public:
+ virtual void method( boost::function< void( int ) > functor ) = 0;
+ };
+
+ void function( base_class& ); // the function will call 'method' with a functor to be applied
+}
+//]
+
+//[ invoke_functor_solution
+#define BOOST_AUTO_TEST_MAIN
+#include
+#include
+#include
+
+namespace
+{
+ MOCK_BASE_CLASS( mock_class, base_class )
+ {
+ MOCK_METHOD( method, 1 )
+ };
+}
+
+BOOST_AUTO_TEST_CASE( how_to_invoke_a_functor_passed_as_parameter_of_a_mock_method )
+{
+ mock_class mock;
+ MOCK_EXPECT( mock.method ).calls( boost::bind( boost::apply< void >(), _1, 42 ) ); // whenever 'method' is called, invoke the functor with 42
+ function( mock );
+}
+//]
diff --git a/build/boost/doc/example/patterns_quick_constraint.cpp b/doc/example/patterns_quick_constraint.cpp
similarity index 96%
rename from build/boost/doc/example/patterns_quick_constraint.cpp
rename to doc/example/patterns_quick_constraint.cpp
index eb0821d..f3bc053 100644
--- a/build/boost/doc/example/patterns_quick_constraint.cpp
+++ b/doc/example/patterns_quick_constraint.cpp
@@ -1,54 +1,54 @@
-// 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)
-
-//[ quick_constraint_problem
-#define BOOST_AUTO_TEST_MAIN
-#include
-#include
-#include
-
-namespace
-{
- class my_class
- {
- public:
- explicit my_class( int data )
- : data_( data )
- {}
- int data_;
- };
- std::ostream& operator<<( std::ostream& os, const my_class& c ) // my_class is serializable to an std::ostream
- {
- return os << "my_class( " << c.data_ << " )";
- }
-
- MOCK_CLASS( my_mock )
- {
- MOCK_METHOD( method, 1, void( const my_class& ) ) // how to simply write a custom constraint ?
- };
-}
-//]
-
-//[ quick_constraint_solution
-#include
-
-namespace mock // it could also be in the namespace of 'my_class'
-{
- bool operator==( const my_class& actual, const std::string& expected ) // the first part of the trick is to compare to a string
- {
- return boost::lexical_cast< std::string >( actual ) == expected;
- }
-} // mock
-
-BOOST_AUTO_TEST_CASE( method_is_called )
-{
- my_mock mock;
- MOCK_EXPECT( mock.method ).once().with( "my_class( 42 )" ); // the second part of the trick is to express the constraint as a string
- mock.method( my_class( 42 ) );
-}
-//]
+// 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)
+
+//[ quick_constraint_problem
+#define BOOST_AUTO_TEST_MAIN
+#include
+#include
+#include
+
+namespace
+{
+ class my_class
+ {
+ public:
+ explicit my_class( int data )
+ : data_( data )
+ {}
+ int data_;
+ };
+ std::ostream& operator<<( std::ostream& os, const my_class& c ) // my_class is serializable to an std::ostream
+ {
+ return os << "my_class( " << c.data_ << " )";
+ }
+
+ MOCK_CLASS( my_mock )
+ {
+ MOCK_METHOD( method, 1, void( const my_class& ) ) // how to simply write a custom constraint ?
+ };
+}
+//]
+
+//[ quick_constraint_solution
+#include
+
+namespace mock // it could also be in the namespace of 'my_class'
+{
+ bool operator==( const my_class& actual, const std::string& expected ) // the first part of the trick is to compare to a string
+ {
+ return boost::lexical_cast< std::string >( actual ) == expected;
+ }
+} // mock
+
+BOOST_AUTO_TEST_CASE( method_is_called )
+{
+ my_mock mock;
+ MOCK_EXPECT( mock.method ).once().with( "my_class( 42 )" ); // the second part of the trick is to express the constraint as a string
+ mock.method( my_class( 42 ) );
+}
+//]
diff --git a/build/boost/doc/example/patterns_retrieve_cref.cpp b/doc/example/patterns_retrieve_cref.cpp
similarity index 96%
rename from build/boost/doc/example/patterns_retrieve_cref.cpp
rename to doc/example/patterns_retrieve_cref.cpp
index ffc3f40..8be3e9a 100644
--- a/build/boost/doc/example/patterns_retrieve_cref.cpp
+++ b/doc/example/patterns_retrieve_cref.cpp
@@ -1,50 +1,50 @@
-// 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)
-
-//[ retrieve_cref_problem
-namespace
-{
- class base_class
- {
- public:
- virtual void method( int value ) = 0;
- };
-
- class my_class
- {
- public:
- explicit my_class( base_class& );
-
- void process(); // the processing will call 'method' two times with the same value, but we don't know what value beforehand
- };
-}
-//]
-
-//[ retrieve_cref_solution
-#define BOOST_AUTO_TEST_MAIN
-#include
-#include
-
-namespace
-{
- MOCK_BASE_CLASS( mock_base_class, base_class )
- {
- MOCK_METHOD( method, 1 )
- };
-}
-
-BOOST_AUTO_TEST_CASE( method_is_called_two_times_with_the_same_value )
-{
- mock_base_class mock;
- my_class c( mock );
- int value;
- MOCK_EXPECT( mock.method ).once().with( mock::retrieve( value ) ); // on first call retrieve the value, this expectation takes precedence because it can never fail
- MOCK_EXPECT( mock.method ).once().with( boost::cref( value ) ); // on second call compare the previously retrieved value with the newly received one
- c.process();
-}
-//]
+// 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)
+
+//[ retrieve_cref_problem
+namespace
+{
+ class base_class
+ {
+ public:
+ virtual void method( int value ) = 0;
+ };
+
+ class my_class
+ {
+ public:
+ explicit my_class( base_class& );
+
+ void process(); // the processing will call 'method' two times with the same value, but we don't know what value beforehand
+ };
+}
+//]
+
+//[ retrieve_cref_solution
+#define BOOST_AUTO_TEST_MAIN
+#include
+#include
+
+namespace
+{
+ MOCK_BASE_CLASS( mock_base_class, base_class )
+ {
+ MOCK_METHOD( method, 1 )
+ };
+}
+
+BOOST_AUTO_TEST_CASE( method_is_called_two_times_with_the_same_value )
+{
+ mock_base_class mock;
+ my_class c( mock );
+ int value;
+ MOCK_EXPECT( mock.method ).once().with( mock::retrieve( value ) ); // on first call retrieve the value, this expectation takes precedence because it can never fail
+ MOCK_EXPECT( mock.method ).once().with( boost::cref( value ) ); // on second call compare the previously retrieved value with the newly received one
+ c.process();
+}
+//]
diff --git a/build/boost/doc/example/rationale.cpp b/doc/example/rationale.cpp
similarity index 100%
rename from build/boost/doc/example/rationale.cpp
rename to doc/example/rationale.cpp
diff --git a/build/boost/doc/example/reference.cpp b/doc/example/reference.cpp
similarity index 95%
rename from build/boost/doc/example/reference.cpp
rename to doc/example/reference.cpp
index 1fb520c..fb010ee 100644
--- a/build/boost/doc/example/reference.cpp
+++ b/doc/example/reference.cpp
@@ -1,984 +1,988 @@
-// 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)
-
-#define BOOST_AUTO_TEST_MAIN
-#include
-#include
-
-namespace class_example_1
-{
-//[ class_example_1
-MOCK_CLASS( mock_class )
-{};
-
-BOOST_AUTO_TEST_CASE( demonstrates_instantiating_a_mock_class )
-{
- mock_class c;
-}
-//]
-}
-
-namespace class_example_2
-{
-//[ class_example_2
-template< typename T >
-MOCK_CLASS( mock_class )
-{};
-
-BOOST_AUTO_TEST_CASE( demonstrates_instantiating_a_template_mock_class )
-{
- mock_class< int > c;
-}
-//]
-}
-
-namespace class_example_3
-{
-//[ class_example_3
-struct base_class
-{};
-
-MOCK_BASE_CLASS( mock_class, base_class )
-{};
-
-BOOST_AUTO_TEST_CASE( demonstrates_instantiating_a_derived_mock_class )
-{
- mock_class c;
-}
-//]
-}
-
-namespace class_example_4
-{
-//[ class_example_4
-template< typename T >
-struct base_class
-{};
-
-template< typename T >
-MOCK_BASE_CLASS( mock_class, base_class< T > )
-{};
-
-BOOST_AUTO_TEST_CASE( demonstrates_instantiating_a_template_derived_mock_class )
-{
- mock_class< int > c;
-}
-//]
-}
-
-namespace class_example_5
-{
-//[ class_example_5
-struct name : mock::object // equivalent to using MOCK_CLASS
-{};
-//]
-}
-
-namespace class_example_6
-{
-//[ class_example_6
-template< typename T >
-struct name : mock::object // equivalent to using MOCK_CLASS
-{};
-//]
-}
-
-namespace class_example_7
-{
-//[ class_example_7
-class base
-{};
-
-struct name : base, mock::object // equivalent to using MOCK_BASE_CLASS
-{
- typedef base base_type; // this is required for the shortest form of MOCK_METHOD to work when not using MOCK_BASE_CLASS
-};
-//]
-}
-
-namespace class_example_8
-{
-//[ class_example_8
-template< typename T >
-struct base
-{};
-
-template< typename T >
-struct mock : base< T >, mock::object
-{
- typedef typename base< T > base_type;
-};
-//]
-}
-
-namespace member_function_example_1
-{
-//[ member_function_example_1
-struct base_class
-{
- virtual ~base_class()
- {}
- virtual void method( int ) = 0;
-};
-
-MOCK_BASE_CLASS( mock_class, base_class )
-{
- MOCK_METHOD( method, 1 ) // only possible when referring unambiguously to a base class method
-};
-//]
-}
-
-namespace member_function_example_2
-{
-//[ member_function_example_2
-struct base_class
-{
- virtual ~base_class()
- {}
- virtual void method( int, const std::string& ) = 0;
- virtual void method( float ) = 0;
-};
-
-MOCK_BASE_CLASS( mock_class, base_class )
-{
- MOCK_METHOD( method, 2, void( int, const std::string& ), identifier_1 ) // both the signature and identifier must be specified because of ambiguity due to overloading
- MOCK_METHOD( method, 1, void( float ), identifier_2 ) // the identifier must differ from the previous one in order to fully disambiguate methods
-};
-//]
-}
-
-namespace member_function_example_3
-{
-//[ member_function_example_3
-struct base_class
-{
- virtual ~base_class()
- {}
- virtual void method( float ) = 0;
- virtual void method( float ) const = 0;
-};
-
-MOCK_BASE_CLASS( mock_class, base_class )
-{
- MOCK_METHOD( method, 1, void( float ) ) // this generates both const and non-const versions
-};
-//]
-}
-
-namespace member_function_example_4
-{
-//[ member_function_example_4
-struct base_class
-{
- virtual ~base_class()
- {}
- virtual void method( float ) = 0;
- virtual void method( float ) const = 0;
-};
-
-MOCK_BASE_CLASS( mock_class, base_class )
-{
- MOCK_CONST_METHOD( method, 1, void( float ), identifier_1 ) // this generates only the const version
- MOCK_NON_CONST_METHOD( method, 1, void( float ), identifier_2 ) // this generates only the non-const version, with a different identifier
-};
-//]
-}
-
-namespace member_function_example_5
-{
-//[ member_function_example_5
-struct base_class
-{
- virtual ~base_class()
- {}
- virtual void method( float ) = 0;
-};
-
-struct mock_class : base_class
-{
- typedef base_class base_type; // this is required for MOCK_METHOD to work when not using MOCK_BASE_CLASS
-
- MOCK_METHOD( method, 1 )
-};
-//]
-}
-
-namespace member_function_example_6
-{
-//[ member_function_example_6
-MOCK_CLASS( mock_class )
-{
- MOCK_NON_CONST_METHOD( operator=, 1, mock_class&( const mock_class& ), assignment ) // operators require a custom identifier
-};
-//]
-}
-
-namespace member_function_example_7
-{
-//[ member_function_example_7
-template< typename T >
-MOCK_CLASS( mock_class )
-{
- MOCK_METHOD_TPL( method, 1, void( const T& ) ) // the _TPL variants must be used if the signature includes a template parameter of the class
-};
-//]
-}
-
-namespace member_function_example_8
-{
-//[ member_function_example_8
-MOCK_CLASS( mock_class )
-{
- MOCK_METHOD( method, 0, (std::map< int, int >()) ) // the signature must be surrounded with round parenthesis if the return type contains a comma
-};
-//]
-}
-
-#ifdef BOOST_MSVC
-namespace member_function_example_9
-{
-//[ member_function_example_9
-MOCK_CLASS( mock_class )
-{
- MOCK_METHOD( __stdcall method, 0, void(), method ) // all parameters must be provided when specifying a different calling convention
-};
-//]
-}
-#elif defined( BOOST_GCC )
-namespace member_function_example_10
-{
-//[ member_function_example_10
-MOCK_CLASS( mock_class )
-{
- MOCK_METHOD( __attribute((stdcall)) method, 0, void(), method ) // all parameters must be provided when specifying a different calling convention
-};
-//]
-}
-#endif
-
-namespace static_member_function_example_1
-{
-//[ static_member_function_example_1
-MOCK_CLASS( mock_class )
-{
- MOCK_STATIC_METHOD( method, 1, float( int ) )
-};
-//]
-}
-
-namespace static_member_function_example_2
-{
-//[ static_member_function_example_2
-template< typename T >
-MOCK_CLASS( mock_class )
-{
- MOCK_STATIC_METHOD_TPL( method, 1, void( T ) )
-};
-//]
-}
-
-#ifdef BOOST_MSVC
-namespace static_member_function_example_3
-{
-//[ static_member_function_example_3
-MOCK_CLASS( mock_class )
-{
- MOCK_STATIC_METHOD( __stdcall method, 0, void(), method ) // all parameters must be provided when specifying a different calling convention
-};
-//]
-}
-#elif defined( BOOST_GCC )
-namespace static_member_function_example_4
-{
-//[ static_member_function_example_4
-MOCK_CLASS( mock_class )
-{
- MOCK_STATIC_METHOD( __attribute((stdcall)) method, 0, void(), method ) // all parameters must be provided when specifying a different calling convention
-};
-//]
-}
-#endif
-
-namespace constructor_example_1
-{
-//[ constructor_example_1
-MOCK_CLASS( mock_class )
-{
- MOCK_CONSTRUCTOR( mock_class, 2, ( int, const std::string& ), identifier )
-};
-//]
-}
-
-namespace constructor_example_2
-{
-//[ constructor_example_2
-template< typename T >
-MOCK_CLASS( mock_class )
-{
- MOCK_CONSTRUCTOR( mock_class, 2, ( int, const std::string& ), identifier )
- MOCK_CONSTRUCTOR_TPL( mock_class, 2, ( T, const std::string& ), identifier )
-};
-//]
-}
-
-#ifdef BOOST_MSVC
-namespace constructor_example_3
-{
-//[ constructor_example_3
-MOCK_CLASS( mock_class )
-{
- MOCK_CONSTRUCTOR( __stdcall mock_class, 0, (), constructor )
-};
-//]
-}
-#elif defined( BOOST_GCC )
-namespace constructor_example_4
-{
-//[ constructor_example_4
-MOCK_CLASS( mock_class )
-{
- MOCK_CONSTRUCTOR( __attribute((stdcall)) mock_class, 0, (), constructor )
-};
-//]
-}
-#endif
-
-namespace destructor_example_1
-{
-//[ destructor_example_1
-MOCK_CLASS( mock_class )
-{
- MOCK_DESTRUCTOR( ~mock_class, destructor )
-};
-//]
-}
-
-#ifdef BOOST_MSVC
-namespace destructor_example_2
-{
-//[ destructor_example_2
-MOCK_CLASS( mock_class )
-{
- MOCK_DESTRUCTOR( __stdcall ~mock_class, destructor )
-};
-//]
-}
-#elif defined( BOOST_GCC )
-namespace destructor_example_3
-{
-//[ destructor_example_3
-MOCK_CLASS( mock_class )
-{
- MOCK_DESTRUCTOR( __attribute((stdcall)) ~mock_class, destructor )
-};
-//]
-}
-#endif
-
-namespace conversion_operator_example_1
-{
-//[ conversion_operator_example_1
-MOCK_CLASS( mock_class )
-{
- MOCK_CONVERSION_OPERATOR( operator, int, conversion_to_int )
- MOCK_CONST_CONVERSION_OPERATOR( operator, const std::string&, conversion_to_string )
-};
-//]
-}
-
-namespace conversion_operator_example_2
-{
-//[ conversion_operator_example_2
-template< typename T >
-MOCK_CLASS( mock_class )
-{
- MOCK_CONVERSION_OPERATOR_TPL( operator, T, conversion_to_T ) // the _TPL variants must be used if the signature includes a template parameter of the class
- MOCK_CONST_CONVERSION_OPERATOR( operator, const std::string&, const_conversion_to_string )
- MOCK_NON_CONST_CONVERSION_OPERATOR( operator, const std::string&, non_const_conversion_to_string )
-};
-//]
-}
-
-#ifdef BOOST_MSVC
-namespace conversion_operator_example_3
-{
-//[ conversion_operator_example_3
-MOCK_CLASS( mock_class )
-{
- MOCK_CONVERSION_OPERATOR( __stdcall operator, int, conversion_to_int )
-};
-//]
-}
-#elif defined( BOOST_GCC )
-namespace conversion_operator_example_4
-{
-//[ conversion_operator_example_4
-MOCK_CLASS( mock_class )
-{
- MOCK_CONVERSION_OPERATOR( __attribute((stdcall)) operator, int, conversion_to_int )
-};
-//]
-}
-#endif
-
-namespace function_example_1
-{
-//[ function_example_1
-MOCK_FUNCTION( f, 1, float( int ) )
-
-BOOST_AUTO_TEST_CASE( demonstrates_instantiating_a_mock_function )
-{
- f( 3 );
-}
-//]
-}
-
-#ifdef BOOST_MSVC
-namespace function_example_2
-{
-//[ function_example_2
-MOCK_FUNCTION( __stdcall f, 0, void(), f ) // all parameters must be provided when specifying a different calling convention
-//]
-}
-#elif defined( BOOST_GCC )
-namespace function_example_3
-{
-//[ function_example_3
-MOCK_FUNCTION( __attribute((stdcall)) f, 0, void(), f ) // all parameters must be provided when specifying a different calling convention
-//]
-}
-#endif
-
-namespace functor_example_1
-{
-//[ functor_example_1
-BOOST_AUTO_TEST_CASE( demonstrates_instantiating_a_mock_functor )
-{
- MOCK_FUNCTOR( f, void( int ) );
- f( 3 );
-}
-//]
-}
-
-namespace functor_example_2
-{
-//[ functor_example_2
-template< typename T >
-struct mock_class
-{
- MOCK_FUNCTOR_TPL( f, void( T ) );
-};
-
-BOOST_AUTO_TEST_CASE( demonstrates_instantiating_a_mock_functor )
-{
- mock_class< int > c;
- c.f( 3 );
-}
-//]
-}
-
-namespace expectation_example_1
-{
-//[ expectation_example_1
-MOCK_CLASS( mock_class )
-{
- MOCK_METHOD( method, 1, int( int ), method )
- MOCK_METHOD( method, 2, void( const std::string&, float ), method2 )
-};
-
-BOOST_AUTO_TEST_CASE( demonstrates_configuring_mock_objects )
-{
- mock_class c;
- mock::sequence s;
- MOCK_EXPECT( c.method ).once().with( 0 ).in( s ).returns( 42 );
- MOCK_EXPECT( c.method2 ).never().with( "ok", mock::any );
- MOCK_EXPECT( c.method2 ).at_least( 2 ).in( s ).throws( std::runtime_error( "error !" ) );
-}
-//]
-}
-
-namespace invocation_example_1
-{
-//[ invocation_example_1
-MOCK_CLASS( mock_class )
-{
- MOCK_METHOD( method, 2, void( int, const std::string& ) )
-};
-
-BOOST_AUTO_TEST_CASE( demonstrates_setting_up_invocations_on_a_mock_method )
-{
- mock_class c;
- MOCK_EXPECT( c.method ).once(); // can only be called once
- MOCK_EXPECT( c.method ); // can be called an unlimited number of times
-}
-//]
-}
-
-namespace invocation_example_2
-{
-//[ invocation_example_2
-BOOST_AUTO_TEST_CASE( demonstrates_setting_up_an_invocation_on_a_mock_functor )
-{
- MOCK_FUNCTOR( f, void( int, const std::string& ) );
- MOCK_EXPECT( f ).once();
-}
-//]
-}
-
-namespace invocation_example_3
-{
-//[ invocation_example_3
-MOCK_FUNCTION( f, 1, void( int ) )
-
-BOOST_AUTO_TEST_CASE( demonstrates_setting_up_an_invocation_on_a_mock_function )
-{
- MOCK_EXPECT( f ).once();
-}
-//]
-}
-
-namespace invocation_example_4
-{
-//[ invocation_example_4
-MOCK_CLASS( mock_class )
-{
- MOCK_STATIC_METHOD( method, 1, void( int ) )
-};
-
-BOOST_AUTO_TEST_CASE( demonstrates_setting_up_an_invocation_on_a_mock_static_method )
-{
- mock_class c;
- MOCK_EXPECT( c.method ).once();
- MOCK_EXPECT( mock_class::method ).once(); // does the same
-}
-//]
-}
-
-namespace constraints_example_1
-{
-//[ constraints_example_1
-MOCK_CLASS( mock_class )
-{
- MOCK_METHOD( method, 2, void( int, const std::string& ) )
-};
-
-BOOST_AUTO_TEST_CASE( demonstrates_adding_builtin_constraints )
-{
- mock_class c;
- MOCK_EXPECT( c.method ).with( mock::equal( 3 ), mock::equal( "some string" ) );
- MOCK_EXPECT( c.method ).with( 3, "some string" ); // equivalent to the previous one using short-cuts
-}
-//]
-}
-
-namespace constraints_example_2
-{
-//[ constraints_example_2
-MOCK_CLASS( mock_class )
-{
- MOCK_METHOD( method, 1, void( int ) )
-};
-
-bool custom_constraint( int actual )
-{
- return actual == 42;
-}
-
-BOOST_AUTO_TEST_CASE( demonstrates_adding_a_custom_constraint_with_a_free_function )
-{
- mock_class c;
- MOCK_EXPECT( c.method ).with( &custom_constraint );
-}
-//]
-}
-
-namespace constraints_example_3
-{
-//[ constraints_example_3
-MOCK_CLASS( mock_class )
-{
- MOCK_METHOD( method, 1, void( int ) )
-};
-
-bool custom_constraint( int expected, int actual )
-{
- return expected == actual;
-}
-
-BOOST_AUTO_TEST_CASE( demonstrates_adding_a_custom_constraint_with_a_standard_library_functor )
-{
- mock_class c;
- MOCK_EXPECT( c.method ).with( std::bind1st( std::ptr_fun( &custom_constraint ), 42 ) ); // std::ptr_fun creates an std::unary_function
-}
-//]
-}
-
-namespace constraints_example_4
-{
-//[ constraints_example_4
-MOCK_CLASS( mock_class )
-{
- MOCK_METHOD( method, 1, void( int ) )
-};
-
-bool custom_constraint( int expected, int actual )
-{
- return expected == actual;
-}
-
-BOOST_AUTO_TEST_CASE( demonstrates_adding_a_custom_constraint_with_boost_bind )
-{
- mock_class c;
- MOCK_EXPECT( c.method ).with( boost::bind( &custom_constraint, 42, _1 ) );
-}
-//]
-}
-
-#ifndef BOOST_MSVC // this produces an ICE with all versions of MSVC
-
-#include
-
-namespace constraints_example_5
-{
-//[ constraints_example_5
-MOCK_CLASS( mock_class )
-{
- MOCK_METHOD( method, 1, void( int ) )
-};
-
-BOOST_AUTO_TEST_CASE( demonstrates_adding_a_custom_constraint_with_boost_lambda )
-{
- mock_class c;
- MOCK_EXPECT( c.method ).with( boost::lambda::_1 == 42 );
-}
-//]
-}
-
-#endif // BOOST_MSVC
-
-#include
-
-namespace constraints_example_6
-{
-//[ constraints_example_6
-MOCK_CLASS( mock_class )
-{
- MOCK_METHOD( method, 1, void( int ) )
-};
-
-BOOST_AUTO_TEST_CASE( demonstrates_adding_a_custom_constraint_with_boost_phoenix )
-{
- mock_class c;
- MOCK_EXPECT( c.method ).with( boost::phoenix::arg_names::arg1 == 42 );
- MOCK_EXPECT( c.method ).with( boost::phoenix::arg_names::_1 == 42 );
-}
-//]
-}
-
-#ifdef MOCK_LAMBDAS
-
-namespace constraints_example_7
-{
-//[ constraints_example_7
-MOCK_CLASS( mock_class )
-{
- MOCK_METHOD( method, 1, void( int ) )
-};
-
-BOOST_AUTO_TEST_CASE( demonstrates_adding_a_constraint_with_cxx11_lambda )
-{
- mock_class c;
- MOCK_EXPECT( c.method ).with( []( int actual ) { return 42 == actual; } );
-}
-//]
-}
-
-#endif
-
-namespace constraints_example_8
-{
-//[ constraints_example_8
-MOCK_CLASS( mock_class )
-{
- MOCK_METHOD( method, 2, void( int, const std::string& ) )
-};
-
-BOOST_AUTO_TEST_CASE( demonstrates_combining_constraints )
-{
- mock_class c;
- MOCK_EXPECT( c.method ).with( mock::less( 4 ) && mock::greater( 2 ), ! mock::equal( "" ) );
-}
-//]
-}
-
-namespace sequence_example_1
-{
-//[ sequence_example_1
-MOCK_CLASS( mock_class_1 )
-{
- MOCK_METHOD( method_1, 0, void() )
-};
-
-MOCK_CLASS( mock_class_2 )
-{
- MOCK_METHOD( method_2, 0, void() )
-};
-
-MOCK_CLASS( mock_class_3 )
-{
- MOCK_METHOD( method_3, 0, void() )
-};
-
-BOOST_AUTO_TEST_CASE( demonstrates_enforcing_several_expectation_orders )
-{
- mock_class_1 c_1;
- mock_class_2 c_2;
- mock_class_3 c_3;
- mock::sequence s_1, s_2;
- MOCK_EXPECT( c_1.method_1 ).in( s_1 );
- MOCK_EXPECT( c_2.method_2 ).in( s_2 ); // c_1.method_1 and c_2.method_2 are in different sequences and can be called in any order
- MOCK_EXPECT( c_3.method_3 ).in( s_1, s_2 ); // c_3.method_3 must be called after both c_1.method_1 and c_2.method_2
-}
-//]
-}
-
-namespace action_example_1
-{
-//[ action_example_1
-MOCK_CLASS( mock_class )
-{
- MOCK_METHOD( method, 1, int( int ) )
-};
-
-int function( int i )
-{
- return i;
-}
-
-BOOST_AUTO_TEST_CASE( demonstrates_configuring_actions )
-{
- mock_class c;
- MOCK_EXPECT( c.method ).returns( 42 );
- MOCK_EXPECT( c.method ).moves( 42 ); // returns by moving the value
- MOCK_EXPECT( c.method ).throws( std::runtime_error( "error !" ) );
- MOCK_EXPECT( c.method ).calls( &function ); // forwards 'method' parameter to 'function'
- MOCK_EXPECT( c.method ).calls( boost::bind( &function, 42 ) ); // drops 'method' parameter and binds 42 as parameter to 'function'
- MOCK_EXPECT( c.method ).calls( []( int i ) { return i; } ); // uses a C++11 lambda
-}
-//]
-}
-
-namespace verification_example_1
-{
-//[ verification_example_1
-MOCK_CLASS( mock_class )
-{
- MOCK_METHOD( method, 0, void() )
-};
-
-BOOST_AUTO_TEST_CASE( demonstrates_verifying_a_mock_method )
-{
- mock_class c;
- MOCK_VERIFY( c.method ); // logs an error and returns false if not all expectations are met
- mock::verify( c ); // verifies all expectations set for all methods of 'c'
- mock::verify(); // verifies all existing mock objects, functions and functors
-}
-//]
-}
-
-namespace verification_example_2
-{
-//[ verification_example_2
-BOOST_AUTO_TEST_CASE( demonstrates_verifying_a_mock_functor )
-{
- MOCK_FUNCTOR( f, void( int ) );
- MOCK_VERIFY( f ); // logs an error and returns false if not all expectations are met
- mock::verify( f ); // behaves the same as MOCK_VERIFY
- mock::verify(); // verifies all existing mock objects, functions and functors
-}
-//]
-}
-
-namespace verification_example_3
-{
-//[ verification_example_3
-MOCK_FUNCTION( f, 1, void( int ) )
-
-BOOST_AUTO_TEST_CASE( demonstrates_verifying_a_mock_function )
-{
- MOCK_VERIFY( f ); // logs an error and returns false if not all expectations are met
- mock::verify(); // verifies all existing mock objects, functions and functors
-}
-//]
-}
-
-namespace verification_example_4
-{
-//[ verification_example_4
-MOCK_CLASS( mock_class )
-{
- MOCK_STATIC_METHOD( method, 0, void() )
-};
-
-BOOST_AUTO_TEST_CASE( demonstrates_verifying_a_static_mock_method )
-{
- mock_class c;
- MOCK_VERIFY( c.method ); // logs an error and returns false if not all expectations are met
- MOCK_VERIFY( mock_class::method ); // does the same
- mock::verify(); // verifies all existing mock objects, functions and functors
-}
-//]
-}
-
-namespace reset_example_1
-{
-//[ reset_example_1
-MOCK_CLASS( mock_class )
-{
- MOCK_METHOD( method, 0, void() )
-};
-
-BOOST_AUTO_TEST_CASE( demonstrates_resetting_a_mock_method )
-{
- mock_class c;
- MOCK_RESET( c.method ); // resets all expectations set for 'c.method'
- mock::reset( c ); // resets all expectations set on 'c'
- mock::reset(); // resets all existing mock objects, functions and functors
-}
-//]
-}
-
-namespace reset_example_2
-{
-//[ reset_example_2
-BOOST_AUTO_TEST_CASE( demonstrates_resetting_a_mock_functor )
-{
- MOCK_FUNCTOR( f, void( int ) );
- MOCK_RESET( f ); // resets all expectations set for 'f'
- mock::reset( f ); // behaves the same as MOCK_RESET
- mock::reset(); // resets all existing mock objects, functions and functors
-}
-//]
-}
-
-namespace reset_example_3
-{
-//[ reset_example_3
-MOCK_FUNCTION( f, 1, void( int ) )
-
-BOOST_AUTO_TEST_CASE( demonstrates_resetting_a_mock_function )
-{
- MOCK_RESET( f ); // resets all expectations set for 'f'
- mock::reset(); // resets all existing mock objects, functions and functors
-}
-//]
-}
-
-namespace reset_example_4
-{
-//[ reset_example_4
-MOCK_CLASS( mock_class )
-{
- MOCK_STATIC_METHOD( method, 0, void() )
-};
-
-BOOST_AUTO_TEST_CASE( demonstrates_resetting_a_static_mock_method )
-{
- mock_class c;
- MOCK_RESET( c.method ); // resets all expectations set for 'c::method'
- MOCK_RESET( mock_class::method ); // resets all expectations set for 'c::method'
- mock::reset(); // resets all existing mock objects, functions and functors
-}
-//]
-}
-
-namespace helpers_example_1
-{
-//[ helpers_example_1
-MOCK_CONSTRAINT( any, true ) // this is how mock::any could be defined
-MOCK_CONSTRAINT( forty_two, actual == 42 ) // this defines a 'forty_two' constraint
-
-BOOST_AUTO_TEST_CASE( mock_constraint_0_arity )
-{
- MOCK_FUNCTOR( f, void( int ) );
- MOCK_EXPECT( f ).with( forty_two );
- MOCK_EXPECT( f ).with( any );
-}
-//]
-}
-
-namespace helpers_example_2
-{
-//[ helpers_example_2
-MOCK_CONSTRAINT( equal, expected, actual == expected ) // this is how mock::equal could be defined
-MOCK_CONSTRAINT( near, expected, std::abs( actual - expected ) < 0.01 ) // this defines a 'near' constraint which can be used as 'near( 42 )'
-
-BOOST_AUTO_TEST_CASE( mock_constraint_1_arity )
-{
- MOCK_FUNCTOR( f, void( int ) );
- MOCK_EXPECT( f ).with( near( 42 ) );
- MOCK_EXPECT( f ).with( equal( 42 ) );
-}
-//]
-}
-
-namespace helpers_example_3
-{
-//[ helpers_example_3
-MOCK_CONSTRAINT( near, expected, tolerance, std::abs( actual - expected ) < tolerance ) // this is how mock::near could be defined
-
-BOOST_AUTO_TEST_CASE( mock_constraint_2_arity )
-{
- MOCK_FUNCTOR( f, void( int ) );
- MOCK_EXPECT( f ).with( near( 42, 0.001 ) );
-}
-//]
-}
-
-namespace helpers_example_4
-{
-//[ helpers_example_4
-MOCK_CONSTRAINT_EXT( any, 0,, true ) // this is (almost) how mock::any is defined
-MOCK_CONSTRAINT_EXT( forty_two, 0,, actual == 42 ) // this defines a 'forty_two' constraint
-
-BOOST_AUTO_TEST_CASE( mock_constraint_0_arity )
-{
- MOCK_FUNCTOR( f, void( int ) );
- MOCK_EXPECT( f ).with( forty_two );
- MOCK_EXPECT( f ).with( any );
-}
-//]
-}
-
-namespace helpers_example_5
-{
-//[ helpers_example_5
-MOCK_CONSTRAINT_EXT( equal, 1, ( expected ), actual == expected ) // this is how mock::equal is defined
-MOCK_CONSTRAINT_EXT( near, 1, ( expected ), std::abs( actual - expected ) < 0.01 ) // this defines a 'near' constraint which can be used as 'near( 42 )'
-
-BOOST_AUTO_TEST_CASE( mock_constraint_1_arity )
-{
- MOCK_FUNCTOR( f, void( int ) );
- MOCK_EXPECT( f ).with( near( 42 ) );
- MOCK_EXPECT( f ).with( equal( 42 ) );
-}
-//]
-}
-
-namespace helpers_example_6
-{
-//[ helpers_example_6
-MOCK_CONSTRAINT_EXT( near, 2, ( expected, tolerance ), std::abs( actual - expected ) < tolerance ) // this is how mock::near is defined
-
-BOOST_AUTO_TEST_CASE( mock_constraint_2_arity )
-{
- MOCK_FUNCTOR( f, void( int ) );
- MOCK_EXPECT( f ).with( near( 42, 0.001 ) );
-}
-//]
-}
+// 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)
+
+#define BOOST_AUTO_TEST_MAIN
+#include
+#include
+
+namespace class_example_1
+{
+//[ class_example_1
+MOCK_CLASS( mock_class )
+{};
+
+BOOST_AUTO_TEST_CASE( demonstrates_instantiating_a_mock_class )
+{
+ mock_class c;
+}
+//]
+}
+
+namespace class_example_2
+{
+//[ class_example_2
+template< typename T >
+MOCK_CLASS( mock_class )
+{};
+
+BOOST_AUTO_TEST_CASE( demonstrates_instantiating_a_template_mock_class )
+{
+ mock_class< int > c;
+}
+//]
+}
+
+namespace class_example_3
+{
+//[ class_example_3
+struct base_class
+{};
+
+MOCK_BASE_CLASS( mock_class, base_class )
+{};
+
+BOOST_AUTO_TEST_CASE( demonstrates_instantiating_a_derived_mock_class )
+{
+ mock_class c;
+}
+//]
+}
+
+namespace class_example_4
+{
+//[ class_example_4
+template< typename T >
+struct base_class
+{};
+
+template< typename T >
+MOCK_BASE_CLASS( mock_class, base_class< T > )
+{};
+
+BOOST_AUTO_TEST_CASE( demonstrates_instantiating_a_template_derived_mock_class )
+{
+ mock_class< int > c;
+}
+//]
+}
+
+namespace class_example_5
+{
+//[ class_example_5
+struct name : mock::object // equivalent to using MOCK_CLASS
+{};
+//]
+}
+
+namespace class_example_6
+{
+//[ class_example_6
+template< typename T >
+struct name : mock::object // equivalent to using MOCK_CLASS
+{};
+//]
+}
+
+namespace class_example_7
+{
+//[ class_example_7
+class base
+{};
+
+struct name : base, mock::object // equivalent to using MOCK_BASE_CLASS
+{
+ typedef base base_type; // this is required for the shortest form of MOCK_METHOD to work when not using MOCK_BASE_CLASS
+};
+//]
+}
+
+namespace class_example_8
+{
+//[ class_example_8
+template< typename T >
+struct base
+{};
+
+template< typename T >
+struct name : base< T >, mock::object
+{
+ typedef base< T > base_type;
+};
+//]
+}
+
+namespace member_function_example_1
+{
+//[ member_function_example_1
+struct base_class
+{
+ virtual ~base_class()
+ {}
+ virtual void method( int ) = 0;
+};
+
+MOCK_BASE_CLASS( mock_class, base_class )
+{
+ MOCK_METHOD( method, 1 ) // only possible when referring unambiguously to a base class method
+};
+//]
+}
+
+namespace member_function_example_2
+{
+//[ member_function_example_2
+struct base_class
+{
+ virtual ~base_class()
+ {}
+ virtual void method( int, const std::string& ) = 0;
+ virtual void method( float ) = 0;
+};
+
+MOCK_BASE_CLASS( mock_class, base_class )
+{
+ MOCK_METHOD( method, 2, void( int, const std::string& ), identifier_1 ) // both the signature and identifier must be specified because of ambiguity due to overloading
+ MOCK_METHOD( method, 1, void( float ), identifier_2 ) // the identifier must differ from the previous one in order to fully disambiguate methods
+};
+//]
+}
+
+namespace member_function_example_3
+{
+//[ member_function_example_3
+struct base_class
+{
+ virtual ~base_class()
+ {}
+ virtual void method( float ) = 0;
+ virtual void method( float ) const = 0;
+};
+
+MOCK_BASE_CLASS( mock_class, base_class )
+{
+ MOCK_METHOD( method, 1, void( float ) ) // this generates both const and non-const versions
+};
+//]
+}
+
+namespace member_function_example_4
+{
+//[ member_function_example_4
+struct base_class
+{
+ virtual ~base_class()
+ {}
+ virtual void method( float ) = 0;
+ virtual void method( float ) const = 0;
+};
+
+MOCK_BASE_CLASS( mock_class, base_class )
+{
+ MOCK_CONST_METHOD( method, 1, void( float ), identifier_1 ) // this generates only the const version
+ MOCK_NON_CONST_METHOD( method, 1, void( float ), identifier_2 ) // this generates only the non-const version, with a different identifier
+};
+//]
+}
+
+namespace member_function_example_5
+{
+//[ member_function_example_5
+struct base_class
+{
+ virtual ~base_class()
+ {}
+ virtual void method( float ) = 0;
+};
+
+struct mock_class : base_class
+{
+ typedef base_class base_type; // this is required for MOCK_METHOD to work when not using MOCK_BASE_CLASS
+
+ MOCK_METHOD( method, 1 )
+};
+//]
+}
+
+namespace member_function_example_6
+{
+//[ member_function_example_6
+MOCK_CLASS( mock_class )
+{
+ MOCK_NON_CONST_METHOD( operator=, 1, mock_class&( const mock_class& ), assignment ) // operators require a custom identifier
+};
+//]
+}
+
+namespace member_function_example_7
+{
+//[ member_function_example_7
+template< typename T >
+MOCK_CLASS( mock_class )
+{
+ MOCK_METHOD_TPL( method, 1, void( const T& ) ) // the _TPL variants must be used if the signature includes a template parameter of the class
+};
+//]
+}
+
+namespace member_function_example_8
+{
+//[ member_function_example_8
+MOCK_CLASS( mock_class )
+{
+ MOCK_METHOD( method, 0, (std::map< int, int >()) ) // the signature must be surrounded with round parenthesis if the return type contains a comma
+};
+//]
+}
+
+#ifdef BOOST_MSVC
+namespace member_function_example_9
+{
+//[ member_function_example_9
+MOCK_CLASS( mock_class )
+{
+ MOCK_METHOD( __stdcall method, 0, void(), method ) // all parameters must be provided when specifying a different calling convention
+};
+//]
+}
+#elif defined( BOOST_GCC )
+namespace member_function_example_10
+{
+//[ member_function_example_10
+MOCK_CLASS( mock_class )
+{
+ MOCK_METHOD( __attribute((stdcall)) method, 0, void(), method ) // all parameters must be provided when specifying a different calling convention
+};
+//]
+}
+#endif
+
+namespace static_member_function_example_1
+{
+//[ static_member_function_example_1
+MOCK_CLASS( mock_class )
+{
+ MOCK_STATIC_METHOD( method, 1, float( int ) )
+};
+//]
+}
+
+namespace static_member_function_example_2
+{
+//[ static_member_function_example_2
+template< typename T >
+MOCK_CLASS( mock_class )
+{
+ MOCK_STATIC_METHOD_TPL( method, 1, void( T ) )
+};
+//]
+}
+
+#ifdef BOOST_MSVC
+namespace static_member_function_example_3
+{
+//[ static_member_function_example_3
+MOCK_CLASS( mock_class )
+{
+ MOCK_STATIC_METHOD( __stdcall method, 0, void(), method ) // all parameters must be provided when specifying a different calling convention
+};
+//]
+}
+#elif defined( BOOST_GCC )
+namespace static_member_function_example_4
+{
+//[ static_member_function_example_4
+MOCK_CLASS( mock_class )
+{
+ MOCK_STATIC_METHOD( __attribute((stdcall)) method, 0, void(), method ) // all parameters must be provided when specifying a different calling convention
+};
+//]
+}
+#endif
+
+namespace constructor_example_1
+{
+//[ constructor_example_1
+MOCK_CLASS( mock_class )
+{
+ MOCK_CONSTRUCTOR( mock_class, 2, ( int, const std::string& ), identifier )
+};
+//]
+}
+
+namespace constructor_example_2
+{
+//[ constructor_example_2
+template< typename T >
+MOCK_CLASS( mock_class )
+{
+ MOCK_CONSTRUCTOR( mock_class, 2, ( int, const std::string& ), identifier )
+ MOCK_CONSTRUCTOR_TPL( mock_class, 2, ( T, const std::string& ), identifier_2 )
+};
+//]
+}
+
+#ifdef BOOST_MSVC
+namespace constructor_example_3
+{
+//[ constructor_example_3
+MOCK_CLASS( mock_class )
+{
+ MOCK_CONSTRUCTOR( __stdcall mock_class, 0, (), constructor )
+};
+//]
+}
+#elif defined( BOOST_GCC )
+namespace constructor_example_4
+{
+//[ constructor_example_4
+MOCK_CLASS( mock_class )
+{
+ MOCK_CONSTRUCTOR( __attribute((stdcall)) mock_class, 0, (), constructor )
+};
+//]
+}
+#endif
+
+namespace destructor_example_1
+{
+//[ destructor_example_1
+MOCK_CLASS( mock_class )
+{
+ MOCK_DESTRUCTOR( ~mock_class, destructor )
+};
+//]
+}
+
+#ifdef BOOST_MSVC
+namespace destructor_example_2
+{
+//[ destructor_example_2
+MOCK_CLASS( mock_class )
+{
+ MOCK_DESTRUCTOR( __stdcall ~mock_class, destructor )
+};
+//]
+}
+#elif defined( BOOST_GCC )
+namespace destructor_example_3
+{
+//[ destructor_example_3
+MOCK_CLASS( mock_class )
+{
+ MOCK_DESTRUCTOR( __attribute((stdcall)) ~mock_class, destructor )
+};
+//]
+}
+#endif
+
+namespace conversion_operator_example_1
+{
+//[ conversion_operator_example_1
+MOCK_CLASS( mock_class )
+{
+ MOCK_CONVERSION_OPERATOR( operator, int, conversion_to_int )
+ MOCK_CONST_CONVERSION_OPERATOR( operator, const std::string&, conversion_to_string )
+};
+//]
+}
+
+namespace conversion_operator_example_2
+{
+//[ conversion_operator_example_2
+template< typename T >
+MOCK_CLASS( mock_class )
+{
+ MOCK_CONVERSION_OPERATOR_TPL( operator, T, conversion_to_T ) // the _TPL variants must be used if the signature includes a template parameter of the class
+ MOCK_CONST_CONVERSION_OPERATOR( operator, const std::string&, const_conversion_to_string )
+ MOCK_NON_CONST_CONVERSION_OPERATOR( operator, const std::string&, non_const_conversion_to_string )
+};
+//]
+}
+
+#ifdef BOOST_MSVC
+namespace conversion_operator_example_3
+{
+//[ conversion_operator_example_3
+MOCK_CLASS( mock_class )
+{
+ MOCK_CONVERSION_OPERATOR( __stdcall operator, int, conversion_to_int )
+};
+//]
+}
+#elif defined( BOOST_GCC )
+namespace conversion_operator_example_4
+{
+//[ conversion_operator_example_4
+MOCK_CLASS( mock_class )
+{
+ MOCK_CONVERSION_OPERATOR( __attribute((stdcall)) operator, int, conversion_to_int )
+};
+//]
+}
+#endif
+
+namespace function_example_1
+{
+//[ function_example_1
+MOCK_FUNCTION( f, 1, float( int ) )
+
+BOOST_AUTO_TEST_CASE( demonstrates_instantiating_a_mock_function )
+{
+ f( 3 );
+}
+//]
+}
+
+#ifdef BOOST_MSVC
+namespace function_example_2
+{
+//[ function_example_2
+MOCK_FUNCTION( __stdcall f, 0, void(), f ) // all parameters must be provided when specifying a different calling convention
+//]
+}
+#elif defined( BOOST_GCC )
+namespace function_example_3
+{
+//[ function_example_3
+MOCK_FUNCTION( __attribute((stdcall)) f, 0, void(), f ) // all parameters must be provided when specifying a different calling convention
+//]
+}
+#endif
+
+namespace functor_example_1
+{
+//[ functor_example_1
+BOOST_AUTO_TEST_CASE( demonstrates_instantiating_a_mock_functor )
+{
+ MOCK_FUNCTOR( f, void( int ) );
+ f( 3 );
+}
+//]
+}
+
+namespace functor_example_2
+{
+//[ functor_example_2
+template< typename T >
+struct mock_class
+{
+ MOCK_FUNCTOR_TPL( f, void( T ) );
+};
+
+BOOST_AUTO_TEST_CASE( demonstrates_instantiating_a_mock_functor )
+{
+ mock_class< int > c;
+ c.f( 3 );
+}
+//]
+}
+
+namespace expectation_example_1
+{
+//[ expectation_example_1
+MOCK_CLASS( mock_class )
+{
+ MOCK_METHOD( method, 1, int( int ), method )
+ MOCK_METHOD( method, 2, void( const std::string&, float ), method2 )
+};
+
+BOOST_AUTO_TEST_CASE( demonstrates_configuring_mock_objects )
+{
+ mock_class c;
+ mock::sequence s;
+ MOCK_EXPECT( c.method ).once().with( 0 ).in( s ).returns( 42 );
+ MOCK_EXPECT( c.method2 ).never().with( "ok", mock::any );
+ MOCK_EXPECT( c.method2 ).at_least( 2 ).in( s ).throws( std::runtime_error( "error !" ) );
+}
+//]
+}
+
+namespace invocation_example_1
+{
+//[ invocation_example_1
+MOCK_CLASS( mock_class )
+{
+ MOCK_METHOD( method, 2, void( int, const std::string& ) )
+};
+
+BOOST_AUTO_TEST_CASE( demonstrates_setting_up_invocations_on_a_mock_method )
+{
+ mock_class c;
+ MOCK_EXPECT( c.method ).once(); // can only be called once
+ MOCK_EXPECT( c.method ); // can be called an unlimited number of times
+}
+//]
+}
+
+namespace invocation_example_2
+{
+//[ invocation_example_2
+BOOST_AUTO_TEST_CASE( demonstrates_setting_up_an_invocation_on_a_mock_functor )
+{
+ MOCK_FUNCTOR( f, void( int, const std::string& ) );
+ MOCK_EXPECT( f ).once();
+}
+//]
+}
+
+namespace invocation_example_3
+{
+//[ invocation_example_3
+MOCK_FUNCTION( f, 1, void( int ) )
+
+BOOST_AUTO_TEST_CASE( demonstrates_setting_up_an_invocation_on_a_mock_function )
+{
+ MOCK_EXPECT( f ).once();
+}
+//]
+}
+
+namespace invocation_example_4
+{
+//[ invocation_example_4
+MOCK_CLASS( mock_class )
+{
+ MOCK_STATIC_METHOD( method, 1, void( int ) )
+};
+
+BOOST_AUTO_TEST_CASE( demonstrates_setting_up_an_invocation_on_a_mock_static_method )
+{
+ mock_class c;
+ MOCK_EXPECT( c.method ).once();
+ MOCK_EXPECT( mock_class::method ).once(); // does the same
+}
+//]
+}
+
+namespace constraints_example_1
+{
+//[ constraints_example_1
+MOCK_CLASS( mock_class )
+{
+ MOCK_METHOD( method, 2, void( int, const std::string& ) )
+};
+
+BOOST_AUTO_TEST_CASE( demonstrates_adding_builtin_constraints )
+{
+ mock_class c;
+ MOCK_EXPECT( c.method ).with( mock::equal( 3 ), mock::equal( "some string" ) );
+ MOCK_EXPECT( c.method ).with( 3, "some string" ); // equivalent to the previous one using short-cuts
+}
+//]
+}
+
+namespace constraints_example_2
+{
+//[ constraints_example_2
+MOCK_CLASS( mock_class )
+{
+ MOCK_METHOD( method, 1, void( int ) )
+};
+
+bool custom_constraint( int actual )
+{
+ return actual == 42;
+}
+
+BOOST_AUTO_TEST_CASE( demonstrates_adding_a_custom_constraint_with_a_free_function )
+{
+ mock_class c;
+ MOCK_EXPECT( c.method ).with( &custom_constraint );
+}
+//]
+}
+
+namespace constraints_example_3
+{
+//[ constraints_example_3
+MOCK_CLASS( mock_class )
+{
+ MOCK_METHOD( method, 1, void( int ) )
+};
+
+bool custom_constraint( int expected, int actual )
+{
+ return expected == actual;
+}
+
+BOOST_AUTO_TEST_CASE( demonstrates_adding_a_custom_constraint_with_a_standard_library_functor )
+{
+ mock_class c;
+ MOCK_EXPECT( c.method ).with( std::bind1st( std::ptr_fun( &custom_constraint ), 42 ) ); // std::ptr_fun creates an std::unary_function
+}
+//]
+}
+
+namespace constraints_example_4
+{
+//[ constraints_example_4
+MOCK_CLASS( mock_class )
+{
+ MOCK_METHOD( method, 1, void( int ) )
+};
+
+bool custom_constraint( int expected, int actual )
+{
+ return expected == actual;
+}
+
+BOOST_AUTO_TEST_CASE( demonstrates_adding_a_custom_constraint_with_boost_bind )
+{
+ mock_class c;
+ MOCK_EXPECT( c.method ).with( boost::bind( &custom_constraint, 42, _1 ) );
+}
+//]
+}
+
+#ifndef BOOST_MSVC // this produces an ICE with all versions of MSVC
+
+#include
+
+namespace constraints_example_5
+{
+//[ constraints_example_5
+MOCK_CLASS( mock_class )
+{
+ MOCK_METHOD( method, 1, void( int ) )
+};
+
+BOOST_AUTO_TEST_CASE( demonstrates_adding_a_custom_constraint_with_boost_lambda )
+{
+ mock_class c;
+ MOCK_EXPECT( c.method ).with( boost::lambda::_1 == 42 );
+}
+//]
+}
+
+#endif // BOOST_MSVC
+
+#include
+
+namespace constraints_example_6
+{
+//[ constraints_example_6
+MOCK_CLASS( mock_class )
+{
+ MOCK_METHOD( method, 1, void( int ) )
+};
+
+BOOST_AUTO_TEST_CASE( demonstrates_adding_a_custom_constraint_with_boost_phoenix )
+{
+ mock_class c;
+ MOCK_EXPECT( c.method ).with( boost::phoenix::arg_names::arg1 == 42 );
+ MOCK_EXPECT( c.method ).with( boost::phoenix::arg_names::_1 == 42 );
+}
+//]
+}
+
+#ifdef MOCK_LAMBDAS
+
+namespace constraints_example_7
+{
+//[ constraints_example_7
+MOCK_CLASS( mock_class )
+{
+ MOCK_METHOD( method, 1, void( int ) )
+};
+
+BOOST_AUTO_TEST_CASE( demonstrates_adding_a_constraint_with_cxx11_lambda )
+{
+ mock_class c;
+ MOCK_EXPECT( c.method ).with( []( int actual ) { return 42 == actual; } );
+}
+//]
+}
+
+#endif
+
+namespace constraints_example_8
+{
+//[ constraints_example_8
+MOCK_CLASS( mock_class )
+{
+ MOCK_METHOD( method, 2, void( int, const std::string& ) )
+};
+
+BOOST_AUTO_TEST_CASE( demonstrates_combining_constraints )
+{
+ mock_class c;
+ MOCK_EXPECT( c.method ).with( mock::less( 4 ) && mock::greater( 2 ), ! mock::equal( "" ) );
+}
+//]
+}
+
+namespace sequence_example_1
+{
+//[ sequence_example_1
+MOCK_CLASS( mock_class_1 )
+{
+ MOCK_METHOD( method_1, 0, void() )
+};
+
+MOCK_CLASS( mock_class_2 )
+{
+ MOCK_METHOD( method_2, 0, void() )
+};
+
+MOCK_CLASS( mock_class_3 )
+{
+ MOCK_METHOD( method_3, 0, void() )
+};
+
+BOOST_AUTO_TEST_CASE( demonstrates_enforcing_several_expectation_orders )
+{
+ mock_class_1 c_1;
+ mock_class_2 c_2;
+ mock_class_3 c_3;
+ mock::sequence s_1, s_2;
+ MOCK_EXPECT( c_1.method_1 ).in( s_1 );
+ MOCK_EXPECT( c_2.method_2 ).in( s_2 ); // c_1.method_1 and c_2.method_2 are in different sequences and can be called in any order
+ MOCK_EXPECT( c_3.method_3 ).in( s_1, s_2 ); // c_3.method_3 must be called after both c_1.method_1 and c_2.method_2
+}
+//]
+}
+
+#ifdef MOCK_LAMBDAS
+
+namespace action_example_1
+{
+//[ action_example_1
+MOCK_CLASS( mock_class )
+{
+ MOCK_METHOD( method, 1, int( int ) )
+};
+
+int function( int i )
+{
+ return i;
+}
+
+BOOST_AUTO_TEST_CASE( demonstrates_configuring_actions )
+{
+ mock_class c;
+ MOCK_EXPECT( c.method ).returns( 42 );
+ MOCK_EXPECT( c.method ).moves( 42 ); // returns by moving the value
+ MOCK_EXPECT( c.method ).throws( std::runtime_error( "error !" ) );
+ MOCK_EXPECT( c.method ).calls( &function ); // forwards 'method' parameter to 'function'
+ MOCK_EXPECT( c.method ).calls( boost::bind( &function, 42 ) ); // drops 'method' parameter and binds 42 as parameter to 'function'
+ MOCK_EXPECT( c.method ).calls( []( int i ) { return i; } ); // uses a C++11 lambda
+}
+//]
+}
+
+#endif
+
+namespace verification_example_1
+{
+//[ verification_example_1
+MOCK_CLASS( mock_class )
+{
+ MOCK_METHOD( method, 0, void() )
+};
+
+BOOST_AUTO_TEST_CASE( demonstrates_verifying_a_mock_method )
+{
+ mock_class c;
+ MOCK_VERIFY( c.method ); // logs an error and returns false if not all expectations are met
+ mock::verify( c ); // verifies all expectations set for all methods of 'c'
+ mock::verify(); // verifies all existing mock objects, functions and functors
+}
+//]
+}
+
+namespace verification_example_2
+{
+//[ verification_example_2
+BOOST_AUTO_TEST_CASE( demonstrates_verifying_a_mock_functor )
+{
+ MOCK_FUNCTOR( f, void( int ) );
+ MOCK_VERIFY( f ); // logs an error and returns false if not all expectations are met
+ mock::verify( f ); // behaves the same as MOCK_VERIFY
+ mock::verify(); // verifies all existing mock objects, functions and functors
+}
+//]
+}
+
+namespace verification_example_3
+{
+//[ verification_example_3
+MOCK_FUNCTION( f, 1, void( int ) )
+
+BOOST_AUTO_TEST_CASE( demonstrates_verifying_a_mock_function )
+{
+ MOCK_VERIFY( f ); // logs an error and returns false if not all expectations are met
+ mock::verify(); // verifies all existing mock objects, functions and functors
+}
+//]
+}
+
+namespace verification_example_4
+{
+//[ verification_example_4
+MOCK_CLASS( mock_class )
+{
+ MOCK_STATIC_METHOD( method, 0, void() )
+};
+
+BOOST_AUTO_TEST_CASE( demonstrates_verifying_a_static_mock_method )
+{
+ mock_class c;
+ MOCK_VERIFY( c.method ); // logs an error and returns false if not all expectations are met
+ MOCK_VERIFY( mock_class::method ); // does the same
+ mock::verify(); // verifies all existing mock objects, functions and functors
+}
+//]
+}
+
+namespace reset_example_1
+{
+//[ reset_example_1
+MOCK_CLASS( mock_class )
+{
+ MOCK_METHOD( method, 0, void() )
+};
+
+BOOST_AUTO_TEST_CASE( demonstrates_resetting_a_mock_method )
+{
+ mock_class c;
+ MOCK_RESET( c.method ); // resets all expectations set for 'c.method'
+ mock::reset( c ); // resets all expectations set on 'c'
+ mock::reset(); // resets all existing mock objects, functions and functors
+}
+//]
+}
+
+namespace reset_example_2
+{
+//[ reset_example_2
+BOOST_AUTO_TEST_CASE( demonstrates_resetting_a_mock_functor )
+{
+ MOCK_FUNCTOR( f, void( int ) );
+ MOCK_RESET( f ); // resets all expectations set for 'f'
+ mock::reset( f ); // behaves the same as MOCK_RESET
+ mock::reset(); // resets all existing mock objects, functions and functors
+}
+//]
+}
+
+namespace reset_example_3
+{
+//[ reset_example_3
+MOCK_FUNCTION( f, 1, void( int ) )
+
+BOOST_AUTO_TEST_CASE( demonstrates_resetting_a_mock_function )
+{
+ MOCK_RESET( f ); // resets all expectations set for 'f'
+ mock::reset(); // resets all existing mock objects, functions and functors
+}
+//]
+}
+
+namespace reset_example_4
+{
+//[ reset_example_4
+MOCK_CLASS( mock_class )
+{
+ MOCK_STATIC_METHOD( method, 0, void() )
+};
+
+BOOST_AUTO_TEST_CASE( demonstrates_resetting_a_static_mock_method )
+{
+ mock_class c;
+ MOCK_RESET( c.method ); // resets all expectations set for 'c::method'
+ MOCK_RESET( mock_class::method ); // resets all expectations set for 'c::method'
+ mock::reset(); // resets all existing mock objects, functions and functors
+}
+//]
+}
+
+namespace helpers_example_1
+{
+//[ helpers_example_1
+MOCK_CONSTRAINT( any, true ) // this is how mock::any could be defined
+MOCK_CONSTRAINT( forty_two, actual == 42 ) // this defines a 'forty_two' constraint
+
+BOOST_AUTO_TEST_CASE( mock_constraint_0_arity )
+{
+ MOCK_FUNCTOR( f, void( int ) );
+ MOCK_EXPECT( f ).with( forty_two );
+ MOCK_EXPECT( f ).with( any );
+}
+//]
+}
+
+namespace helpers_example_2
+{
+//[ helpers_example_2
+MOCK_CONSTRAINT( equal, expected, actual == expected ) // this is how mock::equal could be defined
+MOCK_CONSTRAINT( near, expected, std::abs( actual - expected ) < 0.01 ) // this defines a 'near' constraint which can be used as 'near( 42 )'
+
+BOOST_AUTO_TEST_CASE( mock_constraint_1_arity )
+{
+ MOCK_FUNCTOR( f, void( int ) );
+ MOCK_EXPECT( f ).with( near( 42 ) );
+ MOCK_EXPECT( f ).with( equal( 42 ) );
+}
+//]
+}
+
+namespace helpers_example_3
+{
+//[ helpers_example_3
+MOCK_CONSTRAINT( near, expected, tolerance, std::abs( actual - expected ) < tolerance ) // this is how mock::near could be defined
+
+BOOST_AUTO_TEST_CASE( mock_constraint_2_arity )
+{
+ MOCK_FUNCTOR( f, void( int ) );
+ MOCK_EXPECT( f ).with( near( 42, 0.001 ) );
+}
+//]
+}
+
+namespace helpers_example_4
+{
+//[ helpers_example_4
+MOCK_CONSTRAINT_EXT( any, 0,, true ) // this is (almost) how mock::any is defined
+MOCK_CONSTRAINT_EXT( forty_two, 0,, actual == 42 ) // this defines a 'forty_two' constraint
+
+BOOST_AUTO_TEST_CASE( mock_constraint_0_arity )
+{
+ MOCK_FUNCTOR( f, void( int ) );
+ MOCK_EXPECT( f ).with( forty_two );
+ MOCK_EXPECT( f ).with( any );
+}
+//]
+}
+
+namespace helpers_example_5
+{
+//[ helpers_example_5
+MOCK_CONSTRAINT_EXT( equal, 1, ( expected ), actual == expected ) // this is how mock::equal is defined
+MOCK_CONSTRAINT_EXT( near, 1, ( expected ), std::abs( actual - expected ) < 0.01 ) // this defines a 'near' constraint which can be used as 'near( 42 )'
+
+BOOST_AUTO_TEST_CASE( mock_constraint_1_arity )
+{
+ MOCK_FUNCTOR( f, void( int ) );
+ MOCK_EXPECT( f ).with( near( 42 ) );
+ MOCK_EXPECT( f ).with( equal( 42 ) );
+}
+//]
+}
+
+namespace helpers_example_6
+{
+//[ helpers_example_6
+MOCK_CONSTRAINT_EXT( near, 2, ( expected, tolerance ), std::abs( actual - expected ) < tolerance ) // this is how mock::near is defined
+
+BOOST_AUTO_TEST_CASE( mock_constraint_2_arity )
+{
+ MOCK_FUNCTOR( f, void( int ) );
+ MOCK_EXPECT( f ).with( near( 42, 0.001 ) );
+}
+//]
+}
diff --git a/build/boost/doc/example/view.hpp b/doc/example/view.hpp
similarity index 100%
rename from build/boost/doc/example/view.hpp
rename to doc/example/view.hpp
diff --git a/build/boost/doc/getting_started.qbk b/doc/getting_started.qbk
similarity index 100%
rename from build/boost/doc/getting_started.qbk
rename to doc/getting_started.qbk
diff --git a/doc/html/.gitignore b/doc/html/.gitignore
new file mode 100644
index 0000000..df8a062
--- /dev/null
+++ b/doc/html/.gitignore
@@ -0,0 +1,4 @@
+*.css
+*.html
+*.png
+standalone_HTML.manifest
diff --git a/build/boost/doc/images/boost.png b/doc/html/images/boost.png
similarity index 100%
rename from build/boost/doc/images/boost.png
rename to doc/html/images/boost.png
diff --git a/build/boost/doc/limitations.qbk b/doc/limitations.qbk
similarity index 100%
rename from build/boost/doc/limitations.qbk
rename to doc/limitations.qbk
diff --git a/build/boost/doc/mock.qbk b/doc/mock.qbk
similarity index 100%
rename from build/boost/doc/mock.qbk
rename to doc/mock.qbk
diff --git a/build/boost/doc/motivation.qbk b/doc/motivation.qbk
similarity index 100%
rename from build/boost/doc/motivation.qbk
rename to doc/motivation.qbk
diff --git a/build/boost/doc/patterns.qbk b/doc/patterns.qbk
similarity index 100%
rename from build/boost/doc/patterns.qbk
rename to doc/patterns.qbk
diff --git a/build/boost/doc/rationale.qbk b/doc/rationale.qbk
similarity index 100%
rename from build/boost/doc/rationale.qbk
rename to doc/rationale.qbk
diff --git a/build/boost/doc/reference.qbk b/doc/reference.qbk
similarity index 100%
rename from build/boost/doc/reference.qbk
rename to doc/reference.qbk
diff --git a/turtle/config.hpp b/include/turtle/config.hpp
similarity index 96%
rename from turtle/config.hpp
rename to include/turtle/config.hpp
index a09c73a..54000f6 100644
--- a/turtle/config.hpp
+++ b/include/turtle/config.hpp
@@ -1,85 +1,85 @@
-// http://turtle.sourceforge.net
-//
-// Copyright Mathieu Champlon 2009
-//
-// 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)
-
-// boost-no-inspect
-
-#ifndef MOCK_CONFIG_HPP_INCLUDED
-#define MOCK_CONFIG_HPP_INCLUDED
-
-#include
-#include
-#include
-
-#ifndef MOCK_ERROR_POLICY
-# define MOCK_ERROR_POLICY mock::error
-# define MOCK_USE_BOOST_TEST
-#endif
-
-#ifndef MOCK_MAX_ARGS
-# define MOCK_MAX_ARGS 9
-#endif
-
-#ifndef MOCK_MAX_SEQUENCES
-# define MOCK_MAX_SEQUENCES 10
-#endif
-
-#ifndef BOOST_FUNCTION_MAX_ARGS
-# define BOOST_FUNCTION_MAX_ARGS MOCK_MAX_ARGS
-#elif BOOST_PP_LESS(BOOST_FUNCTION_MAX_ARGS, MOCK_MAX_ARGS)
-# error BOOST_FUNCTION_MAX_ARGS must be set to MOCK_MAX_ARGS or higher
-#endif
-
-#ifndef BOOST_FT_MAX_ARITY
-# define BOOST_FT_MAX_ARITY BOOST_PP_INC(MOCK_MAX_ARGS)
-#elif BOOST_PP_LESS_EQUAL(BOOST_FT_MAX_ARITY, MOCK_MAX_ARGS)
-# error BOOST_FT_MAX_ARITY must be set to MOCK_MAX_ARGS + 1 or higher
-#endif
-
-#if !defined(BOOST_NO_CXX11_NULLPTR) && !defined(BOOST_NO_NULLPTR)
-# ifndef MOCK_NO_NULLPTR
-# define MOCK_NULLPTR
-# endif
-#endif
-
-#if !defined(BOOST_NO_CXX11_DECLTYPE) && !defined(BOOST_NO_DECLTYPE)
-# ifndef MOCK_NO_DECLTYPE
-# define MOCK_DECLTYPE
-# endif
-#endif
-
-#if !defined(BOOST_NO_CXX11_VARIADIC_MACROS) && !defined(BOOST_NO_VARIADIC_MACROS)
-# ifndef MOCK_NO_VARIADIC_MACROS
-# define MOCK_VARIADIC_MACROS
-# endif
-#endif
-
-#if !defined(BOOST_NO_CXX11_SMART_PTR) && !defined(BOOST_NO_SMART_PTR)
-# ifndef MOCK_NO_SMART_PTR
-# define MOCK_SMART_PTR
-# endif
-#endif
-
-#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_NO_RVALUE_REFERENCES)
-# ifndef MOCK_NO_RVALUE_REFERENCES
-# define MOCK_RVALUE_REFERENCES
-# endif
-#endif
-
-#if !defined(BOOST_NO_CXX11_HDR_MUTEX) && !defined(BOOST_NO_0X_HDR_MUTEX)
-# ifndef MOCK_NO_HDR_MUTEX
-# define MOCK_HDR_MUTEX
-# endif
-#endif
-
-#if !defined(BOOST_NO_CXX11_LAMBDAS) && !defined(BOOST_NO_LAMBDAS)
-# ifndef MOCK_NO_LAMBDAS
-# define MOCK_LAMBDAS
-# endif
-#endif
-
-#endif // MOCK_CONFIG_HPP_INCLUDED
+// http://turtle.sourceforge.net
+//
+// Copyright Mathieu Champlon 2009
+//
+// 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)
+
+// boost-no-inspect
+
+#ifndef MOCK_CONFIG_HPP_INCLUDED
+#define MOCK_CONFIG_HPP_INCLUDED
+
+#include
+#include
+#include
+
+#ifndef MOCK_ERROR_POLICY
+# define MOCK_ERROR_POLICY mock::error
+# define MOCK_USE_BOOST_TEST
+#endif
+
+#ifndef MOCK_MAX_ARGS
+# define MOCK_MAX_ARGS 9
+#endif
+
+#ifndef MOCK_MAX_SEQUENCES
+# define MOCK_MAX_SEQUENCES 10
+#endif
+
+#ifndef BOOST_FUNCTION_MAX_ARGS
+# define BOOST_FUNCTION_MAX_ARGS MOCK_MAX_ARGS
+#elif BOOST_PP_LESS(BOOST_FUNCTION_MAX_ARGS, MOCK_MAX_ARGS)
+# error BOOST_FUNCTION_MAX_ARGS must be set to MOCK_MAX_ARGS or higher
+#endif
+
+#ifndef BOOST_FT_MAX_ARITY
+# define BOOST_FT_MAX_ARITY BOOST_PP_INC(MOCK_MAX_ARGS)
+#elif BOOST_PP_LESS_EQUAL(BOOST_FT_MAX_ARITY, MOCK_MAX_ARGS)
+# error BOOST_FT_MAX_ARITY must be set to MOCK_MAX_ARGS + 1 or higher
+#endif
+
+#if !defined(BOOST_NO_CXX11_NULLPTR) && !defined(BOOST_NO_NULLPTR)
+# ifndef MOCK_NO_NULLPTR
+# define MOCK_NULLPTR
+# endif
+#endif
+
+#if !defined(BOOST_NO_CXX11_DECLTYPE) && !defined(BOOST_NO_DECLTYPE)
+# ifndef MOCK_NO_DECLTYPE
+# define MOCK_DECLTYPE
+# endif
+#endif
+
+#if !defined(BOOST_NO_CXX11_VARIADIC_MACROS) && !defined(BOOST_NO_VARIADIC_MACROS)
+# ifndef MOCK_NO_VARIADIC_MACROS
+# define MOCK_VARIADIC_MACROS
+# endif
+#endif
+
+#if !defined(BOOST_NO_CXX11_SMART_PTR) && !defined(BOOST_NO_SMART_PTR)
+# ifndef MOCK_NO_SMART_PTR
+# define MOCK_SMART_PTR
+# endif
+#endif
+
+#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_NO_RVALUE_REFERENCES)
+# ifndef MOCK_NO_RVALUE_REFERENCES
+# define MOCK_RVALUE_REFERENCES
+# endif
+#endif
+
+#if !defined(BOOST_NO_CXX11_HDR_MUTEX) && !defined(BOOST_NO_0X_HDR_MUTEX)
+# ifndef MOCK_NO_HDR_MUTEX
+# define MOCK_HDR_MUTEX
+# endif
+#endif
+
+#if !defined(BOOST_NO_CXX11_LAMBDAS) && !defined(BOOST_NO_LAMBDAS)
+# ifndef MOCK_NO_LAMBDAS
+# define MOCK_LAMBDAS
+# endif
+#endif
+
+#endif // MOCK_CONFIG_HPP_INCLUDED
diff --git a/turtle/constraint.hpp b/include/turtle/constraint.hpp
similarity index 96%
rename from turtle/constraint.hpp
rename to include/turtle/constraint.hpp
index b30a469..32329c2 100644
--- a/turtle/constraint.hpp
+++ b/include/turtle/constraint.hpp
@@ -1,247 +1,247 @@
-// http://turtle.sourceforge.net
-//
-// Copyright Mathieu Champlon 2008
-//
-// 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)
-
-#ifndef MOCK_CONSTRAINT_HPP_INCLUDED
-#define MOCK_CONSTRAINT_HPP_INCLUDED
-
-#include "config.hpp"
-#include "log.hpp"
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-namespace mock
-{
- template< typename Constraint >
- struct constraint
- {
- constraint()
- {}
- constraint( const Constraint& c )
- : c_( c )
- {}
- Constraint c_;
- };
-
-namespace detail
-{
- template< typename Lhs, typename Rhs >
- class and_
- {
- public:
- and_( const Lhs& lhs, const Rhs& rhs )
- : lhs_( lhs )
- , rhs_( rhs )
- {}
- template< typename Actual >
- bool operator()( const Actual& actual ) const
- {
- return lhs_( actual ) && rhs_( actual );
- }
- friend std::ostream& operator<<( std::ostream& s, const and_& a )
- {
- return s << "( " << mock::format( a.lhs_ )
- << " && " << mock::format( a.rhs_ ) << " )";
- }
- private:
- Lhs lhs_;
- Rhs rhs_;
- };
-
- template< typename Lhs, typename Rhs >
- class or_
- {
- public:
- or_( const Lhs& lhs, const Rhs& rhs )
- : lhs_( lhs )
- , rhs_( rhs )
- {}
- template< typename Actual >
- bool operator()( const Actual& actual ) const
- {
- return lhs_( actual ) || rhs_( actual );
- }
- friend std::ostream& operator<<( std::ostream& s, const or_& o )
- {
- return s << "( " << mock::format( o.lhs_ )
- << " || " << mock::format( o.rhs_ )<< " )";
- }
- private:
- Lhs lhs_;
- Rhs rhs_;
- };
-
- template< typename Constraint >
- class not_
- {
- public:
- explicit not_( const Constraint& c )
- : c_( c )
- {}
- template< typename Actual >
- bool operator()( const Actual& actual ) const
- {
- return ! c_( actual );
- }
- friend std::ostream& operator<<( std::ostream& s, const not_& n )
- {
- return s << "! " << mock::format( n.c_ );
- }
- private:
- Constraint c_;
- };
-}
-
- template< typename Lhs, typename Rhs >
- const constraint< detail::or_< Lhs, Rhs > >
- operator||( const constraint< Lhs >& lhs,
- const constraint< Rhs >& rhs )
- {
- return detail::or_< Lhs, Rhs >( lhs.c_, rhs.c_ );
- }
-
- template< typename Lhs, typename Rhs >
- const constraint< detail::and_< Lhs, Rhs > >
- operator&&( const constraint< Lhs >& lhs,
- const constraint< Rhs >& rhs )
- {
- return detail::and_< Lhs, Rhs >( lhs.c_, rhs.c_ );
- }
-
- template< typename Constraint >
- const constraint< detail::not_< Constraint > >
- operator!( const constraint< Constraint >& c )
- {
- return detail::not_< Constraint >( c.c_ );
- }
-} // mock
-
-#define MOCK_UNARY_CONSTRAINT(Name, n, Args, Expr) \
- namespace detail \
- { \
- struct Name \
- { \
- template< typename Actual > \
- bool operator()( const Actual& actual ) const \
- { \
- return Expr; \
- } \
- friend std::ostream& operator<<( std::ostream& s, const Name& ) \
- { \
- return s << BOOST_STRINGIZE(Name); \
- } \
- }; \
- } \
- const mock::constraint< detail::Name > Name;
-
-#define MOCK_CONSTRAINT_ASSIGN(z, n, d) \
- expected##n( e##n )
-
-#define MOCK_CONSTRAINT_UNWRAP_REF(z, n, d) \
- boost::unwrap_ref( expected##n )
-
-#define MOCK_CONSTRAINT_FORMAT(z, n, d) \
- BOOST_PP_IF(n, << ", " <<,) mock::format( c.expected##n )
-
-#define MOCK_CONSTRAINT_MEMBER(z, n, d) \
- Expected_##n expected##n;
-
-#define MOCK_CONSTRAINT_CREF_PARAM(z, n, Args) \
- typename \
- boost::unwrap_reference< Expected_##n >::type \
- BOOST_PP_ARRAY_ELEM(n, Args)
-
-#define MOCK_CONSTRAINT_PARAM(z, n, Args) \
- T##n BOOST_PP_ARRAY_ELEM(n, Args)
-
-#define MOCK_NARY_CONSTRAINT(Name, n, Args, Expr) \
- namespace detail \
- { \
- template< BOOST_PP_ENUM_PARAMS(n, typename Expected_) > \
- struct Name \
- { \
- explicit Name( \
- BOOST_PP_ENUM_BINARY_PARAMS(n, const Expected_, & e) ) \
- : BOOST_PP_ENUM(n, MOCK_CONSTRAINT_ASSIGN, _) \
- {} \
- template< typename Actual > \
- bool operator()( const Actual& actual ) const \
- { \
- return test( actual, \
- BOOST_PP_ENUM(n, MOCK_CONSTRAINT_UNWRAP_REF, _) ); \
- } \
- template< typename Actual > \
- bool test( const Actual& actual, \
- BOOST_PP_ENUM(n, \
- MOCK_CONSTRAINT_CREF_PARAM, (n, Args)) ) const \
- { \
- return Expr; \
- } \
- friend std::ostream& operator<<( std::ostream& s, const Name& c ) \
- { \
- return s << BOOST_STRINGIZE(Name) << "( " \
- << BOOST_PP_REPEAT(n, MOCK_CONSTRAINT_FORMAT, _) \
- << " )"; \
- } \
- BOOST_PP_REPEAT(n, MOCK_CONSTRAINT_MEMBER, _) \
- }; \
- } \
- template< BOOST_PP_ENUM_PARAMS(n, typename T) > \
- mock::constraint< \
- detail::Name< BOOST_PP_ENUM_PARAMS(n, T) > \
- > Name( BOOST_PP_ENUM(n, MOCK_CONSTRAINT_PARAM, (n, Args)) ) \
- { \
- return detail::Name< BOOST_PP_ENUM_PARAMS(n, T) > Args; \
- }
-
-#define MOCK_CONSTRAINT_EXT(Name, n, Args, Expr) \
- BOOST_PP_IF(n, \
- MOCK_NARY_CONSTRAINT, \
- MOCK_UNARY_CONSTRAINT)(Name, n, Args, Expr)
-
-#ifdef MOCK_VARIADIC_MACROS
-
-#if BOOST_MSVC
-# define MOCK_VARIADIC_SIZE(...) \
- BOOST_PP_CAT(MOCK_VARIADIC_SIZE_I(__VA_ARGS__, \
- 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, \
- 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, \
- 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1,),)
-#else // BOOST_MSVC
-# define MOCK_VARIADIC_SIZE(...) \
- MOCK_VARIADIC_SIZE_I(__VA_ARGS__, \
- 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, \
- 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, \
- 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1,)
-#endif // BOOST_MSVC
-#define MOCK_VARIADIC_SIZE_I( \
- e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, \
- e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, \
- e25, e26, e27, e28, e29, e30, e31, size, ...) size
-
-#define MOCK_CONSTRAINT_AUX_AUX(Name, n, Array) \
- MOCK_CONSTRAINT_EXT( \
- Name, n, \
- BOOST_PP_ARRAY_TO_TUPLE(BOOST_PP_ARRAY_POP_BACK(Array)), \
- BOOST_PP_ARRAY_ELEM(n, Array))
-
-#define MOCK_CONSTRAINT_AUX(Name, Size, Tuple) \
- MOCK_CONSTRAINT_AUX_AUX(Name, BOOST_PP_DEC(Size), (Size,Tuple))
-
-#define MOCK_CONSTRAINT(Name, ...) \
- MOCK_CONSTRAINT_AUX( \
- Name, MOCK_VARIADIC_SIZE(__VA_ARGS__), (__VA_ARGS__))
-
-#endif // MOCK_VARIADIC_MACROS
-
-#endif // MOCK_CONSTRAINT_HPP_INCLUDED
+// http://turtle.sourceforge.net
+//
+// Copyright Mathieu Champlon 2008
+//
+// 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)
+
+#ifndef MOCK_CONSTRAINT_HPP_INCLUDED
+#define MOCK_CONSTRAINT_HPP_INCLUDED
+
+#include "config.hpp"
+#include "log.hpp"
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+namespace mock
+{
+ template< typename Constraint >
+ struct constraint
+ {
+ constraint()
+ {}
+ constraint( const Constraint& c )
+ : c_( c )
+ {}
+ Constraint c_;
+ };
+
+namespace detail
+{
+ template< typename Lhs, typename Rhs >
+ class and_
+ {
+ public:
+ and_( const Lhs& lhs, const Rhs& rhs )
+ : lhs_( lhs )
+ , rhs_( rhs )
+ {}
+ template< typename Actual >
+ bool operator()( const Actual& actual ) const
+ {
+ return lhs_( actual ) && rhs_( actual );
+ }
+ friend std::ostream& operator<<( std::ostream& s, const and_& a )
+ {
+ return s << "( " << mock::format( a.lhs_ )
+ << " && " << mock::format( a.rhs_ ) << " )";
+ }
+ private:
+ Lhs lhs_;
+ Rhs rhs_;
+ };
+
+ template< typename Lhs, typename Rhs >
+ class or_
+ {
+ public:
+ or_( const Lhs& lhs, const Rhs& rhs )
+ : lhs_( lhs )
+ , rhs_( rhs )
+ {}
+ template< typename Actual >
+ bool operator()( const Actual& actual ) const
+ {
+ return lhs_( actual ) || rhs_( actual );
+ }
+ friend std::ostream& operator<<( std::ostream& s, const or_& o )
+ {
+ return s << "( " << mock::format( o.lhs_ )
+ << " || " << mock::format( o.rhs_ )<< " )";
+ }
+ private:
+ Lhs lhs_;
+ Rhs rhs_;
+ };
+
+ template< typename Constraint >
+ class not_
+ {
+ public:
+ explicit not_( const Constraint& c )
+ : c_( c )
+ {}
+ template< typename Actual >
+ bool operator()( const Actual& actual ) const
+ {
+ return ! c_( actual );
+ }
+ friend std::ostream& operator<<( std::ostream& s, const not_& n )
+ {
+ return s << "! " << mock::format( n.c_ );
+ }
+ private:
+ Constraint c_;
+ };
+}
+
+ template< typename Lhs, typename Rhs >
+ const constraint< detail::or_< Lhs, Rhs > >
+ operator||( const constraint< Lhs >& lhs,
+ const constraint< Rhs >& rhs )
+ {
+ return detail::or_< Lhs, Rhs >( lhs.c_, rhs.c_ );
+ }
+
+ template< typename Lhs, typename Rhs >
+ const constraint< detail::and_< Lhs, Rhs > >
+ operator&&( const constraint< Lhs >& lhs,
+ const constraint< Rhs >& rhs )
+ {
+ return detail::and_< Lhs, Rhs >( lhs.c_, rhs.c_ );
+ }
+
+ template< typename Constraint >
+ const constraint< detail::not_< Constraint > >
+ operator!( const constraint< Constraint >& c )
+ {
+ return detail::not_< Constraint >( c.c_ );
+ }
+} // mock
+
+#define MOCK_UNARY_CONSTRAINT(Name, n, Args, Expr) \
+ namespace detail \
+ { \
+ struct Name \
+ { \
+ template< typename Actual > \
+ bool operator()( const Actual& actual ) const \
+ { \
+ return Expr; \
+ } \
+ friend std::ostream& operator<<( std::ostream& s, const Name& ) \
+ { \
+ return s << BOOST_STRINGIZE(Name); \
+ } \
+ }; \
+ } \
+ const mock::constraint< detail::Name > Name;
+
+#define MOCK_CONSTRAINT_ASSIGN(z, n, d) \
+ expected##n( e##n )
+
+#define MOCK_CONSTRAINT_UNWRAP_REF(z, n, d) \
+ boost::unwrap_ref( expected##n )
+
+#define MOCK_CONSTRAINT_FORMAT(z, n, d) \
+ BOOST_PP_IF(n, << ", " <<,) mock::format( c.expected##n )
+
+#define MOCK_CONSTRAINT_MEMBER(z, n, d) \
+ Expected_##n expected##n;
+
+#define MOCK_CONSTRAINT_CREF_PARAM(z, n, Args) \
+ typename \
+ boost::unwrap_reference< Expected_##n >::type \
+ BOOST_PP_ARRAY_ELEM(n, Args)
+
+#define MOCK_CONSTRAINT_PARAM(z, n, Args) \
+ T##n BOOST_PP_ARRAY_ELEM(n, Args)
+
+#define MOCK_NARY_CONSTRAINT(Name, n, Args, Expr) \
+ namespace detail \
+ { \
+ template< BOOST_PP_ENUM_PARAMS(n, typename Expected_) > \
+ struct Name \
+ { \
+ explicit Name( \
+ BOOST_PP_ENUM_BINARY_PARAMS(n, const Expected_, & e) ) \
+ : BOOST_PP_ENUM(n, MOCK_CONSTRAINT_ASSIGN, _) \
+ {} \
+ template< typename Actual > \
+ bool operator()( const Actual& actual ) const \
+ { \
+ return test( actual, \
+ BOOST_PP_ENUM(n, MOCK_CONSTRAINT_UNWRAP_REF, _) ); \
+ } \
+ template< typename Actual > \
+ bool test( const Actual& actual, \
+ BOOST_PP_ENUM(n, \
+ MOCK_CONSTRAINT_CREF_PARAM, (n, Args)) ) const \
+ { \
+ return Expr; \
+ } \
+ friend std::ostream& operator<<( std::ostream& s, const Name& c ) \
+ { \
+ return s << BOOST_STRINGIZE(Name) << "( " \
+ << BOOST_PP_REPEAT(n, MOCK_CONSTRAINT_FORMAT, _) \
+ << " )"; \
+ } \
+ BOOST_PP_REPEAT(n, MOCK_CONSTRAINT_MEMBER, _) \
+ }; \
+ } \
+ template< BOOST_PP_ENUM_PARAMS(n, typename T) > \
+ mock::constraint< \
+ detail::Name< BOOST_PP_ENUM_PARAMS(n, T) > \
+ > Name( BOOST_PP_ENUM(n, MOCK_CONSTRAINT_PARAM, (n, Args)) ) \
+ { \
+ return detail::Name< BOOST_PP_ENUM_PARAMS(n, T) > Args; \
+ }
+
+#define MOCK_CONSTRAINT_EXT(Name, n, Args, Expr) \
+ BOOST_PP_IF(n, \
+ MOCK_NARY_CONSTRAINT, \
+ MOCK_UNARY_CONSTRAINT)(Name, n, Args, Expr)
+
+#ifdef MOCK_VARIADIC_MACROS
+
+#if BOOST_MSVC
+# define MOCK_VARIADIC_SIZE(...) \
+ BOOST_PP_CAT(MOCK_VARIADIC_SIZE_I(__VA_ARGS__, \
+ 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, \
+ 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, \
+ 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1,),)
+#else // BOOST_MSVC
+# define MOCK_VARIADIC_SIZE(...) \
+ MOCK_VARIADIC_SIZE_I(__VA_ARGS__, \
+ 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, \
+ 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, \
+ 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1,)
+#endif // BOOST_MSVC
+#define MOCK_VARIADIC_SIZE_I( \
+ e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, \
+ e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, \
+ e25, e26, e27, e28, e29, e30, e31, size, ...) size
+
+#define MOCK_CONSTRAINT_AUX_AUX(Name, n, Array) \
+ MOCK_CONSTRAINT_EXT( \
+ Name, n, \
+ BOOST_PP_ARRAY_TO_TUPLE(BOOST_PP_ARRAY_POP_BACK(Array)), \
+ BOOST_PP_ARRAY_ELEM(n, Array))
+
+#define MOCK_CONSTRAINT_AUX(Name, Size, Tuple) \
+ MOCK_CONSTRAINT_AUX_AUX(Name, BOOST_PP_DEC(Size), (Size,Tuple))
+
+#define MOCK_CONSTRAINT(Name, ...) \
+ MOCK_CONSTRAINT_AUX( \
+ Name, MOCK_VARIADIC_SIZE(__VA_ARGS__), (__VA_ARGS__))
+
+#endif // MOCK_VARIADIC_MACROS
+
+#endif // MOCK_CONSTRAINT_HPP_INCLUDED
diff --git a/turtle/constraints.hpp b/include/turtle/constraints.hpp
similarity index 96%
rename from turtle/constraints.hpp
rename to include/turtle/constraints.hpp
index f74eeca..bc7ea28 100644
--- a/turtle/constraints.hpp
+++ b/include/turtle/constraints.hpp
@@ -1,201 +1,201 @@
-// http://turtle.sourceforge.net
-//
-// Copyright Mathieu Champlon 2008
-//
-// 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)
-
-#ifndef MOCK_CONSTRAINTS_HPP_INCLUDED
-#define MOCK_CONSTRAINTS_HPP_INCLUDED
-
-#include "config.hpp"
-#include "constraint.hpp"
-#include "detail/addressof.hpp"
-#include
-#include
-#include
-#include
-
-namespace mock
-{
- MOCK_UNARY_CONSTRAINT( any, 0,, true && &actual )
- MOCK_UNARY_CONSTRAINT( affirm, 0,, !! actual )
- MOCK_UNARY_CONSTRAINT( negate, 0,, ! actual )
- MOCK_UNARY_CONSTRAINT( evaluate, 0,, actual() )
-
- MOCK_NARY_CONSTRAINT( equal, 1, ( expected ), actual == expected )
- MOCK_NARY_CONSTRAINT( less, 1, ( expected ), actual < expected )
- MOCK_NARY_CONSTRAINT( greater, 1, ( expected ), actual > expected )
- MOCK_NARY_CONSTRAINT( less_equal, 1, ( expected ), actual <= expected )
- MOCK_NARY_CONSTRAINT( greater_equal, 1, ( expected ), actual >= expected )
-
-#ifdef BOOST_MSVC
-# pragma push_macro( "small" )
-# undef small
-#endif
- MOCK_NARY_CONSTRAINT( small, 1, ( expected ), \
- ( boost::test_tools::check_is_small( actual, expected ) ) )
-#ifdef BOOST_MSVC
-# pragma pop_macro( "small" )
-#endif
-
- MOCK_NARY_CONSTRAINT( close, 2, ( expected, tolerance ), \
- ( boost::test_tools::check_is_close( \
- actual, expected, \
- boost::test_tools::percent_tolerance( tolerance ) ) ) )
- MOCK_NARY_CONSTRAINT( close_fraction, 2, ( expected, tolerance ), \
- ( boost::test_tools::check_is_close( \
- actual, expected, \
- boost::test_tools::fraction_tolerance( tolerance ) ) ) )
-
-#ifdef BOOST_MSVC
-# pragma push_macro( "near" )
-# undef near
-#endif
- MOCK_NARY_CONSTRAINT( near, 2, ( expected, tolerance ), \
- std::abs( actual - expected ) < tolerance )
-#ifdef BOOST_MSVC
-# pragma pop_macro( "near" )
-#endif
-
-namespace detail
-{
- template< typename Expected >
- struct same
- {
- explicit same( const Expected& expected )
- : expected_( detail::addressof( boost::unwrap_ref( expected ) ) )
- {}
- template< typename Actual >
- bool operator()( const Actual& actual ) const
- {
- return detail::addressof( actual ) == expected_;
- }
- friend std::ostream& operator<<( std::ostream& os, const same& s )
- {
- return os << "same( " << mock::format( *s.expected_ ) << " )";
- }
- const typename
- boost::unwrap_reference< Expected >::type* expected_;
- };
-
- template< typename Expected >
- struct retrieve
- {
- explicit retrieve( Expected& expected )
- : expected_( detail::addressof( boost::unwrap_ref( expected ) ) )
- {}
- template< typename Actual >
- bool operator()( const Actual& actual,
- typename boost::disable_if<
- boost::is_convertible<
- const Actual*,
- typename
- boost::unwrap_reference< Expected >::type
- >
- >::type* = 0 ) const
- {
- *expected_ = actual;
- return true;
- }
- template< typename Actual >
- bool operator()( Actual& actual,
- typename boost::enable_if<
- boost::is_convertible< Actual*,
- typename
- boost::unwrap_reference< Expected >::type
- >
- >::type* = 0 ) const
- {
- *expected_ = detail::addressof( actual );
- return true;
- }
- friend std::ostream& operator<<( std::ostream& s, const retrieve& r )
- {
- return s << "retrieve( " << mock::format( *r.expected_ ) << " )";
- }
- typename
- boost::unwrap_reference< Expected >::type* expected_;
- };
-
- template< typename Expected >
- struct assign
- {
- explicit assign( const Expected& expected )
- : expected_( expected )
- {}
- template< typename Actual >
- bool operator()( Actual& actual ) const
- {
- actual = boost::unwrap_ref( expected_ );
- return true;
- }
- template< typename Actual >
- bool operator()( Actual* actual,
- typename boost::enable_if<
- boost::is_convertible<
- typename
- boost::unwrap_reference< Expected >::type,
- Actual
- >
- >::type* = 0 ) const
- {
- *actual = boost::unwrap_ref( expected_ );
- return true;
- }
- friend std::ostream& operator<<( std::ostream& s, const assign& a )
- {
- return s << "assign( " << mock::format( a.expected_ ) << " )";
- }
- Expected expected_;
- };
-
- template< typename Expected >
- struct contain
- {
- explicit contain( const Expected& expected )
- : expected_( expected )
- {}
- bool operator()( const std::string& actual ) const
- {
- return actual.find( boost::unwrap_ref( expected_ ) )
- != std::string::npos;
- }
- friend std::ostream& operator<<( std::ostream& s, const contain& n )
- {
- return s << "contain( " << mock::format( n.expected_ ) << " )";
- }
- Expected expected_;
- };
-}
-
- template< typename T >
- constraint< detail::same< T > > same( T& t )
- {
- return detail::same< T >( t );
- }
- template< typename T >
- constraint< detail::retrieve< T > > retrieve( T& t )
- {
- return detail::retrieve< T >( t );
- }
- template< typename T >
- constraint< detail::assign< T > > assign( T t )
- {
- return detail::assign< T >( t );
- }
- template< typename T >
- constraint< detail::contain< T > > contain( T t )
- {
- return detail::contain< T >( t );
- }
-
- template< typename T >
- constraint< T > call( T t )
- {
- return constraint< T >( t );
- }
-} // mock
-
-#endif // MOCK_CONSTRAINTS_HPP_INCLUDED
+// http://turtle.sourceforge.net
+//
+// Copyright Mathieu Champlon 2008
+//
+// 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)
+
+#ifndef MOCK_CONSTRAINTS_HPP_INCLUDED
+#define MOCK_CONSTRAINTS_HPP_INCLUDED
+
+#include "config.hpp"
+#include "constraint.hpp"
+#include "detail/addressof.hpp"
+#include
+#include
+#include
+#include
+
+namespace mock
+{
+ MOCK_UNARY_CONSTRAINT( any, 0,, true && &actual )
+ MOCK_UNARY_CONSTRAINT( affirm, 0,, !! actual )
+ MOCK_UNARY_CONSTRAINT( negate, 0,, ! actual )
+ MOCK_UNARY_CONSTRAINT( evaluate, 0,, actual() )
+
+ MOCK_NARY_CONSTRAINT( equal, 1, ( expected ), actual == expected )
+ MOCK_NARY_CONSTRAINT( less, 1, ( expected ), actual < expected )
+ MOCK_NARY_CONSTRAINT( greater, 1, ( expected ), actual > expected )
+ MOCK_NARY_CONSTRAINT( less_equal, 1, ( expected ), actual <= expected )
+ MOCK_NARY_CONSTRAINT( greater_equal, 1, ( expected ), actual >= expected )
+
+#ifdef BOOST_MSVC
+# pragma push_macro( "small" )
+# undef small
+#endif
+ MOCK_NARY_CONSTRAINT( small, 1, ( expected ), \
+ ( boost::test_tools::check_is_small( actual, expected ) ) )
+#ifdef BOOST_MSVC
+# pragma pop_macro( "small" )
+#endif
+
+ MOCK_NARY_CONSTRAINT( close, 2, ( expected, tolerance ), \
+ ( boost::test_tools::check_is_close( \
+ actual, expected, \
+ boost::test_tools::percent_tolerance( tolerance ) ) ) )
+ MOCK_NARY_CONSTRAINT( close_fraction, 2, ( expected, tolerance ), \
+ ( boost::test_tools::check_is_close( \
+ actual, expected, \
+ boost::test_tools::fraction_tolerance( tolerance ) ) ) )
+
+#ifdef BOOST_MSVC
+# pragma push_macro( "near" )
+# undef near
+#endif
+ MOCK_NARY_CONSTRAINT( near, 2, ( expected, tolerance ), \
+ std::abs( actual - expected ) < tolerance )
+#ifdef BOOST_MSVC
+# pragma pop_macro( "near" )
+#endif
+
+namespace detail
+{
+ template< typename Expected >
+ struct same
+ {
+ explicit same( const Expected& expected )
+ : expected_( detail::addressof( boost::unwrap_ref( expected ) ) )
+ {}
+ template< typename Actual >
+ bool operator()( const Actual& actual ) const
+ {
+ return detail::addressof( actual ) == expected_;
+ }
+ friend std::ostream& operator<<( std::ostream& os, const same& s )
+ {
+ return os << "same( " << mock::format( *s.expected_ ) << " )";
+ }
+ const typename
+ boost::unwrap_reference< Expected >::type* expected_;
+ };
+
+ template< typename Expected >
+ struct retrieve
+ {
+ explicit retrieve( Expected& expected )
+ : expected_( detail::addressof( boost::unwrap_ref( expected ) ) )
+ {}
+ template< typename Actual >
+ bool operator()( const Actual& actual,
+ typename boost::disable_if<
+ boost::is_convertible<
+ const Actual*,
+ typename
+ boost::unwrap_reference< Expected >::type
+ >
+ >::type* = 0 ) const
+ {
+ *expected_ = actual;
+ return true;
+ }
+ template< typename Actual >
+ bool operator()( Actual& actual,
+ typename boost::enable_if<
+ boost::is_convertible< Actual*,
+ typename
+ boost::unwrap_reference< Expected >::type
+ >
+ >::type* = 0 ) const
+ {
+ *expected_ = detail::addressof( actual );
+ return true;
+ }
+ friend std::ostream& operator<<( std::ostream& s, const retrieve& r )
+ {
+ return s << "retrieve( " << mock::format( *r.expected_ ) << " )";
+ }
+ typename
+ boost::unwrap_reference< Expected >::type* expected_;
+ };
+
+ template< typename Expected >
+ struct assign
+ {
+ explicit assign( const Expected& expected )
+ : expected_( expected )
+ {}
+ template< typename Actual >
+ bool operator()( Actual& actual ) const
+ {
+ actual = boost::unwrap_ref( expected_ );
+ return true;
+ }
+ template< typename Actual >
+ bool operator()( Actual* actual,
+ typename boost::enable_if<
+ boost::is_convertible<
+ typename
+ boost::unwrap_reference< Expected >::type,
+ Actual
+ >
+ >::type* = 0 ) const
+ {
+ *actual = boost::unwrap_ref( expected_ );
+ return true;
+ }
+ friend std::ostream& operator<<( std::ostream& s, const assign& a )
+ {
+ return s << "assign( " << mock::format( a.expected_ ) << " )";
+ }
+ Expected expected_;
+ };
+
+ template< typename Expected >
+ struct contain
+ {
+ explicit contain( const Expected& expected )
+ : expected_( expected )
+ {}
+ bool operator()( const std::string& actual ) const
+ {
+ return actual.find( boost::unwrap_ref( expected_ ) )
+ != std::string::npos;
+ }
+ friend std::ostream& operator<<( std::ostream& s, const contain& n )
+ {
+ return s << "contain( " << mock::format( n.expected_ ) << " )";
+ }
+ Expected expected_;
+ };
+}
+
+ template< typename T >
+ constraint< detail::same< T > > same( T& t )
+ {
+ return detail::same< T >( t );
+ }
+ template< typename T >
+ constraint< detail::retrieve< T > > retrieve( T& t )
+ {
+ return detail::retrieve< T >( t );
+ }
+ template< typename T >
+ constraint< detail::assign< T > > assign( T t )
+ {
+ return detail::assign< T >( t );
+ }
+ template< typename T >
+ constraint< detail::contain< T > > contain( T t )
+ {
+ return detail::contain< T >( t );
+ }
+
+ template< typename T >
+ constraint< T > call( T t )
+ {
+ return constraint< T >( t );
+ }
+} // mock
+
+#endif // MOCK_CONSTRAINTS_HPP_INCLUDED
diff --git a/turtle/detail/action.hpp b/include/turtle/detail/action.hpp
similarity index 96%
rename from turtle/detail/action.hpp
rename to include/turtle/detail/action.hpp
index 02c5e4c..db98aad 100644
--- a/turtle/detail/action.hpp
+++ b/include/turtle/detail/action.hpp
@@ -1,214 +1,214 @@
-// http://turtle.sourceforge.net
-//
-// Copyright Mathieu Champlon 2008
-//
-// 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)
-
-#ifndef MOCK_ACTION_HPP_INCLUDED
-#define MOCK_ACTION_HPP_INCLUDED
-
-#include "../config.hpp"
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-namespace mock
-{
-namespace detail
-{
- template< typename Result, typename Signature >
- class action_base
- {
- private:
- typedef boost::function< Signature > functor_type;
- typedef boost::function< Result() > action_type;
-
- public:
- const functor_type& functor() const
- {
- return f_;
- }
- bool valid() const
- {
- return f_ || a_;
- }
- Result trigger() const
- {
- return a_();
- }
-
- void calls( const functor_type& f )
- {
- if( ! f )
- throw std::invalid_argument( "null functor" );
- f_ = f;
- }
-
- template< typename Exception >
- void throws( Exception e )
- {
- a_ = boost::bind( &do_throw< Exception >, e );
- }
-
- protected:
- void set( const action_type& a )
- {
- a_ = a;
- }
- template< typename Y >
- void set( const boost::reference_wrapper< Y >& r )
- {
- a_ = boost::bind( &do_ref< Y >, r.get_pointer() );
- }
-
- private:
- template< typename T >
- static T& do_ref( T* t )
- {
- return *t;
- }
- template< typename T >
- static Result do_throw( T t )
- {
- throw t;
- }
-
- functor_type f_;
- action_type a_;
- };
-
- template< typename Result, typename Signature >
- class action : public action_base< Result, Signature >
- {
- public:
- template< typename Value >
- void returns( const Value& v )
- {
- this->set( boost::ref( store( v ) ) );
- }
- template< typename Y >
- void returns( const boost::reference_wrapper< Y >& r )
- {
- this->set( r );
- }
-
- template< typename Value >
- void moves( BOOST_RV_REF( Value ) v )
- {
- this->set(
- boost::bind(
- &boost::move< BOOST_RV_REF( Value ) >,
- boost::ref( store( boost::move( v ) ) ) ) );
- }
-
- private:
- struct value : boost::noncopyable
- {
- virtual ~value()
- {}
- };
- template< typename T >
- struct value_imp : value
- {
- typedef
- typename boost::remove_const<
- typename boost::remove_reference<
- T
- >::type
- >::type value_type;
-
- value_imp( BOOST_RV_REF( value_type ) t )
- : t_( boost::move( t ) )
- {}
- value_imp( const T& t )
- : t_( t )
- {}
- template< typename Y >
- value_imp( Y* y )
- : t_( y )
- {}
- value_type t_;
- };
-
- template< typename T >
- T& store( BOOST_RV_REF( T ) t )
- {
- v_.reset( new value_imp< T >( boost::move( t ) ) );
- return static_cast< value_imp< T >& >( *v_ ).t_;
- }
- template< typename T >
- T& store( const T& t )
- {
- v_.reset( new value_imp< T >( t ) );
- return static_cast< value_imp< T >& >( *v_ ).t_;
- }
- template< typename T >
- Result& store( T* t )
- {
- v_.reset( new value_imp< Result >( t ) );
- return static_cast< value_imp< Result >& >( *v_ ).t_;
- }
-
- boost::shared_ptr< value > v_;
- };
-
- template< typename Signature >
- class action< void, Signature > : public action_base< void, Signature >
- {
- public:
- action()
- {
- this->set( boost::bind( &do_nothing ) );
- }
-
- private:
- static void do_nothing()
- {}
- };
-
- template< typename Result, typename Signature >
- class action< std::auto_ptr< Result >, Signature >
- : public action_base< std::auto_ptr< Result >, Signature >
- {
- public:
- action()
- {}
- action( const action& rhs )
- : v_( rhs.v_.release() )
- {
- if( v_.get() )
- returns( boost::ref( v_ ) );
- }
-
- template< typename Y >
- void returns( Y* r )
- {
- v_.reset( r );
- this->set( boost::ref( v_ ) );
- }
- template< typename Y >
- void returns( std::auto_ptr< Y > r )
- {
- v_ = r;
- this->set( boost::ref( v_ ) );
- }
- template< typename Y >
- void returns( const boost::reference_wrapper< Y >& r )
- {
- this->set( r );
- }
-
- private:
- mutable std::auto_ptr< Result > v_;
- };
-}
-} // mock
-
-#endif // MOCK_ACTION_HPP_INCLUDED
+// http://turtle.sourceforge.net
+//
+// Copyright Mathieu Champlon 2008
+//
+// 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)
+
+#ifndef MOCK_ACTION_HPP_INCLUDED
+#define MOCK_ACTION_HPP_INCLUDED
+
+#include "../config.hpp"
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+namespace mock
+{
+namespace detail
+{
+ template< typename Result, typename Signature >
+ class action_base
+ {
+ private:
+ typedef boost::function< Signature > functor_type;
+ typedef boost::function< Result() > action_type;
+
+ public:
+ const functor_type& functor() const
+ {
+ return f_;
+ }
+ bool valid() const
+ {
+ return f_ || a_;
+ }
+ Result trigger() const
+ {
+ return a_();
+ }
+
+ void calls( const functor_type& f )
+ {
+ if( ! f )
+ throw std::invalid_argument( "null functor" );
+ f_ = f;
+ }
+
+ template< typename Exception >
+ void throws( Exception e )
+ {
+ a_ = boost::bind( &do_throw< Exception >, e );
+ }
+
+ protected:
+ void set( const action_type& a )
+ {
+ a_ = a;
+ }
+ template< typename Y >
+ void set( const boost::reference_wrapper< Y >& r )
+ {
+ a_ = boost::bind( &do_ref< Y >, r.get_pointer() );
+ }
+
+ private:
+ template< typename T >
+ static T& do_ref( T* t )
+ {
+ return *t;
+ }
+ template< typename T >
+ static Result do_throw( T t )
+ {
+ throw t;
+ }
+
+ functor_type f_;
+ action_type a_;
+ };
+
+ template< typename Result, typename Signature >
+ class action : public action_base< Result, Signature >
+ {
+ public:
+ template< typename Value >
+ void returns( const Value& v )
+ {
+ this->set( boost::ref( store( v ) ) );
+ }
+ template< typename Y >
+ void returns( const boost::reference_wrapper< Y >& r )
+ {
+ this->set( r );
+ }
+
+ template< typename Value >
+ void moves( BOOST_RV_REF( Value ) v )
+ {
+ this->set(
+ boost::bind(
+ &boost::move< BOOST_RV_REF( Value ) >,
+ boost::ref( store( boost::move( v ) ) ) ) );
+ }
+
+ private:
+ struct value : boost::noncopyable
+ {
+ virtual ~value()
+ {}
+ };
+ template< typename T >
+ struct value_imp : value
+ {
+ typedef
+ typename boost::remove_const<
+ typename boost::remove_reference<
+ T
+ >::type
+ >::type value_type;
+
+ value_imp( BOOST_RV_REF( value_type ) t )
+ : t_( boost::move( t ) )
+ {}
+ value_imp( const T& t )
+ : t_( t )
+ {}
+ template< typename Y >
+ value_imp( Y* y )
+ : t_( y )
+ {}
+ value_type t_;
+ };
+
+ template< typename T >
+ T& store( BOOST_RV_REF( T ) t )
+ {
+ v_.reset( new value_imp< T >( boost::move( t ) ) );
+ return static_cast< value_imp< T >& >( *v_ ).t_;
+ }
+ template< typename T >
+ T& store( const T& t )
+ {
+ v_.reset( new value_imp< T >( t ) );
+ return static_cast< value_imp< T >& >( *v_ ).t_;
+ }
+ template< typename T >
+ Result& store( T* t )
+ {
+ v_.reset( new value_imp< Result >( t ) );
+ return static_cast< value_imp< Result >& >( *v_ ).t_;
+ }
+
+ boost::shared_ptr< value > v_;
+ };
+
+ template< typename Signature >
+ class action< void, Signature > : public action_base< void, Signature >
+ {
+ public:
+ action()
+ {
+ this->set( boost::bind( &do_nothing ) );
+ }
+
+ private:
+ static void do_nothing()
+ {}
+ };
+
+ template< typename Result, typename Signature >
+ class action< std::auto_ptr< Result >, Signature >
+ : public action_base< std::auto_ptr< Result >, Signature >
+ {
+ public:
+ action()
+ {}
+ action( const action& rhs )
+ : v_( rhs.v_.release() )
+ {
+ if( v_.get() )
+ returns( boost::ref( v_ ) );
+ }
+
+ template< typename Y >
+ void returns( Y* r )
+ {
+ v_.reset( r );
+ this->set( boost::ref( v_ ) );
+ }
+ template< typename Y >
+ void returns( std::auto_ptr< Y > r )
+ {
+ v_ = r;
+ this->set( boost::ref( v_ ) );
+ }
+ template< typename Y >
+ void returns( const boost::reference_wrapper< Y >& r )
+ {
+ this->set( r );
+ }
+
+ private:
+ mutable std::auto_ptr< Result > v_;
+ };
+}
+} // mock
+
+#endif // MOCK_ACTION_HPP_INCLUDED
diff --git a/turtle/detail/addressof.hpp b/include/turtle/detail/addressof.hpp
similarity index 95%
rename from turtle/detail/addressof.hpp
rename to include/turtle/detail/addressof.hpp
index a818945..4e48a8d 100644
--- a/turtle/detail/addressof.hpp
+++ b/include/turtle/detail/addressof.hpp
@@ -1,36 +1,36 @@
-// http://turtle.sourceforge.net
-//
-// Copyright Mathieu Champlon 2013
-//
-// 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)
-
-#ifndef MOCK_ADDRESSOF_HPP_INCLUDED
-#define MOCK_ADDRESSOF_HPP_INCLUDED
-
-#include "../config.hpp"
-#include
-
-namespace mock
-{
-namespace detail
-{
- using boost::addressof;
-
-#ifdef MOCK_NULLPTR
-
- inline const std::nullptr_t* addressof( const std::nullptr_t& p )
- {
- return &p;
- }
- inline std::nullptr_t* addressof( std::nullptr_t& p )
- {
- return &p;
- }
-
-#endif
-}
-} // mock
-
-#endif // MOCK_ADDRESSOF_HPP_INCLUDED
+// http://turtle.sourceforge.net
+//
+// Copyright Mathieu Champlon 2013
+//
+// 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)
+
+#ifndef MOCK_ADDRESSOF_HPP_INCLUDED
+#define MOCK_ADDRESSOF_HPP_INCLUDED
+
+#include "../config.hpp"
+#include
+
+namespace mock
+{
+namespace detail
+{
+ using boost::addressof;
+
+#ifdef MOCK_NULLPTR
+
+ inline const std::nullptr_t* addressof( const std::nullptr_t& p )
+ {
+ return &p;
+ }
+ inline std::nullptr_t* addressof( std::nullptr_t& p )
+ {
+ return &p;
+ }
+
+#endif
+}
+} // mock
+
+#endif // MOCK_ADDRESSOF_HPP_INCLUDED
diff --git a/turtle/detail/child.hpp b/include/turtle/detail/child.hpp
similarity index 96%
rename from turtle/detail/child.hpp
rename to include/turtle/detail/child.hpp
index 3de8492..992d397 100644
--- a/turtle/detail/child.hpp
+++ b/include/turtle/detail/child.hpp
@@ -1,52 +1,52 @@
-// http://turtle.sourceforge.net
-//
-// Copyright Mathieu Champlon 2011
-//
-// 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)
-
-#ifndef MOCK_CHILD_HPP_INCLUDED
-#define MOCK_CHILD_HPP_INCLUDED
-
-#include "../config.hpp"
-#include "type_name.hpp"
-#include "parent.hpp"
-#include
-#include
-#include
-
-namespace mock
-{
-namespace detail
-{
- class child
- {
- public:
- child()
- : parent_( 0 )
- {}
- void update( parent& p,
- boost::unit_test::const_string instance,
- boost::optional< type_name > type,
- boost::unit_test::const_string name )
- {
- if( instance != "?." || name_.empty() )
- p = parent( instance, type );
- parent_ = &p;
- name_ = name;
- }
- friend std::ostream& operator<<( std::ostream& s, const child& c )
- {
- if( c.parent_ )
- s << *c.parent_;
- return s << c.name_;
- }
- private:
- const parent* parent_;
- boost::unit_test::const_string name_;
- };
-}
-} // mock
-
-#endif // MOCK_CHILD_HPP_INCLUDED
+// http://turtle.sourceforge.net
+//
+// Copyright Mathieu Champlon 2011
+//
+// 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)
+
+#ifndef MOCK_CHILD_HPP_INCLUDED
+#define MOCK_CHILD_HPP_INCLUDED
+
+#include "../config.hpp"
+#include "type_name.hpp"
+#include "parent.hpp"
+#include
+#include
+#include
+
+namespace mock
+{
+namespace detail
+{
+ class child
+ {
+ public:
+ child()
+ : parent_( 0 )
+ {}
+ void update( parent& p,
+ boost::unit_test::const_string instance,
+ boost::optional< type_name > type,
+ boost::unit_test::const_string name )
+ {
+ if( instance != "?." || name_.empty() )
+ p = parent( instance, type );
+ parent_ = &p;
+ name_ = name;
+ }
+ friend std::ostream& operator<<( std::ostream& s, const child& c )
+ {
+ if( c.parent_ )
+ s << *c.parent_;
+ return s << c.name_;
+ }
+ private:
+ const parent* parent_;
+ boost::unit_test::const_string name_;
+ };
+}
+} // mock
+
+#endif // MOCK_CHILD_HPP_INCLUDED
diff --git a/turtle/detail/cleanup.hpp b/include/turtle/detail/cleanup.hpp
similarity index 95%
rename from turtle/detail/cleanup.hpp
rename to include/turtle/detail/cleanup.hpp
index 88e20e0..ca5d212 100644
--- a/turtle/detail/cleanup.hpp
+++ b/include/turtle/detail/cleanup.hpp
@@ -1,37 +1,37 @@
-// http://turtle.sourceforge.net
-//
-// Copyright Mathieu Champlon 2011
-//
-// 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)
-
-#ifndef MOCK_CLEANUP_HPP_INCLUDED
-#define MOCK_CLEANUP_HPP_INCLUDED
-
-#include "../config.hpp"
-#ifdef MOCK_USE_BOOST_TEST
-#include "../verify.hpp"
-#include "../reset.hpp"
-#include
-
-namespace mock
-{
-namespace detail
-{
- struct cleanup
- {
- ~cleanup()
- {
- // see https://svn.boost.org/trac/boost/ticket/5563
- //mock::verify();
- mock::reset();
- }
- };
- BOOST_GLOBAL_FIXTURE( cleanup )
-}
-} // mock
-
-#endif // MOCK_USE_BOOST_TEST
-
-#endif // MOCK_CLEANUP_HPP_INCLUDED
+// http://turtle.sourceforge.net
+//
+// Copyright Mathieu Champlon 2011
+//
+// 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)
+
+#ifndef MOCK_CLEANUP_HPP_INCLUDED
+#define MOCK_CLEANUP_HPP_INCLUDED
+
+#include "../config.hpp"
+#ifdef MOCK_USE_BOOST_TEST
+#include "../verify.hpp"
+#include "../reset.hpp"
+#include
+
+namespace mock
+{
+namespace detail
+{
+ struct cleanup
+ {
+ ~cleanup()
+ {
+ // see https://svn.boost.org/trac/boost/ticket/5563
+ //mock::verify();
+ mock::reset();
+ }
+ };
+ BOOST_GLOBAL_FIXTURE( cleanup )
+}
+} // mock
+
+#endif // MOCK_USE_BOOST_TEST
+
+#endif // MOCK_CLEANUP_HPP_INCLUDED
diff --git a/turtle/detail/context.hpp b/include/turtle/detail/context.hpp
similarity index 96%
rename from turtle/detail/context.hpp
rename to include/turtle/detail/context.hpp
index 39ca5bb..9b275a3 100644
--- a/turtle/detail/context.hpp
+++ b/include/turtle/detail/context.hpp
@@ -1,44 +1,44 @@
-// http://turtle.sourceforge.net
-//
-// Copyright Mathieu Champlon 2011
-//
-// 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)
-
-#ifndef MOCK_CONTEXT_HPP_INCLUDED
-#define MOCK_CONTEXT_HPP_INCLUDED
-
-#include "../config.hpp"
-#include "type_name.hpp"
-#include
-#include
-#include
-#include
-
-namespace mock
-{
-namespace detail
-{
- class verifiable;
-
- class context : boost::noncopyable
- {
- public:
- context() {}
- virtual ~context() {}
-
- virtual void add( const void* p, verifiable& v,
- boost::unit_test::const_string instance,
- boost::optional< type_name > type,
- boost::unit_test::const_string name ) = 0;
- virtual void add( verifiable& v ) = 0;
- virtual void remove( verifiable& v ) = 0;
-
- virtual void serialize( std::ostream& s,
- const verifiable& v ) const = 0;
- };
-}
-} // mock
-
-#endif // MOCK_CONTEXT_HPP_INCLUDED
+// http://turtle.sourceforge.net
+//
+// Copyright Mathieu Champlon 2011
+//
+// 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)
+
+#ifndef MOCK_CONTEXT_HPP_INCLUDED
+#define MOCK_CONTEXT_HPP_INCLUDED
+
+#include "../config.hpp"
+#include "type_name.hpp"
+#include
+#include
+#include
+#include
+
+namespace mock
+{
+namespace detail
+{
+ class verifiable;
+
+ class context : boost::noncopyable
+ {
+ public:
+ context() {}
+ virtual ~context() {}
+
+ virtual void add( const void* p, verifiable& v,
+ boost::unit_test::const_string instance,
+ boost::optional< type_name > type,
+ boost::unit_test::const_string name ) = 0;
+ virtual void add( verifiable& v ) = 0;
+ virtual void remove( verifiable& v ) = 0;
+
+ virtual void serialize( std::ostream& s,
+ const verifiable& v ) const = 0;
+ };
+}
+} // mock
+
+#endif // MOCK_CONTEXT_HPP_INCLUDED
diff --git a/turtle/detail/expectation_template.hpp b/include/turtle/detail/expectation_template.hpp
similarity index 93%
rename from turtle/detail/expectation_template.hpp
rename to include/turtle/detail/expectation_template.hpp
index 8431cd1..a4f14a0 100644
--- a/turtle/detail/expectation_template.hpp
+++ b/include/turtle/detail/expectation_template.hpp
@@ -1,263 +1,263 @@
-// http://turtle.sourceforge.net
-//
-// Copyright Mathieu Champlon 2012
-//
-// 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 "matcher_base_template.hpp"
-
-#define MOCK_EXPECTATION_INITIALIZE(z, n, d) \
- BOOST_PP_COMMA_IF(n) c##n##_( c##n )
-
-#define MOCK_EXPECTATION_MEMBER(z, n, d) \
- matcher< T##n, Constraint_##n > c##n##_;
-
-#define MOCK_EXPECTATION_IS_VALID(z, n, d) \
- BOOST_PP_IF(n, &&,) c##n##_( a##n )
-
-#define MOCK_EXPECTATION_SERIALIZE(z, n, d) \
- BOOST_PP_IF(n, << ", " <<,) c##n##_
-
-#define MOCK_EXPECTATION_SERIALIZE_ANY(z, n, d) \
- BOOST_PP_IF(n, << ", " <<,) "any"
-
-namespace mock
-{
-namespace detail
-{
- template< typename Signature > class default_matcher;
-
- template<
- BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, typename T) >
- class default_matcher< void( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) ) >
- : public matcher_base< void( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) ) >
- {
- private:
- virtual bool operator()(
- BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) )
- {
- return true;
- }
- virtual void serialize( std::ostream& s ) const
- {
- s << "" BOOST_PP_REPEAT(MOCK_NUM_ARGS,
- MOCK_EXPECTATION_SERIALIZE_ANY, _ );
- }
- };
-
-#ifndef MOCK_NUM_ARGS_0
-
- template< typename Constraint, typename Signature > class single_matcher;
-
- template<
- BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, typename Constraint_),
- BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, typename T)
- >
- class single_matcher<
- void( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, Constraint_) ),
- void( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) )
- >
- : public matcher_base< void( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) ) >
- {
- public:
- single_matcher(
- BOOST_PP_ENUM_BINARY_PARAMS(MOCK_NUM_ARGS, Constraint_, c) )
- : BOOST_PP_REPEAT(MOCK_NUM_ARGS,
- MOCK_EXPECTATION_INITIALIZE, _)
- {}
-
- private:
- virtual bool operator()(
- BOOST_PP_ENUM_BINARY_PARAMS(MOCK_NUM_ARGS, T, a) )
- {
- return BOOST_PP_REPEAT(MOCK_NUM_ARGS,
- MOCK_EXPECTATION_IS_VALID, _);
- }
- virtual void serialize( std::ostream& s ) const
- {
- s << BOOST_PP_REPEAT(MOCK_NUM_ARGS,
- MOCK_EXPECTATION_SERIALIZE, _ );
- }
-
- private:
- BOOST_PP_REPEAT(
- MOCK_NUM_ARGS, MOCK_EXPECTATION_MEMBER, _ )
-};
-
- template< typename F, typename Signature > class multi_matcher;
-
- template< typename F,
- BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, typename T) >
- class multi_matcher< F, void( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) ) >
- : public matcher_base< void( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS,T) ) >
- {
- public:
- multi_matcher( const F& f )
- : f_( f )
- {}
-
- private:
- virtual bool operator()(
- BOOST_PP_ENUM_BINARY_PARAMS( MOCK_NUM_ARGS, T, a ) )
- {
- return f_( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, a ) );
- }
- virtual void serialize( std::ostream& s ) const
- {
- s << mock::format( f_ );
- }
-
- private:
- F f_;
- };
-
-#endif
-
- template< typename Signature > class expectation;
-
- template< typename R
- BOOST_PP_ENUM_TRAILING_PARAMS(MOCK_NUM_ARGS, typename T) >
- class expectation< R (BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS,T)) >
- : public action< R, R (BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS,T)) >
- {
- public:
- expectation()
- : invocation_( boost::make_shared< unlimited >() )
- , matcher_(
- boost::make_shared<
- default_matcher<
- void( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) )
- >
- > () )
- , file_( "unknown location" )
- , line_( 0 )
- {}
- expectation( const char* file, int line )
- : invocation_( boost::make_shared< unlimited >() )
- , matcher_(
- boost::make_shared<
- default_matcher<
- void( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) )
- >
- > () )
- , file_( file )
- , line_( line )
- {}
-
- ~expectation()
- {
- for( sequences_cit it = sequences_.begin();
- it != sequences_.end(); ++it )
- (*it)->remove( this );
- }
-
- void invoke( const boost::shared_ptr< invocation >& i )
- {
- invocation_ = i;
- }
-
-#ifndef MOCK_NUM_ARGS_0
- template<
- BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, typename Constraint_)
- >
- expectation& with(
- BOOST_PP_ENUM_BINARY_PARAMS(MOCK_NUM_ARGS, Constraint_, c) )
- {
- matcher_ =
- boost::make_shared< single_matcher<
- void( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, Constraint_) ),
- void( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) )
- > >(
- BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, c) );
- return *this;
- }
-#if MOCK_NUM_ARGS > 1
- template< typename Constraint >
- expectation& with( const Constraint& c )
- {
- matcher_ =
- boost::make_shared< multi_matcher<
- Constraint,
- void( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) ) > >( c );
- return *this;
- }
-#endif
-#endif
-
- void add( sequence& s )
- {
- s.impl_->add( this );
- sequences_.push_back( s.impl_ );
- }
-
- bool verify() const
- {
- return invocation_->verify();
- }
-
- bool is_valid(
- BOOST_PP_ENUM_BINARY_PARAMS(MOCK_NUM_ARGS, T, a) ) const
- {
- return !invocation_->exhausted()
- && (*matcher_)( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, a) );
- }
-
- bool invoke() const
- {
- for( sequences_cit it = sequences_.begin();
- it != sequences_.end(); ++it )
- if( ! (*it)->is_valid( this ) )
- return false;
- bool result = invocation_->invoke();
- for( sequences_cit it = sequences_.begin();
- it != sequences_.end(); ++it )
- (*it)->invalidate( this );
- return result;
- }
-
- const char* file() const
- {
- return file_;
- }
- int line() const
- {
- return line_;
- }
-
- friend std::ostream& operator<<(
- std::ostream& s, const expectation& e )
- {
- return s << ( e.invocation_->exhausted() ? 'v' : '.' )
- << ' ' << *e.invocation_
-#ifndef MOCK_NUM_ARGS_0
- << ".with( " << *e.matcher_ << " )"
-#endif
- ;
- }
-
- private:
- typedef std::vector<
- boost::shared_ptr< sequence_impl >
- > sequences_type;
- typedef sequences_type::const_iterator sequences_cit;
-
- boost::shared_ptr< invocation > invocation_;
- boost::shared_ptr<
- matcher_base<
- void( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) )
- >
- > matcher_;
- sequences_type sequences_;
- const char* file_;
- int line_;
- };
-}
-} // mock
-
-#undef MOCK_EXPECTATION_INITIALIZE
-#undef MOCK_EXPECTATION_MEMBER
-#undef MOCK_EXPECTATION_IS_VALID
-#undef MOCK_EXPECTATION_SERIALIZE
-#undef MOCK_EXPECTATION_SERIALIZE_ANY
+// http://turtle.sourceforge.net
+//
+// Copyright Mathieu Champlon 2012
+//
+// 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 "matcher_base_template.hpp"
+
+#define MOCK_EXPECTATION_INITIALIZE(z, n, d) \
+ BOOST_PP_COMMA_IF(n) c##n##_( c##n )
+
+#define MOCK_EXPECTATION_MEMBER(z, n, d) \
+ matcher< T##n, Constraint_##n > c##n##_;
+
+#define MOCK_EXPECTATION_IS_VALID(z, n, d) \
+ BOOST_PP_IF(n, &&,) c##n##_( a##n )
+
+#define MOCK_EXPECTATION_SERIALIZE(z, n, d) \
+ BOOST_PP_IF(n, << ", " <<,) c##n##_
+
+#define MOCK_EXPECTATION_SERIALIZE_ANY(z, n, d) \
+ BOOST_PP_IF(n, << ", " <<,) "any"
+
+namespace mock
+{
+namespace detail
+{
+ template< typename Signature > class default_matcher;
+
+ template<
+ BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, typename T) >
+ class default_matcher< void( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) ) >
+ : public matcher_base< void( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) ) >
+ {
+ private:
+ virtual bool operator()(
+ BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) )
+ {
+ return true;
+ }
+ virtual void serialize( std::ostream& s ) const
+ {
+ s << "" BOOST_PP_REPEAT(MOCK_NUM_ARGS,
+ MOCK_EXPECTATION_SERIALIZE_ANY, _ );
+ }
+ };
+
+#ifndef MOCK_NUM_ARGS_0
+
+ template< typename Constraint, typename Signature > class single_matcher;
+
+ template<
+ BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, typename Constraint_),
+ BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, typename T)
+ >
+ class single_matcher<
+ void( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, Constraint_) ),
+ void( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) )
+ >
+ : public matcher_base< void( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) ) >
+ {
+ public:
+ single_matcher(
+ BOOST_PP_ENUM_BINARY_PARAMS(MOCK_NUM_ARGS, Constraint_, c) )
+ : BOOST_PP_REPEAT(MOCK_NUM_ARGS,
+ MOCK_EXPECTATION_INITIALIZE, _)
+ {}
+
+ private:
+ virtual bool operator()(
+ BOOST_PP_ENUM_BINARY_PARAMS(MOCK_NUM_ARGS, T, a) )
+ {
+ return BOOST_PP_REPEAT(MOCK_NUM_ARGS,
+ MOCK_EXPECTATION_IS_VALID, _);
+ }
+ virtual void serialize( std::ostream& s ) const
+ {
+ s << BOOST_PP_REPEAT(MOCK_NUM_ARGS,
+ MOCK_EXPECTATION_SERIALIZE, _ );
+ }
+
+ private:
+ BOOST_PP_REPEAT(
+ MOCK_NUM_ARGS, MOCK_EXPECTATION_MEMBER, _ )
+};
+
+ template< typename F, typename Signature > class multi_matcher;
+
+ template< typename F,
+ BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, typename T) >
+ class multi_matcher< F, void( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) ) >
+ : public matcher_base< void( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS,T) ) >
+ {
+ public:
+ multi_matcher( const F& f )
+ : f_( f )
+ {}
+
+ private:
+ virtual bool operator()(
+ BOOST_PP_ENUM_BINARY_PARAMS( MOCK_NUM_ARGS, T, a ) )
+ {
+ return f_( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, a ) );
+ }
+ virtual void serialize( std::ostream& s ) const
+ {
+ s << mock::format( f_ );
+ }
+
+ private:
+ F f_;
+ };
+
+#endif
+
+ template< typename Signature > class expectation;
+
+ template< typename R
+ BOOST_PP_ENUM_TRAILING_PARAMS(MOCK_NUM_ARGS, typename T) >
+ class expectation< R (BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS,T)) >
+ : public action< R, R (BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS,T)) >
+ {
+ public:
+ expectation()
+ : invocation_( boost::make_shared< unlimited >() )
+ , matcher_(
+ boost::make_shared<
+ default_matcher<
+ void( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) )
+ >
+ > () )
+ , file_( "unknown location" )
+ , line_( 0 )
+ {}
+ expectation( const char* file, int line )
+ : invocation_( boost::make_shared< unlimited >() )
+ , matcher_(
+ boost::make_shared<
+ default_matcher<
+ void( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) )
+ >
+ > () )
+ , file_( file )
+ , line_( line )
+ {}
+
+ ~expectation()
+ {
+ for( sequences_cit it = sequences_.begin();
+ it != sequences_.end(); ++it )
+ (*it)->remove( this );
+ }
+
+ void invoke( const boost::shared_ptr< invocation >& i )
+ {
+ invocation_ = i;
+ }
+
+#ifndef MOCK_NUM_ARGS_0
+ template<
+ BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, typename Constraint_)
+ >
+ expectation& with(
+ BOOST_PP_ENUM_BINARY_PARAMS(MOCK_NUM_ARGS, Constraint_, c) )
+ {
+ matcher_.reset(
+ new single_matcher<
+ void( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, Constraint_) ),
+ void( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) )
+ >( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, c) ) );
+ return *this;
+ }
+#if MOCK_NUM_ARGS > 1
+ template< typename Constraint >
+ expectation& with( const Constraint& c )
+ {
+ matcher_.reset(
+ new multi_matcher<
+ Constraint,
+ void( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) )
+ >( c ) );
+ return *this;
+ }
+#endif
+#endif
+
+ void add( sequence& s )
+ {
+ s.impl_->add( this );
+ sequences_.push_back( s.impl_ );
+ }
+
+ bool verify() const
+ {
+ return invocation_->verify();
+ }
+
+ bool is_valid(
+ BOOST_PP_ENUM_BINARY_PARAMS(MOCK_NUM_ARGS, T, a) ) const
+ {
+ return !invocation_->exhausted()
+ && (*matcher_)( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, a) );
+ }
+
+ bool invoke() const
+ {
+ for( sequences_cit it = sequences_.begin();
+ it != sequences_.end(); ++it )
+ if( ! (*it)->is_valid( this ) )
+ return false;
+ bool result = invocation_->invoke();
+ for( sequences_cit it = sequences_.begin();
+ it != sequences_.end(); ++it )
+ (*it)->invalidate( this );
+ return result;
+ }
+
+ const char* file() const
+ {
+ return file_;
+ }
+ int line() const
+ {
+ return line_;
+ }
+
+ friend std::ostream& operator<<(
+ std::ostream& s, const expectation& e )
+ {
+ return s << ( e.invocation_->exhausted() ? 'v' : '.' )
+ << ' ' << *e.invocation_
+#ifndef MOCK_NUM_ARGS_0
+ << ".with( " << *e.matcher_ << " )"
+#endif
+ ;
+ }
+
+ private:
+ typedef std::vector<
+ boost::shared_ptr< sequence_impl >
+ > sequences_type;
+ typedef sequences_type::const_iterator sequences_cit;
+
+ boost::shared_ptr< invocation > invocation_;
+ boost::shared_ptr<
+ matcher_base<
+ void( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) )
+ >
+ > matcher_;
+ sequences_type sequences_;
+ const char* file_;
+ int line_;
+ };
+}
+} // mock
+
+#undef MOCK_EXPECTATION_INITIALIZE
+#undef MOCK_EXPECTATION_MEMBER
+#undef MOCK_EXPECTATION_IS_VALID
+#undef MOCK_EXPECTATION_SERIALIZE
+#undef MOCK_EXPECTATION_SERIALIZE_ANY
diff --git a/turtle/detail/formatter.hpp b/include/turtle/detail/formatter.hpp
similarity index 95%
rename from turtle/detail/formatter.hpp
rename to include/turtle/detail/formatter.hpp
index 78dddae..18ccd73 100644
--- a/turtle/detail/formatter.hpp
+++ b/include/turtle/detail/formatter.hpp
@@ -1,50 +1,50 @@
-// http://turtle.sourceforge.net
-//
-// Copyright Mathieu Champlon 2012
-//
-// 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)
-
-#ifndef MOCK_FORMATTER_HPP_INCLUDED
-#define MOCK_FORMATTER_HPP_INCLUDED
-
-#include "../config.hpp"
-#include "../stream.hpp"
-#include "addressof.hpp"
-
-namespace mock
-{
-namespace detail
-{
- template< typename T >
- struct formatter
- {
- explicit formatter( const T& t )
- : t_( detail::addressof( t ) )
- {}
- void serialize( stream& s ) const
- {
- detail::serialize( s, *t_ );
- }
- const T* t_;
- };
-
- template< typename T >
- stream& operator<<( stream& s, const formatter< T >& f )
- {
- f.serialize( s );
- return s;
- }
-
- template< typename T >
- std::ostream& operator<<( std::ostream& s, const formatter< T >& f )
- {
- stream ss( s );
- f.serialize( ss );
- return s;
- }
-}
-} // mock
-
-#endif // MOCK_FORMATTER_HPP_INCLUDED
+// http://turtle.sourceforge.net
+//
+// Copyright Mathieu Champlon 2012
+//
+// 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)
+
+#ifndef MOCK_FORMATTER_HPP_INCLUDED
+#define MOCK_FORMATTER_HPP_INCLUDED
+
+#include "../config.hpp"
+#include "../stream.hpp"
+#include "addressof.hpp"
+
+namespace mock
+{
+namespace detail
+{
+ template< typename T >
+ struct formatter
+ {
+ explicit formatter( const T& t )
+ : t_( detail::addressof( t ) )
+ {}
+ void serialize( stream& s ) const
+ {
+ detail::serialize( s, *t_ );
+ }
+ const T* t_;
+ };
+
+ template< typename T >
+ stream& operator<<( stream& s, const formatter< T >& f )
+ {
+ f.serialize( s );
+ return s;
+ }
+
+ template< typename T >
+ std::ostream& operator<<( std::ostream& s, const formatter< T >& f )
+ {
+ stream ss( s );
+ f.serialize( ss );
+ return s;
+ }
+}
+} // mock
+
+#endif // MOCK_FORMATTER_HPP_INCLUDED
diff --git a/turtle/detail/function.hpp b/include/turtle/detail/function.hpp
similarity index 96%
rename from turtle/detail/function.hpp
rename to include/turtle/detail/function.hpp
index 300786c..4a48220 100644
--- a/turtle/detail/function.hpp
+++ b/include/turtle/detail/function.hpp
@@ -1,103 +1,103 @@
-// http://turtle.sourceforge.net
-//
-// Copyright Mathieu Champlon 2008
-//
-// 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)
-
-#ifndef MOCK_FUNCTION_HPP_INCLUDED
-#define MOCK_FUNCTION_HPP_INCLUDED
-
-#include "../config.hpp"
-#include "../error.hpp"
-#include "../log.hpp"
-#include "../constraints.hpp"
-#include "../sequence.hpp"
-#include "../matcher.hpp"
-#include "action.hpp"
-#include "verifiable.hpp"
-#include "invocation.hpp"
-#include "type_name.hpp"
-#include "context.hpp"
-#include "mutex.hpp"
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-namespace mock
-{
-namespace detail
-{
- template< typename R, typename E >
- struct wrapper_base
- {
- wrapper_base( E& e )
- : e_( &e )
- {}
-
- template< typename T >
- void returns( T t )
- {
- e_->returns( t );
- }
-
- E* e_;
- };
- template< typename E >
- struct wrapper_base< void, E >
- {
- wrapper_base( E& e )
- : e_( &e )
- {}
-
- E* e_;
- };
- template< typename R, typename E >
- struct wrapper_base< R*, E >
- {
- wrapper_base( E& e )
- : e_( &e )
- {}
-
- void returns( R* r )
- {
- e_->returns( r );
- }
- template< typename Y >
- void returns( const boost::reference_wrapper< Y >& r )
- {
- e_->returns( r );
- }
-
- E* e_;
- };
-}
-} // mock
-
-#define MOCK_NUM_ARGS 0
-#define MOCK_NUM_ARGS_0
-#include "function_template.hpp"
-#undef MOCK_NUM_ARGS_0
-#undef MOCK_NUM_ARGS
-
-#define BOOST_PP_FILENAME_1
-#define BOOST_PP_ITERATION_LIMITS (1, MOCK_MAX_ARGS)
-#include BOOST_PP_ITERATE()
-#undef BOOST_PP_FILENAME_1
-#undef BOOST_PP_ITERATION_LIMITS
-
-#endif // MOCK_FUNCTION_HPP_INCLUDED
+// http://turtle.sourceforge.net
+//
+// Copyright Mathieu Champlon 2008
+//
+// 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)
+
+#ifndef MOCK_FUNCTION_HPP_INCLUDED
+#define MOCK_FUNCTION_HPP_INCLUDED
+
+#include "../config.hpp"
+#include "../error.hpp"
+#include "../log.hpp"
+#include "../constraints.hpp"
+#include "../sequence.hpp"
+#include "../matcher.hpp"
+#include "action.hpp"
+#include "verifiable.hpp"
+#include "invocation.hpp"
+#include "type_name.hpp"
+#include "context.hpp"
+#include "mutex.hpp"
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+namespace mock
+{
+namespace detail
+{
+ template< typename R, typename E >
+ struct wrapper_base
+ {
+ wrapper_base( E& e )
+ : e_( &e )
+ {}
+
+ template< typename T >
+ void returns( T t )
+ {
+ e_->returns( t );
+ }
+
+ E* e_;
+ };
+ template< typename E >
+ struct wrapper_base< void, E >
+ {
+ wrapper_base( E& e )
+ : e_( &e )
+ {}
+
+ E* e_;
+ };
+ template< typename R, typename E >
+ struct wrapper_base< R*, E >
+ {
+ wrapper_base( E& e )
+ : e_( &e )
+ {}
+
+ void returns( R* r )
+ {
+ e_->returns( r );
+ }
+ template< typename Y >
+ void returns( const boost::reference_wrapper< Y >& r )
+ {
+ e_->returns( r );
+ }
+
+ E* e_;
+ };
+}
+} // mock
+
+#define MOCK_NUM_ARGS 0
+#define MOCK_NUM_ARGS_0
+#include "function_template.hpp"
+#undef MOCK_NUM_ARGS_0
+#undef MOCK_NUM_ARGS
+
+#define BOOST_PP_FILENAME_1
+#define BOOST_PP_ITERATION_LIMITS (1, MOCK_MAX_ARGS)
+#include BOOST_PP_ITERATE()
+#undef BOOST_PP_FILENAME_1
+#undef BOOST_PP_ITERATION_LIMITS
+
+#endif // MOCK_FUNCTION_HPP_INCLUDED
diff --git a/turtle/detail/function_impl_template.hpp b/include/turtle/detail/function_impl_template.hpp
similarity index 93%
rename from turtle/detail/function_impl_template.hpp
rename to include/turtle/detail/function_impl_template.hpp
index 16205e7..32f04b3 100644
--- a/turtle/detail/function_impl_template.hpp
+++ b/include/turtle/detail/function_impl_template.hpp
@@ -1,304 +1,308 @@
-// http://turtle.sourceforge.net
-//
-// Copyright Mathieu Champlon 2012
-//
-// 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 "expectation_template.hpp"
-
-#ifndef MOCK_ERROR_POLICY
-# error no error policy has been set
-#endif
-
-#define MOCK_FUNCTION_FORMAT(z, n, N) \
- << ' ' << mock::format( t##n ) \
- << BOOST_PP_IF(BOOST_PP_EQUAL(N,n), ' ', ',')
-
-#define MOCK_FUNCTION_CONTEXT \
- boost::unit_test::lazy_ostream::instance() \
- << lazy_context( this ) \
- << '(' BOOST_PP_REPEAT(MOCK_NUM_ARGS, MOCK_FUNCTION_FORMAT, \
- BOOST_PP_DEC(MOCK_NUM_ARGS)) \
- << ')' \
- << lazy_expectations( this )
-
-namespace mock
-{
-namespace detail
-{
- template< typename Signature > class function_impl;
-
- template< typename R
- BOOST_PP_ENUM_TRAILING_PARAMS(MOCK_NUM_ARGS, typename T) >
- class function_impl< R ( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) ) >
- : public verifiable, public boost::enable_shared_from_this<
- function_impl< R ( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) )> >
- {
- public:
- typedef safe_error< R, MOCK_ERROR_POLICY< R > > error_type;
-
- public:
- function_impl()
- : context_( 0 )
- , valid_( true )
- , mutex_( boost::make_shared< mutex >() )
- {}
- virtual ~function_impl()
- {
- if( valid_ && ! std::uncaught_exception() )
- for( expectations_cit it = expectations_.begin();
- it != expectations_.end(); ++it )
- if( ! it->verify() )
- error_type::fail( "untriggered expectation",
- boost::unit_test::lazy_ostream::instance()
- << lazy_context( this )
- << lazy_expectations( this ),
- it->file(), it->line() );
- if( context_ )
- context_->remove( *this );
- }
-
- virtual bool verify() const
- {
- lock _( mutex_ );
- for( expectations_cit it = expectations_.begin();
- it != expectations_.end(); ++it )
- if( ! it->verify() )
- {
- valid_ = false;
- error_type::fail( "verification failed",
- boost::unit_test::lazy_ostream::instance()
- << lazy_context( this )
- << lazy_expectations( this ),
- it->file(), it->line() );
- }
- return valid_;
- }
-
- virtual void reset()
- {
- lock _( mutex_ );
- valid_ = true;
- boost::shared_ptr< function_impl > guard =
- this->shared_from_this();
- expectations_.clear();
- }
-
- private:
- typedef expectation<
- R( BOOST_PP_ENUM_PARAMS( MOCK_NUM_ARGS, T ) )
- > expectation_type;
-
- struct wrapper : wrapper_base< R, expectation_type >
- {
- wrapper( const boost::shared_ptr< mutex >& m, expectation_type& e )
- : wrapper_base< R, expectation_type >( e )
- , lock_( m )
- {}
-
- wrapper once()
- {
- this->e_->invoke( boost::make_shared< detail::once >() );
- return *this;
- }
- wrapper never()
- {
- this->e_->invoke( boost::make_shared< detail::never >() );
- return *this;
- }
- wrapper exactly( std::size_t count )
- {
- this->e_->invoke( boost::make_shared< detail::exactly >( count ) );
- return *this;
- }
- wrapper at_least( std::size_t min )
- {
- this->e_->invoke( boost::make_shared< detail::at_least >( min ) );
- return *this;
- }
- wrapper at_most( std::size_t max )
- {
- this->e_->invoke( boost::make_shared< detail::at_most >( max ) );
- return *this;
- }
- wrapper between( std::size_t min, std::size_t max )
- {
- this->e_->invoke( boost::make_shared< detail::between >( min, max ) );
- return *this;
- }
-
-#ifndef MOCK_NUM_ARGS_0
- template<
- BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, typename Constraint_)
- >
- wrapper with(
- BOOST_PP_ENUM_BINARY_PARAMS(MOCK_NUM_ARGS, Constraint_, c) )
- {
- this->e_->with(
- BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, c) );
- return *this;
- }
-#if MOCK_NUM_ARGS > 1
- template< typename Constraint >
- wrapper with( const Constraint& c )
- {
- this->e_->with( c );
- return *this;
- }
-#endif
-#endif
-
-#define MOCK_FUNCTION_IN_ADD(z, n, d) \
- this->e_->add( s##n );
-
-#define MOCK_FUNCTION_IN(z, n, d) \
- wrapper in( BOOST_PP_ENUM_PARAMS(n, sequence& s) ) \
- { \
- BOOST_PP_REPEAT(n, MOCK_FUNCTION_IN_ADD, _) \
- return *this; \
- }
-
- BOOST_PP_REPEAT(MOCK_MAX_SEQUENCES,
- MOCK_FUNCTION_IN, _)
-
-#undef MOCK_FUNCTION_IN
-#undef MOCK_FUNCTION_IN_ADD
-
- template< typename TT >
- void calls( TT t )
- {
- this->e_->calls( t );
- }
- template< typename TT >
- void throws( TT t )
- {
- this->e_->throws( t );
- }
- template< typename TT >
- void moves( TT t )
- {
- this->e_->moves( t );
- }
-
- lock lock_;
- };
-
- public:
- typedef wrapper wrapper_type;
-
- wrapper expect( const char* file, int line )
- {
- lock _( mutex_ );
- expectations_.push_back( expectation_type( file, line ) );
- valid_ = true;
- return wrapper( mutex_, expectations_.back() );
- }
- wrapper expect()
- {
- lock _( mutex_ );
- expectations_.push_back( expectation_type() );
- valid_ = true;
- return wrapper( mutex_, expectations_.back() );
- }
-
- R operator()(
- BOOST_PP_ENUM_BINARY_PARAMS(MOCK_NUM_ARGS, T, t) ) const
- {
- lock _( mutex_ );
- valid_ = false;
- for( expectations_cit it = expectations_.begin();
- it != expectations_.end(); ++it )
- if( it->is_valid(
- BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, t) ) )
- {
- if( ! it->invoke() )
- {
- error_type::fail( "sequence failed",
- MOCK_FUNCTION_CONTEXT, it->file(), it->line() );
- return error_type::abort();
- }
- if( ! it->valid() )
- {
- error_type::fail( "missing action",
- MOCK_FUNCTION_CONTEXT, it->file(), it->line() );
- return error_type::abort();
- }
- valid_ = true;
- error_type::call(
- MOCK_FUNCTION_CONTEXT, it->file(), it->line() );
- if( it->functor() )
- return it->functor()(
- BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, t) );
- return it->trigger();
- }
- error_type::fail( "unexpected call", MOCK_FUNCTION_CONTEXT );
- return error_type::abort();
- }
-
- void add( context& c, const void* p,
- boost::unit_test::const_string instance,
- boost::optional< type_name > type,
- boost::unit_test::const_string name )
- {
- lock _( mutex_ );
- if( ! context_ )
- c.add( *this );
- c.add( p, *this, instance, type, name );
- context_ = &c;
- }
-
- friend std::ostream& operator<<(
- std::ostream& s, const function_impl& impl )
- {
- lock _( impl.mutex_ );
- return s << lazy_context( &impl ) << lazy_expectations( &impl );
- }
-
- struct lazy_context
- {
- lazy_context( const function_impl* impl )
- : impl_( impl )
- {}
- friend std::ostream& operator<<(
- std::ostream& s, const lazy_context& c )
- {
- if( c.impl_->context_ )
- c.impl_->context_->serialize( s, *c.impl_ );
- else
- s << '?';
- return s;
- }
- const function_impl* impl_;
- };
-
- struct lazy_expectations
- {
- lazy_expectations( const function_impl* impl )
- : impl_( impl )
- {}
- friend std::ostream& operator<<(
- std::ostream& s, const lazy_expectations& e )
- {
- for( expectations_cit it = e.impl_->expectations_.begin();
- it != e.impl_->expectations_.end(); ++it )
- s << std::endl << *it;
- return s;
- }
- const function_impl* impl_;
- };
-
- typedef std::list< expectation_type > expectations_type;
- typedef typename expectations_type::const_iterator expectations_cit;
-
- expectations_type expectations_;
- context* context_;
- mutable bool valid_;
- const boost::shared_ptr< mutex > mutex_;
- };
-}
-} // mock
-
-#undef MOCK_FUNCTION_FORMAT
-#undef MOCK_FUNCTION_CONTEXT
+// http://turtle.sourceforge.net
+//
+// Copyright Mathieu Champlon 2012
+//
+// 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 "expectation_template.hpp"
+
+#ifndef MOCK_ERROR_POLICY
+# error no error policy has been set
+#endif
+
+#define MOCK_FUNCTION_FORMAT(z, n, N) \
+ << ' ' << mock::format( t##n ) \
+ << BOOST_PP_IF(BOOST_PP_EQUAL(N,n), ' ', ',')
+
+#define MOCK_FUNCTION_CONTEXT \
+ boost::unit_test::lazy_ostream::instance() \
+ << lazy_context( this ) \
+ << '(' BOOST_PP_REPEAT(MOCK_NUM_ARGS, MOCK_FUNCTION_FORMAT, \
+ BOOST_PP_DEC(MOCK_NUM_ARGS)) \
+ << ')' \
+ << lazy_expectations( this )
+
+namespace mock
+{
+namespace detail
+{
+ template< typename Signature > class function_impl;
+
+ template< typename R
+ BOOST_PP_ENUM_TRAILING_PARAMS(MOCK_NUM_ARGS, typename T) >
+ class function_impl< R ( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) ) >
+ : public verifiable, public boost::enable_shared_from_this<
+ function_impl< R ( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) )> >
+ {
+ public:
+ typedef safe_error< R, MOCK_ERROR_POLICY< R > > error_type;
+
+ public:
+ function_impl()
+ : context_( 0 )
+ , valid_( true )
+ , mutex_( boost::make_shared< mutex >() )
+ {}
+ virtual ~function_impl()
+ {
+ if( valid_ && ! std::uncaught_exception() )
+ for( expectations_cit it = expectations_.begin();
+ it != expectations_.end(); ++it )
+ if( ! it->verify() )
+ error_type::fail( "untriggered expectation",
+ boost::unit_test::lazy_ostream::instance()
+ << lazy_context( this )
+ << lazy_expectations( this ),
+ it->file(), it->line() );
+ if( context_ )
+ context_->remove( *this );
+ }
+
+ virtual bool verify() const
+ {
+ lock _( mutex_ );
+ for( expectations_cit it = expectations_.begin();
+ it != expectations_.end(); ++it )
+ if( ! it->verify() )
+ {
+ valid_ = false;
+ error_type::fail( "verification failed",
+ boost::unit_test::lazy_ostream::instance()
+ << lazy_context( this )
+ << lazy_expectations( this ),
+ it->file(), it->line() );
+ }
+ return valid_;
+ }
+
+ virtual void reset()
+ {
+ lock _( mutex_ );
+ valid_ = true;
+ boost::shared_ptr< function_impl > guard =
+ this->shared_from_this();
+ expectations_.clear();
+ }
+
+ private:
+ typedef expectation<
+ R( BOOST_PP_ENUM_PARAMS( MOCK_NUM_ARGS, T ) )
+ > expectation_type;
+
+ struct wrapper : wrapper_base< R, expectation_type >
+ {
+ wrapper( const boost::shared_ptr< mutex >& m, expectation_type& e )
+ : wrapper_base< R, expectation_type >( e )
+ , lock_( m )
+ {}
+
+ wrapper once()
+ {
+ this->e_->invoke( boost::make_shared< detail::once >() );
+ return *this;
+ }
+ wrapper never()
+ {
+ this->e_->invoke( boost::make_shared< detail::never >() );
+ return *this;
+ }
+ wrapper exactly( std::size_t count )
+ {
+ this->e_->invoke(
+ boost::make_shared< detail::exactly >( count ) );
+ return *this;
+ }
+ wrapper at_least( std::size_t min )
+ {
+ this->e_->invoke(
+ boost::make_shared< detail::at_least >( min ) );
+ return *this;
+ }
+ wrapper at_most( std::size_t max )
+ {
+ this->e_->invoke(
+ boost::make_shared< detail::at_most >( max ) );
+ return *this;
+ }
+ wrapper between( std::size_t min, std::size_t max )
+ {
+ this->e_->invoke(
+ boost::make_shared< detail::between >( min, max ) );
+ return *this;
+ }
+
+#ifndef MOCK_NUM_ARGS_0
+ template<
+ BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, typename Constraint_)
+ >
+ wrapper with(
+ BOOST_PP_ENUM_BINARY_PARAMS(MOCK_NUM_ARGS, Constraint_, c) )
+ {
+ this->e_->with(
+ BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, c) );
+ return *this;
+ }
+#if MOCK_NUM_ARGS > 1
+ template< typename Constraint >
+ wrapper with( const Constraint& c )
+ {
+ this->e_->with( c );
+ return *this;
+ }
+#endif
+#endif
+
+#define MOCK_FUNCTION_IN_ADD(z, n, d) \
+ this->e_->add( s##n );
+
+#define MOCK_FUNCTION_IN(z, n, d) \
+ wrapper in( BOOST_PP_ENUM_PARAMS(n, sequence& s) ) \
+ { \
+ BOOST_PP_REPEAT(n, MOCK_FUNCTION_IN_ADD, _) \
+ return *this; \
+ }
+
+ BOOST_PP_REPEAT(MOCK_MAX_SEQUENCES,
+ MOCK_FUNCTION_IN, _)
+
+#undef MOCK_FUNCTION_IN
+#undef MOCK_FUNCTION_IN_ADD
+
+ template< typename TT >
+ void calls( TT t )
+ {
+ this->e_->calls( t );
+ }
+ template< typename TT >
+ void throws( TT t )
+ {
+ this->e_->throws( t );
+ }
+ template< typename TT >
+ void moves( TT t )
+ {
+ this->e_->moves( t );
+ }
+
+ lock lock_;
+ };
+
+ public:
+ typedef wrapper wrapper_type;
+
+ wrapper expect( const char* file, int line )
+ {
+ lock _( mutex_ );
+ expectations_.push_back( expectation_type( file, line ) );
+ valid_ = true;
+ return wrapper( mutex_, expectations_.back() );
+ }
+ wrapper expect()
+ {
+ lock _( mutex_ );
+ expectations_.push_back( expectation_type() );
+ valid_ = true;
+ return wrapper( mutex_, expectations_.back() );
+ }
+
+ R operator()(
+ BOOST_PP_ENUM_BINARY_PARAMS(MOCK_NUM_ARGS, T, t) ) const
+ {
+ lock _( mutex_ );
+ valid_ = false;
+ for( expectations_cit it = expectations_.begin();
+ it != expectations_.end(); ++it )
+ if( it->is_valid(
+ BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, t) ) )
+ {
+ if( ! it->invoke() )
+ {
+ error_type::fail( "sequence failed",
+ MOCK_FUNCTION_CONTEXT, it->file(), it->line() );
+ return error_type::abort();
+ }
+ if( ! it->valid() )
+ {
+ error_type::fail( "missing action",
+ MOCK_FUNCTION_CONTEXT, it->file(), it->line() );
+ return error_type::abort();
+ }
+ valid_ = true;
+ error_type::call(
+ MOCK_FUNCTION_CONTEXT, it->file(), it->line() );
+ if( it->functor() )
+ return it->functor()(
+ BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, t) );
+ return it->trigger();
+ }
+ error_type::fail( "unexpected call", MOCK_FUNCTION_CONTEXT );
+ return error_type::abort();
+ }
+
+ void add( context& c, const void* p,
+ boost::unit_test::const_string instance,
+ boost::optional< type_name > type,
+ boost::unit_test::const_string name )
+ {
+ lock _( mutex_ );
+ if( ! context_ )
+ c.add( *this );
+ c.add( p, *this, instance, type, name );
+ context_ = &c;
+ }
+
+ friend std::ostream& operator<<(
+ std::ostream& s, const function_impl& impl )
+ {
+ lock _( impl.mutex_ );
+ return s << lazy_context( &impl ) << lazy_expectations( &impl );
+ }
+
+ struct lazy_context
+ {
+ lazy_context( const function_impl* impl )
+ : impl_( impl )
+ {}
+ friend std::ostream& operator<<(
+ std::ostream& s, const lazy_context& c )
+ {
+ if( c.impl_->context_ )
+ c.impl_->context_->serialize( s, *c.impl_ );
+ else
+ s << '?';
+ return s;
+ }
+ const function_impl* impl_;
+ };
+
+ struct lazy_expectations
+ {
+ lazy_expectations( const function_impl* impl )
+ : impl_( impl )
+ {}
+ friend std::ostream& operator<<(
+ std::ostream& s, const lazy_expectations& e )
+ {
+ for( expectations_cit it = e.impl_->expectations_.begin();
+ it != e.impl_->expectations_.end(); ++it )
+ s << std::endl << *it;
+ return s;
+ }
+ const function_impl* impl_;
+ };
+
+ typedef std::list< expectation_type > expectations_type;
+ typedef typename expectations_type::const_iterator expectations_cit;
+
+ expectations_type expectations_;
+ context* context_;
+ mutable bool valid_;
+ const boost::shared_ptr< mutex > mutex_;
+ };
+}
+} // mock
+
+#undef MOCK_FUNCTION_FORMAT
+#undef MOCK_FUNCTION_CONTEXT
diff --git a/turtle/detail/function_iterate.hpp b/include/turtle/detail/function_iterate.hpp
similarity index 96%
rename from turtle/detail/function_iterate.hpp
rename to include/turtle/detail/function_iterate.hpp
index 7bf1794..f86538e 100644
--- a/turtle/detail/function_iterate.hpp
+++ b/include/turtle/detail/function_iterate.hpp
@@ -1,11 +1,11 @@
-// http://turtle.sourceforge.net
-//
-// Copyright Mathieu Champlon 2012
-//
-// 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)
-
-#define MOCK_NUM_ARGS BOOST_PP_ITERATION()
-#include "function_template.hpp"
-#undef MOCK_NUM_ARGS
+// http://turtle.sourceforge.net
+//
+// Copyright Mathieu Champlon 2012
+//
+// 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)
+
+#define MOCK_NUM_ARGS BOOST_PP_ITERATION()
+#include "function_template.hpp"
+#undef MOCK_NUM_ARGS
diff --git a/turtle/detail/function_template.hpp b/include/turtle/detail/function_template.hpp
similarity index 96%
rename from turtle/detail/function_template.hpp
rename to include/turtle/detail/function_template.hpp
index 1093f28..f356eca 100644
--- a/turtle/detail/function_template.hpp
+++ b/include/turtle/detail/function_template.hpp
@@ -1,111 +1,111 @@
-// http://turtle.sourceforge.net
-//
-// Copyright Mathieu Champlon 2008
-//
-// 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 "function_impl_template.hpp"
-
-#define MOCK_FUNCTION_CALL(z, n, d ) \
- BOOST_PP_COMMA_IF(n) typename \
- boost::call_traits< T##n >::param_type
-
-#define MOCK_FUNCTION_PARAM(z, n, d) \
- MOCK_FUNCTION_CALL(z, n, d) t##n
-
-namespace mock
-{
-namespace detail
-{
- template< typename Signature > class function;
-
- template< typename R
- BOOST_PP_ENUM_TRAILING_PARAMS(MOCK_NUM_ARGS, typename T) >
- class function< R ( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) ) >
- {
- public:
- typedef R result_type;
-
- template< typename Args >
- struct sig
- {
- typedef R type;
- };
-
- private:
- typedef function_impl<
- R ( BOOST_PP_REPEAT(MOCK_NUM_ARGS, MOCK_FUNCTION_CALL, _) )
- > impl_type;
- typedef typename impl_type::wrapper_type expectation_type;
- typedef typename impl_type::error_type error_type;
-
- public:
- function()
- : impl_( boost::make_shared< impl_type >() )
- {}
-
- bool verify() const
- {
- return impl_->verify();
- }
- bool verify( const char* file, int line ) const
- {
- error_type::pass( file, line );
- return impl_->verify();
- }
- void reset()
- {
- impl_->reset();
- }
- void reset( const char* file, int line )
- {
- error_type::pass( file, line );
- impl_->reset();
- }
-
- expectation_type expect( const char* file, int line )
- {
- error_type::pass( file, line );
- return impl_->expect( file, line );
- }
- expectation_type expect()
- {
- return impl_->expect();
- }
-
- R operator()(
- BOOST_PP_REPEAT(MOCK_NUM_ARGS, MOCK_FUNCTION_PARAM, _) ) const
- {
- return (*impl_)( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, t) );
- }
-
- friend std::ostream& operator<<( std::ostream& s, const function& f )
- {
- return s << *f.impl_;
- }
-
- function& operator()( context& c,
- boost::unit_test::const_string instance )
- {
- impl_->add( c, impl_.get(), instance, boost::none, "" );
- return *this;
- }
-
- void configure( context& c, const void* p,
- boost::unit_test::const_string instance,
- boost::optional< type_name > type,
- boost::unit_test::const_string name ) const
- {
- impl_->add( c, p, instance, type, name );
- }
-
- private:
- boost::shared_ptr< impl_type > impl_;
- };
-}
-} // mock
-
-#undef MOCK_FUNCTION_CALL
-#undef MOCK_FUNCTION_PARAM
+// http://turtle.sourceforge.net
+//
+// Copyright Mathieu Champlon 2008
+//
+// 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 "function_impl_template.hpp"
+
+#define MOCK_FUNCTION_CALL(z, n, d ) \
+ BOOST_PP_COMMA_IF(n) typename \
+ boost::call_traits< T##n >::param_type
+
+#define MOCK_FUNCTION_PARAM(z, n, d) \
+ MOCK_FUNCTION_CALL(z, n, d) t##n
+
+namespace mock
+{
+namespace detail
+{
+ template< typename Signature > class function;
+
+ template< typename R
+ BOOST_PP_ENUM_TRAILING_PARAMS(MOCK_NUM_ARGS, typename T) >
+ class function< R ( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) ) >
+ {
+ public:
+ typedef R result_type;
+
+ template< typename Args >
+ struct sig
+ {
+ typedef R type;
+ };
+
+ private:
+ typedef function_impl<
+ R ( BOOST_PP_REPEAT(MOCK_NUM_ARGS, MOCK_FUNCTION_CALL, _) )
+ > impl_type;
+ typedef typename impl_type::wrapper_type expectation_type;
+ typedef typename impl_type::error_type error_type;
+
+ public:
+ function()
+ : impl_( boost::make_shared< impl_type >() )
+ {}
+
+ bool verify() const
+ {
+ return impl_->verify();
+ }
+ bool verify( const char* file, int line ) const
+ {
+ error_type::pass( file, line );
+ return impl_->verify();
+ }
+ void reset()
+ {
+ impl_->reset();
+ }
+ void reset( const char* file, int line )
+ {
+ error_type::pass( file, line );
+ impl_->reset();
+ }
+
+ expectation_type expect( const char* file, int line )
+ {
+ error_type::pass( file, line );
+ return impl_->expect( file, line );
+ }
+ expectation_type expect()
+ {
+ return impl_->expect();
+ }
+
+ R operator()(
+ BOOST_PP_REPEAT(MOCK_NUM_ARGS, MOCK_FUNCTION_PARAM, _) ) const
+ {
+ return (*impl_)( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, t) );
+ }
+
+ friend std::ostream& operator<<( std::ostream& s, const function& f )
+ {
+ return s << *f.impl_;
+ }
+
+ function& operator()( context& c,
+ boost::unit_test::const_string instance )
+ {
+ impl_->add( c, impl_.get(), instance, boost::none, "" );
+ return *this;
+ }
+
+ void configure( context& c, const void* p,
+ boost::unit_test::const_string instance,
+ boost::optional< type_name > type,
+ boost::unit_test::const_string name ) const
+ {
+ impl_->add( c, p, instance, type, name );
+ }
+
+ private:
+ boost::shared_ptr< impl_type > impl_;
+ };
+}
+} // mock
+
+#undef MOCK_FUNCTION_CALL
+#undef MOCK_FUNCTION_PARAM
diff --git a/turtle/detail/functor.hpp b/include/turtle/detail/functor.hpp
similarity index 95%
rename from turtle/detail/functor.hpp
rename to include/turtle/detail/functor.hpp
index b5c777e..232c7c9 100644
--- a/turtle/detail/functor.hpp
+++ b/include/turtle/detail/functor.hpp
@@ -1,52 +1,52 @@
-// http://turtle.sourceforge.net
-//
-// Copyright Mathieu Champlon 2012
-//
-// 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)
-
-#ifndef MOCK_FUNCTOR_HPP_INCLUDED
-#define MOCK_FUNCTOR_HPP_INCLUDED
-
-#include "../config.hpp"
-#include "function.hpp"
-#include "mutex.hpp"
-
-namespace mock
-{
-namespace detail
-{
- class functor_mutex_t :
- public boost::unit_test::singleton< functor_mutex_t >,
- public mutex
- {
- private:
- BOOST_TEST_SINGLETON_CONS( functor_mutex_t );
- };
- BOOST_TEST_SINGLETON_INST( functor_mutex )
-
- template< typename Signature >
- struct functor : function< Signature >
- {
- functor()
- {
- scoped_lock _( functor_mutex );
- static functor* f = 0;
- if( f )
- {
- *this = *f;
- f = 0;
- functor_mutex.unlock();
- }
- else
- {
- functor_mutex.lock();
- f = this;
- }
- }
- };
-}
-} // mock
-
-#endif // MOCK_FUNCTOR_HPP_INCLUDED
+// http://turtle.sourceforge.net
+//
+// Copyright Mathieu Champlon 2012
+//
+// 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)
+
+#ifndef MOCK_FUNCTOR_HPP_INCLUDED
+#define MOCK_FUNCTOR_HPP_INCLUDED
+
+#include "../config.hpp"
+#include "function.hpp"
+#include "mutex.hpp"
+
+namespace mock
+{
+namespace detail
+{
+ class functor_mutex_t :
+ public boost::unit_test::singleton< functor_mutex_t >,
+ public mutex
+ {
+ private:
+ BOOST_TEST_SINGLETON_CONS( functor_mutex_t );
+ };
+ BOOST_TEST_SINGLETON_INST( functor_mutex )
+
+ template< typename Signature >
+ struct functor : function< Signature >
+ {
+ functor()
+ {
+ scoped_lock _( functor_mutex );
+ static functor* f = 0;
+ if( f )
+ {
+ *this = *f;
+ f = 0;
+ functor_mutex.unlock();
+ }
+ else
+ {
+ functor_mutex.lock();
+ f = this;
+ }
+ }
+ };
+}
+} // mock
+
+#endif // MOCK_FUNCTOR_HPP_INCLUDED
diff --git a/turtle/detail/group.hpp b/include/turtle/detail/group.hpp
similarity index 96%
rename from turtle/detail/group.hpp
rename to include/turtle/detail/group.hpp
index 7d97f00..d0668cc 100644
--- a/turtle/detail/group.hpp
+++ b/include/turtle/detail/group.hpp
@@ -1,64 +1,64 @@
-// http://turtle.sourceforge.net
-//
-// Copyright Mathieu Champlon 2011
-//
-// 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)
-
-#ifndef MOCK_GROUP_HPP_INCLUDED
-#define MOCK_GROUP_HPP_INCLUDED
-
-#include "../config.hpp"
-#include "verifiable.hpp"
-#include
-#include
-#include
-
-namespace mock
-{
-namespace detail
-{
- class group
- {
- public:
- void add( verifiable& v )
- {
- verifiables_.push_back( &v );
- }
- void remove( verifiable& v )
- {
- verifiables_.erase(
- std::remove( verifiables_.begin(), verifiables_.end(), &v ),
- verifiables_.end() );
- }
-
- bool verify() const
- {
- bool valid = true;
- for( verifiables_cit it = verifiables_.begin();
- it != verifiables_.end(); ++it )
- if( ! (*it)->verify() )
- valid = false;
- return valid;
- }
- void reset()
- {
- const verifiables_t verifiables = verifiables_;
- for( verifiables_cit it = verifiables.begin();
- it != verifiables.end(); ++it )
- if( std::find( verifiables_.begin(), verifiables_.end(), *it )
- != verifiables_.end() )
- (*it)->reset();
- }
-
- private:
- typedef std::vector< verifiable* > verifiables_t;
- typedef verifiables_t::const_iterator verifiables_cit;
-
- verifiables_t verifiables_;
- };
-}
-} // mock
-
-#endif // MOCK_GROUP_HPP_INCLUDED
+// http://turtle.sourceforge.net
+//
+// Copyright Mathieu Champlon 2011
+//
+// 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)
+
+#ifndef MOCK_GROUP_HPP_INCLUDED
+#define MOCK_GROUP_HPP_INCLUDED
+
+#include "../config.hpp"
+#include "verifiable.hpp"
+#include
+#include
+#include
+
+namespace mock
+{
+namespace detail
+{
+ class group
+ {
+ public:
+ void add( verifiable& v )
+ {
+ verifiables_.push_back( &v );
+ }
+ void remove( verifiable& v )
+ {
+ verifiables_.erase(
+ std::remove( verifiables_.begin(), verifiables_.end(), &v ),
+ verifiables_.end() );
+ }
+
+ bool verify() const
+ {
+ bool valid = true;
+ for( verifiables_cit it = verifiables_.begin();
+ it != verifiables_.end(); ++it )
+ if( ! (*it)->verify() )
+ valid = false;
+ return valid;
+ }
+ void reset()
+ {
+ const verifiables_t verifiables = verifiables_;
+ for( verifiables_cit it = verifiables.begin();
+ it != verifiables.end(); ++it )
+ if( std::find( verifiables_.begin(), verifiables_.end(), *it )
+ != verifiables_.end() )
+ (*it)->reset();
+ }
+
+ private:
+ typedef std::vector< verifiable* > verifiables_t;
+ typedef verifiables_t::const_iterator verifiables_cit;
+
+ verifiables_t verifiables_;
+ };
+}
+} // mock
+
+#endif // MOCK_GROUP_HPP_INCLUDED
diff --git a/turtle/detail/invocation.hpp b/include/turtle/detail/invocation.hpp
similarity index 95%
rename from turtle/detail/invocation.hpp
rename to include/turtle/detail/invocation.hpp
index bf13310..fd1c0f6 100644
--- a/turtle/detail/invocation.hpp
+++ b/include/turtle/detail/invocation.hpp
@@ -1,170 +1,170 @@
-// http://turtle.sourceforge.net
-//
-// Copyright Mathieu Champlon 2008
-//
-// 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)
-
-#ifndef MOCK_INVOCATION_HPP_INCLUDED
-#define MOCK_INVOCATION_HPP_INCLUDED
-
-#include "../config.hpp"
-#include
-#include
-#include
-#include
-
-namespace mock
-{
-namespace detail
-{
- class invocation : private boost::noncopyable
- {
- public:
- invocation() {}
- virtual ~invocation() {}
-
- virtual bool invoke() = 0;
- virtual bool verify() const = 0;
-
- virtual bool exhausted() const = 0;
-
- friend std::ostream& operator<<( std::ostream& s, const invocation& i )
- {
- return i.serialize( s );
- }
-
- private:
- virtual std::ostream& serialize( std::ostream& s ) const = 0;
- };
-
- class between : public invocation
- {
- public:
- between( std::size_t min, std::size_t max )
- : min_( min )
- , max_( max )
- , count_( 0 )
- {
- if( min > max )
- throw std::invalid_argument( "'min' > 'max'" );
- }
-
- virtual bool invoke()
- {
- if( count_ == max_ )
- return false;
- ++count_;
- return true;
- }
-
- virtual bool exhausted() const
- {
- return count_ >= max_;
- }
-
- virtual bool verify() const
- {
- return min_ <= count_ && count_ <= max_;
- }
-
- protected:
- const std::size_t min_, max_;
- std::size_t count_;
-
- private:
- virtual std::ostream& serialize( std::ostream& s ) const
- {
- return s << "between( " << count_
- << "/[" << min_ << ',' << max_ << "] )";
- }
- };
-
- class exactly : public between
- {
- public:
- explicit exactly( std::size_t count )
- : between( count, count )
- {}
-
- private:
- virtual std::ostream& serialize( std::ostream& s ) const
- {
- return s << "exactly( " << count_ << '/' << max_ << " )";
- }
- };
-
- class never : public exactly
- {
- public:
- never()
- : exactly( 0 )
- {}
-
- private:
- virtual std::ostream& serialize( std::ostream& s ) const
- {
- return s << "never()";
- }
- };
-
- class once : public exactly
- {
- public:
- once()
- : exactly( 1 )
- {}
-
- private:
- virtual std::ostream& serialize( std::ostream& s ) const
- {
- return s << "once()";
- }
- };
-
- class at_least : public between
- {
- public:
- explicit at_least( std::size_t min )
- : between( min, (std::numeric_limits< std::size_t >::max)() )
- {}
-
- private:
- virtual std::ostream& serialize( std::ostream& s ) const
- {
- return s << "at_least( " << count_ << '/' << min_ << " )";
- }
- };
-
- class at_most : public between
- {
- public:
- explicit at_most( std::size_t max )
- : between( 0, max )
- {}
-
- private:
- virtual std::ostream& serialize( std::ostream& s ) const
- {
- return s << "at_most( " << count_ << '/' << max_ << " )";
- }
- };
-
- class unlimited : public at_least
- {
- public:
- unlimited()
- : at_least( 0 )
- {}
-
- private:
- virtual std::ostream& serialize( std::ostream& s ) const
- {
- return s << "unlimited()";
- }
- };
-}
-} // mock
-
-#endif // MOCK_INVOCATION_HPP_INCLUDED
+// http://turtle.sourceforge.net
+//
+// Copyright Mathieu Champlon 2008
+//
+// 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)
+
+#ifndef MOCK_INVOCATION_HPP_INCLUDED
+#define MOCK_INVOCATION_HPP_INCLUDED
+
+#include "../config.hpp"
+#include
+#include
+#include
+#include
+
+namespace mock
+{
+namespace detail
+{
+ class invocation : private boost::noncopyable
+ {
+ public:
+ invocation() {}
+ virtual ~invocation() {}
+
+ virtual bool invoke() = 0;
+ virtual bool verify() const = 0;
+
+ virtual bool exhausted() const = 0;
+
+ friend std::ostream& operator<<( std::ostream& s, const invocation& i )
+ {
+ return i.serialize( s );
+ }
+
+ private:
+ virtual std::ostream& serialize( std::ostream& s ) const = 0;
+ };
+
+ class between : public invocation
+ {
+ public:
+ between( std::size_t min, std::size_t max )
+ : min_( min )
+ , max_( max )
+ , count_( 0 )
+ {
+ if( min > max )
+ throw std::invalid_argument( "'min' > 'max'" );
+ }
+
+ virtual bool invoke()
+ {
+ if( count_ == max_ )
+ return false;
+ ++count_;
+ return true;
+ }
+
+ virtual bool exhausted() const
+ {
+ return count_ >= max_;
+ }
+
+ virtual bool verify() const
+ {
+ return min_ <= count_ && count_ <= max_;
+ }
+
+ protected:
+ const std::size_t min_, max_;
+ std::size_t count_;
+
+ private:
+ virtual std::ostream& serialize( std::ostream& s ) const
+ {
+ return s << "between( " << count_
+ << "/[" << min_ << ',' << max_ << "] )";
+ }
+ };
+
+ class exactly : public between
+ {
+ public:
+ explicit exactly( std::size_t count )
+ : between( count, count )
+ {}
+
+ private:
+ virtual std::ostream& serialize( std::ostream& s ) const
+ {
+ return s << "exactly( " << count_ << '/' << max_ << " )";
+ }
+ };
+
+ class never : public exactly
+ {
+ public:
+ never()
+ : exactly( 0 )
+ {}
+
+ private:
+ virtual std::ostream& serialize( std::ostream& s ) const
+ {
+ return s << "never()";
+ }
+ };
+
+ class once : public exactly
+ {
+ public:
+ once()
+ : exactly( 1 )
+ {}
+
+ private:
+ virtual std::ostream& serialize( std::ostream& s ) const
+ {
+ return s << "once()";
+ }
+ };
+
+ class at_least : public between
+ {
+ public:
+ explicit at_least( std::size_t min )
+ : between( min, (std::numeric_limits< std::size_t >::max)() )
+ {}
+
+ private:
+ virtual std::ostream& serialize( std::ostream& s ) const
+ {
+ return s << "at_least( " << count_ << '/' << min_ << " )";
+ }
+ };
+
+ class at_most : public between
+ {
+ public:
+ explicit at_most( std::size_t max )
+ : between( 0, max )
+ {}
+
+ private:
+ virtual std::ostream& serialize( std::ostream& s ) const
+ {
+ return s << "at_most( " << count_ << '/' << max_ << " )";
+ }
+ };
+
+ class unlimited : public at_least
+ {
+ public:
+ unlimited()
+ : at_least( 0 )
+ {}
+
+ private:
+ virtual std::ostream& serialize( std::ostream& s ) const
+ {
+ return s << "unlimited()";
+ }
+ };
+}
+} // mock
+
+#endif // MOCK_INVOCATION_HPP_INCLUDED
diff --git a/turtle/detail/is_functor.hpp b/include/turtle/detail/is_functor.hpp
similarity index 96%
rename from turtle/detail/is_functor.hpp
rename to include/turtle/detail/is_functor.hpp
index c2007b0..5d4de95 100644
--- a/turtle/detail/is_functor.hpp
+++ b/include/turtle/detail/is_functor.hpp
@@ -1,62 +1,62 @@
-// http://turtle.sourceforge.net
-//
-// Copyright Mathieu Champlon 2009
-//
-// 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)
-
-#ifndef MOCK_IS_FUNCTOR_HPP_INCLUDED
-#define MOCK_IS_FUNCTOR_HPP_INCLUDED
-
-#include "../config.hpp"
-#include
-#include
-#include
-#include
-#include
-
-namespace mock
-{
-namespace detail
-{
- BOOST_MPL_HAS_XXX_TRAIT_DEF( result_type )
- BOOST_MPL_HAS_XXX_TEMPLATE_DEF( sig )
- BOOST_MPL_HAS_XXX_TEMPLATE_DEF( result )
-
-#ifdef MOCK_DECLTYPE
-
- template< typename F, typename P >
- struct is_callable
- {
- typedef boost::type_traits::yes_type yes_type;
- typedef boost::type_traits::no_type no_type;
-
- template< typename T >
- static yes_type check(
- decltype( boost::declval< T >()( boost::declval< P >() ) )* );
- template< typename T >
- static no_type check( ... );
-
- typedef boost::mpl::bool_<
- sizeof( check< F >( 0 ) ) == sizeof( yes_type ) > type;
- };
-
-#endif // MOCK_DECLTYPE
-
- template< typename T, typename P >
- struct is_functor
- : boost::mpl::or_<
- boost::function_types::is_callable_builtin< T >,
-#ifdef MOCK_DECLTYPE
- is_callable< T, P >,
-#endif
- has_result_type< T >,
- has_result< T >,
- has_sig< T >
- >
- {};
-}
-} // mock
-
-#endif // MOCK_IS_FUNCTOR_HPP_INCLUDED
+// http://turtle.sourceforge.net
+//
+// Copyright Mathieu Champlon 2009
+//
+// 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)
+
+#ifndef MOCK_IS_FUNCTOR_HPP_INCLUDED
+#define MOCK_IS_FUNCTOR_HPP_INCLUDED
+
+#include "../config.hpp"
+#include
+#include
+#include
+#include
+#include
+
+namespace mock
+{
+namespace detail
+{
+ BOOST_MPL_HAS_XXX_TRAIT_DEF( result_type )
+ BOOST_MPL_HAS_XXX_TEMPLATE_DEF( sig )
+ BOOST_MPL_HAS_XXX_TEMPLATE_DEF( result )
+
+#ifdef MOCK_DECLTYPE
+
+ template< typename F, typename P >
+ struct is_callable
+ {
+ typedef boost::type_traits::yes_type yes_type;
+ typedef boost::type_traits::no_type no_type;
+
+ template< typename T >
+ static yes_type check(
+ decltype( boost::declval< T >()( boost::declval< P >() ) )* );
+ template< typename T >
+ static no_type check( ... );
+
+ typedef boost::mpl::bool_<
+ sizeof( check< F >( 0 ) ) == sizeof( yes_type ) > type;
+ };
+
+#endif // MOCK_DECLTYPE
+
+ template< typename T, typename P >
+ struct is_functor
+ : boost::mpl::or_<
+ boost::function_types::is_callable_builtin< T >,
+#ifdef MOCK_DECLTYPE
+ is_callable< T, P >,
+#endif
+ has_result_type< T >,
+ has_result< T >,
+ has_sig< T >
+ >
+ {};
+}
+} // mock
+
+#endif // MOCK_IS_FUNCTOR_HPP_INCLUDED
diff --git a/turtle/detail/matcher_base_template.hpp b/include/turtle/detail/matcher_base_template.hpp
similarity index 96%
rename from turtle/detail/matcher_base_template.hpp
rename to include/turtle/detail/matcher_base_template.hpp
index 7636c2f..d3d0993 100644
--- a/turtle/detail/matcher_base_template.hpp
+++ b/include/turtle/detail/matcher_base_template.hpp
@@ -1,37 +1,37 @@
-// http://turtle.sourceforge.net
-//
-// Copyright Mathieu Champlon 2012
-//
-// 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)
-
-namespace mock
-{
-namespace detail
-{
- template< typename Signature > class matcher_base;
-
- template<
- BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, typename Actual_) >
- class matcher_base< void( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, Actual_) ) >
- : boost::noncopyable
- {
- public:
- virtual ~matcher_base() {}
-
- virtual bool operator()(
- BOOST_PP_ENUM_BINARY_PARAMS(MOCK_NUM_ARGS, Actual_, actual_) ) = 0;
-
- friend std::ostream& operator<<(
- std::ostream& s, const matcher_base& m )
- {
- m.serialize( s );
- return s;
- }
-
- private:
- virtual void serialize( std::ostream& ) const = 0;
- };
-}
-} // mock
+// http://turtle.sourceforge.net
+//
+// Copyright Mathieu Champlon 2012
+//
+// 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)
+
+namespace mock
+{
+namespace detail
+{
+ template< typename Signature > class matcher_base;
+
+ template<
+ BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, typename Actual_) >
+ class matcher_base< void( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, Actual_) ) >
+ : boost::noncopyable
+ {
+ public:
+ virtual ~matcher_base() {}
+
+ virtual bool operator()(
+ BOOST_PP_ENUM_BINARY_PARAMS(MOCK_NUM_ARGS, Actual_, actual_) ) = 0;
+
+ friend std::ostream& operator<<(
+ std::ostream& s, const matcher_base& m )
+ {
+ m.serialize( s );
+ return s;
+ }
+
+ private:
+ virtual void serialize( std::ostream& ) const = 0;
+ };
+}
+} // mock
diff --git a/turtle/detail/mutex.hpp b/include/turtle/detail/mutex.hpp
similarity index 95%
rename from turtle/detail/mutex.hpp
rename to include/turtle/detail/mutex.hpp
index fdb643d..4837c6c 100644
--- a/turtle/detail/mutex.hpp
+++ b/include/turtle/detail/mutex.hpp
@@ -1,141 +1,141 @@
-// 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)
-
-#ifndef MOCK_MUTEX_HPP_INCLUDED
-#define MOCK_MUTEX_HPP_INCLUDED
-
-#include "../config.hpp"
-#include
-#include
-
-#ifdef MOCK_THREAD_SAFE
-
-#ifdef MOCK_HDR_MUTEX
-#include
-#else
-#include
-#include
-#endif
-
-namespace mock
-{
-namespace detail
-{
-#ifdef MOCK_HDR_MUTEX
- typedef std::recursive_mutex mutex;
- typedef std::lock_guard< mutex > scoped_lock;
-#else
- typedef boost::recursive_mutex mutex;
- typedef boost::lock_guard< mutex > scoped_lock;
-#endif
-
- struct lock
- {
- lock( const boost::shared_ptr< mutex >& m )
- : m_( m )
- {
- m_->lock();
- }
- lock( const lock& rhs )
- {
- m_.swap( rhs.m_ );
- }
- ~lock()
- {
- if( m_ )
- m_->unlock();
- }
-
- private:
- lock& operator=( const lock& rhs );
-
- mutable boost::shared_ptr< mutex > m_;
- };
-}
-} // mock
-
-#else // MOCK_THREAD_SAFE
-
-namespace mock
-{
-namespace detail
-{
- struct mutex
- {
- mutex()
- {}
- void lock()
- {}
- void unlock()
- {}
- };
- struct scoped_lock
- {
- scoped_lock( mutex& )
- {}
- };
- struct lock
- {
- lock( const boost::shared_ptr< mutex >& )
- {}
- };
-}
-} // mock
-
-#endif // MOCK_THREAD_SAFE
-
-namespace mock
-{
-namespace detail
-{
- class error_mutex_t : public boost::unit_test::singleton< error_mutex_t >,
- public mutex
- {
- private:
- BOOST_TEST_SINGLETON_CONS( error_mutex_t );
- };
- BOOST_TEST_SINGLETON_INST( error_mutex )
-
-#ifdef BOOST_MSVC
-# pragma warning( push )
-# pragma warning( disable: 4702 )
-#endif
- template< typename Result, typename Error >
- struct safe_error
- {
- static Result abort()
- {
- scoped_lock _( error_mutex );
- return Error::abort();
- }
- template< typename Context >
- static void fail( const char* message, const Context& context,
- const char* file = "unknown location", int line = 0 )
- {
- scoped_lock _( error_mutex );
- Error::fail( message, context, file, line );
- }
- template< typename Context >
- static void call( const Context& context, const char* file, int line )
- {
- scoped_lock _( error_mutex );
- Error::call( context, file, line );
- }
- static void pass( const char* file, int line )
- {
- scoped_lock _( error_mutex );
- Error::pass( file, line );
- }
- };
-#ifdef BOOST_MSVC
-# pragma warning( pop )
-#endif
-}
-} // mock
-
-#endif // MOCK_MUTEX_HPP_INCLUDED
+// 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)
+
+#ifndef MOCK_MUTEX_HPP_INCLUDED
+#define MOCK_MUTEX_HPP_INCLUDED
+
+#include "../config.hpp"
+#include
+#include
+
+#ifdef MOCK_THREAD_SAFE
+
+#ifdef MOCK_HDR_MUTEX
+#include
+#else
+#include
+#include
+#endif
+
+namespace mock
+{
+namespace detail
+{
+#ifdef MOCK_HDR_MUTEX
+ typedef std::recursive_mutex mutex;
+ typedef std::lock_guard< mutex > scoped_lock;
+#else
+ typedef boost::recursive_mutex mutex;
+ typedef boost::lock_guard< mutex > scoped_lock;
+#endif
+
+ struct lock
+ {
+ lock( const boost::shared_ptr< mutex >& m )
+ : m_( m )
+ {
+ m_->lock();
+ }
+ lock( const lock& rhs )
+ {
+ m_.swap( rhs.m_ );
+ }
+ ~lock()
+ {
+ if( m_ )
+ m_->unlock();
+ }
+
+ private:
+ lock& operator=( const lock& rhs );
+
+ mutable boost::shared_ptr< mutex > m_;
+ };
+}
+} // mock
+
+#else // MOCK_THREAD_SAFE
+
+namespace mock
+{
+namespace detail
+{
+ struct mutex
+ {
+ mutex()
+ {}
+ void lock()
+ {}
+ void unlock()
+ {}
+ };
+ struct scoped_lock
+ {
+ scoped_lock( mutex& )
+ {}
+ };
+ struct lock
+ {
+ lock( const boost::shared_ptr< mutex >& )
+ {}
+ };
+}
+} // mock
+
+#endif // MOCK_THREAD_SAFE
+
+namespace mock
+{
+namespace detail
+{
+ class error_mutex_t : public boost::unit_test::singleton< error_mutex_t >,
+ public mutex
+ {
+ private:
+ BOOST_TEST_SINGLETON_CONS( error_mutex_t );
+ };
+ BOOST_TEST_SINGLETON_INST( error_mutex )
+
+#ifdef BOOST_MSVC
+# pragma warning( push )
+# pragma warning( disable: 4702 )
+#endif
+ template< typename Result, typename Error >
+ struct safe_error
+ {
+ static Result abort()
+ {
+ scoped_lock _( error_mutex );
+ return Error::abort();
+ }
+ template< typename Context >
+ static void fail( const char* message, const Context& context,
+ const char* file = "unknown location", int line = 0 )
+ {
+ scoped_lock _( error_mutex );
+ Error::fail( message, context, file, line );
+ }
+ template< typename Context >
+ static void call( const Context& context, const char* file, int line )
+ {
+ scoped_lock _( error_mutex );
+ Error::call( context, file, line );
+ }
+ static void pass( const char* file, int line )
+ {
+ scoped_lock _( error_mutex );
+ Error::pass( file, line );
+ }
+ };
+#ifdef BOOST_MSVC
+# pragma warning( pop )
+#endif
+}
+} // mock
+
+#endif // MOCK_MUTEX_HPP_INCLUDED
diff --git a/turtle/detail/object_impl.hpp b/include/turtle/detail/object_impl.hpp
similarity index 96%
rename from turtle/detail/object_impl.hpp
rename to include/turtle/detail/object_impl.hpp
index 20e3fa1..6aa215f 100644
--- a/turtle/detail/object_impl.hpp
+++ b/include/turtle/detail/object_impl.hpp
@@ -1,94 +1,94 @@
-// http://turtle.sourceforge.net
-//
-// Copyright Mathieu Champlon 2012
-//
-// 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)
-
-#ifndef MOCK_OBJECT_IMPL_HPP_INCLUDED
-#define MOCK_OBJECT_IMPL_HPP_INCLUDED
-
-#include "../config.hpp"
-#include "root.hpp"
-#include "parent.hpp"
-#include "type_name.hpp"
-#include "context.hpp"
-#include "child.hpp"
-#include "mutex.hpp"
-#include
-#include
-#include
-#include
-
-namespace mock
-{
-namespace detail
-{
- class object_impl : public context, public verifiable,
- public boost::enable_shared_from_this< object_impl >
- {
- public:
- object_impl()
- : mutex_( boost::make_shared< mutex >() )
- {}
-
- virtual void add( const void* /*p*/, verifiable& v,
- boost::unit_test::const_string instance,
- boost::optional< type_name > type,
- boost::unit_test::const_string name )
- {
- lock _( mutex_ );
- if( children_.empty() )
- detail::root.add( *this );
- children_[ &v ].update( parent_, instance, type, name );
- }
- virtual void add( verifiable& v )
- {
- lock _( mutex_ );
- group_.add( v );
- }
- virtual void remove( verifiable& v )
- {
- lock _( mutex_ );
- group_.remove( v );
- children_.erase( &v );
- if( children_.empty() )
- detail::root.remove( *this );
- }
-
- virtual void serialize( std::ostream& s, const verifiable& v ) const
- {
- lock _( mutex_ );
- children_cit it = children_.find( &v );
- if( it != children_.end() )
- s << it->second;
- else
- s << "?";
- }
-
- virtual bool verify() const
- {
- lock _( mutex_ );
- return group_.verify();
- }
- virtual void reset()
- {
- lock _( mutex_ );
- boost::shared_ptr< object_impl > guard = shared_from_this();
- group_.reset();
- }
-
- private:
- typedef std::map< const verifiable*, child > children_t;
- typedef children_t::const_iterator children_cit;
-
- group group_;
- parent parent_;
- children_t children_;
- const boost::shared_ptr< mutex > mutex_;
- };
-}
-} // mock
-
-#endif // MOCK_OBJECT_IMPL_HPP_INCLUDED
+// http://turtle.sourceforge.net
+//
+// Copyright Mathieu Champlon 2012
+//
+// 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)
+
+#ifndef MOCK_OBJECT_IMPL_HPP_INCLUDED
+#define MOCK_OBJECT_IMPL_HPP_INCLUDED
+
+#include "../config.hpp"
+#include "root.hpp"
+#include "parent.hpp"
+#include "type_name.hpp"
+#include "context.hpp"
+#include "child.hpp"
+#include "mutex.hpp"
+#include
+#include
+#include
+#include
+
+namespace mock
+{
+namespace detail
+{
+ class object_impl : public context, public verifiable,
+ public boost::enable_shared_from_this< object_impl >
+ {
+ public:
+ object_impl()
+ : mutex_( boost::make_shared< mutex >() )
+ {}
+
+ virtual void add( const void* /*p*/, verifiable& v,
+ boost::unit_test::const_string instance,
+ boost::optional< type_name > type,
+ boost::unit_test::const_string name )
+ {
+ lock _( mutex_ );
+ if( children_.empty() )
+ detail::root.add( *this );
+ children_[ &v ].update( parent_, instance, type, name );
+ }
+ virtual void add( verifiable& v )
+ {
+ lock _( mutex_ );
+ group_.add( v );
+ }
+ virtual void remove( verifiable& v )
+ {
+ lock _( mutex_ );
+ group_.remove( v );
+ children_.erase( &v );
+ if( children_.empty() )
+ detail::root.remove( *this );
+ }
+
+ virtual void serialize( std::ostream& s, const verifiable& v ) const
+ {
+ lock _( mutex_ );
+ children_cit it = children_.find( &v );
+ if( it != children_.end() )
+ s << it->second;
+ else
+ s << "?";
+ }
+
+ virtual bool verify() const
+ {
+ lock _( mutex_ );
+ return group_.verify();
+ }
+ virtual void reset()
+ {
+ lock _( mutex_ );
+ boost::shared_ptr< object_impl > guard = shared_from_this();
+ group_.reset();
+ }
+
+ private:
+ typedef std::map< const verifiable*, child > children_t;
+ typedef children_t::const_iterator children_cit;
+
+ group group_;
+ parent parent_;
+ children_t children_;
+ const boost::shared_ptr< mutex > mutex_;
+ };
+}
+} // mock
+
+#endif // MOCK_OBJECT_IMPL_HPP_INCLUDED
diff --git a/turtle/detail/parameter.hpp b/include/turtle/detail/parameter.hpp
similarity index 96%
rename from turtle/detail/parameter.hpp
rename to include/turtle/detail/parameter.hpp
index 2135fd2..38925a2 100644
--- a/turtle/detail/parameter.hpp
+++ b/include/turtle/detail/parameter.hpp
@@ -1,34 +1,34 @@
-// http://turtle.sourceforge.net
-//
-// Copyright Mathieu Champlon 2012
-//
-// 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)
-
-#ifndef MOCK_PARAMETER_HPP_INCLUDED
-#define MOCK_PARAMETER_HPP_INCLUDED
-
-#include "../config.hpp"
-#include
-#include
-#include
-
-namespace mock
-{
-namespace detail
-{
- template< typename Signature, int n >
- struct parameter
- {
- typedef typename
- boost::mpl::at_c<
- typename
- boost::function_types::parameter_types< Signature >,
- n
- >::type type;
- };
-}
-} // mock
-
-#endif // MOCK_PARAMETER_HPP_INCLUDED
+// http://turtle.sourceforge.net
+//
+// Copyright Mathieu Champlon 2012
+//
+// 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)
+
+#ifndef MOCK_PARAMETER_HPP_INCLUDED
+#define MOCK_PARAMETER_HPP_INCLUDED
+
+#include "../config.hpp"
+#include
+#include
+#include
+
+namespace mock
+{
+namespace detail
+{
+ template< typename Signature, int n >
+ struct parameter
+ {
+ typedef typename
+ boost::mpl::at_c<
+ typename
+ boost::function_types::parameter_types< Signature >,
+ n
+ >::type type;
+ };
+}
+} // mock
+
+#endif // MOCK_PARAMETER_HPP_INCLUDED
diff --git a/turtle/detail/parent.hpp b/include/turtle/detail/parent.hpp
similarity index 95%
rename from turtle/detail/parent.hpp
rename to include/turtle/detail/parent.hpp
index d793273..0d14e77 100644
--- a/turtle/detail/parent.hpp
+++ b/include/turtle/detail/parent.hpp
@@ -1,46 +1,46 @@
-// http://turtle.sourceforge.net
-//
-// Copyright Mathieu Champlon 2011
-//
-// 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)
-
-#ifndef MOCK_PARENT_HPP_INCLUDED
-#define MOCK_PARENT_HPP_INCLUDED
-
-#include "../config.hpp"
-#include "type_name.hpp"
-#include
-#include
-#include
-
-namespace mock
-{
-namespace detail
-{
- class parent
- {
- public:
- parent()
- {}
- parent( boost::unit_test::const_string instance,
- boost::optional< type_name > type )
- : instance_( instance )
- , type_( type )
- {}
- friend std::ostream& operator<<( std::ostream& s, const parent& p )
- {
- s << p.instance_;
- if( p.type_ )
- s << *p.type_ << "::";
- return s;
- }
- private:
- boost::unit_test::const_string instance_;
- boost::optional< type_name > type_;
- };
-}
-} // mock
-
-#endif // MOCK_PARENT_HPP_INCLUDED
+// http://turtle.sourceforge.net
+//
+// Copyright Mathieu Champlon 2011
+//
+// 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)
+
+#ifndef MOCK_PARENT_HPP_INCLUDED
+#define MOCK_PARENT_HPP_INCLUDED
+
+#include "../config.hpp"
+#include "type_name.hpp"
+#include
+#include
+#include
+
+namespace mock
+{
+namespace detail
+{
+ class parent
+ {
+ public:
+ parent()
+ {}
+ parent( boost::unit_test::const_string instance,
+ boost::optional< type_name > type )
+ : instance_( instance )
+ , type_( type )
+ {}
+ friend std::ostream& operator<<( std::ostream& s, const parent& p )
+ {
+ s << p.instance_;
+ if( p.type_ )
+ s << *p.type_ << "::";
+ return s;
+ }
+ private:
+ boost::unit_test::const_string instance_;
+ boost::optional< type_name > type_;
+ };
+}
+} // mock
+
+#endif // MOCK_PARENT_HPP_INCLUDED
diff --git a/turtle/detail/root.hpp b/include/turtle/detail/root.hpp
similarity index 96%
rename from turtle/detail/root.hpp
rename to include/turtle/detail/root.hpp
index d56954c..2006a28 100644
--- a/turtle/detail/root.hpp
+++ b/include/turtle/detail/root.hpp
@@ -1,138 +1,138 @@
-// http://turtle.sourceforge.net
-//
-// Copyright Mathieu Champlon 2008
-//
-// 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)
-
-#ifndef MOCK_ROOT_HPP_INCLUDED
-#define MOCK_ROOT_HPP_INCLUDED
-
-#include "../config.hpp"
-#include "parent.hpp"
-#include "group.hpp"
-#include "context.hpp"
-#include "child.hpp"
-#include "mutex.hpp"
-#include
-#include
-#include
-#include