mirror of
https://github.com/mat007/turtle.git
synced 2026-06-22 12:13:43 +00:00
commit
df20ff111f
126 changed files with 15627 additions and 15564 deletions
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
bin
|
||||||
|
out
|
||||||
85
.travis.yml
Normal file
85
.travis.yml
Normal file
|
|
@ -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
|
||||||
|
|
@ -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 ;
|
import modules ;
|
||||||
|
|
||||||
13
README.md
Normal file
13
README.md
Normal file
|
|
@ -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).
|
||||||
37
build/build.bat
Normal file
37
build/build.bat
Normal file
|
|
@ -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
|
||||||
|
|
@ -1,5 +1 @@
|
||||||
extensions = svn,headers,check
|
extensions = headers,check,run
|
||||||
src.dir = ${root.dir}
|
|
||||||
tests.dir = ${root.dir}
|
|
||||||
libraries.dir = ${root.dir}
|
|
||||||
boost.dir = ${out.dir}/../boost
|
|
||||||
|
|
|
||||||
40
build/build.sh
Executable file
40
build/build.sh
Executable file
|
|
@ -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
|
||||||
235
build/build.xml
235
build/build.xml
|
|
@ -1,173 +1,60 @@
|
||||||
|
<!--
|
||||||
|
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)
|
||||||
|
-->
|
||||||
<project name="turtle" default="all">
|
<project name="turtle" default="all">
|
||||||
|
|
||||||
<property environment="env"/>
|
<property environment="env"/>
|
||||||
|
<fail unless="env.BOOST_ROOT" message="missing BOOST_ROOT environment variable"/>
|
||||||
|
<property name="boost.dir" value="${env.BOOST_ROOT}"/>
|
||||||
|
<property name="src.dir" value="${root.dir}"/>
|
||||||
|
<property name="doc.dir" value="${src.dir}/doc"/>
|
||||||
|
<property name="libraries.dir" value="${src.dir}/include"/>
|
||||||
|
<property name="out.dir" value="${root.dir}/bin/poney/${platform}"/>
|
||||||
|
<property name="boost-mock.dir" value="${out.dir}/boost-mock"/>
|
||||||
|
|
||||||
|
<property name="version" value="unreleased"/>
|
||||||
|
|
||||||
<import file="${env.PONEY_HOME}/poney.xml"/>
|
<import file="${env.PONEY_HOME}/poney.xml"/>
|
||||||
|
|
||||||
<property name="boost.root" value="${env.BOOST_ROOT}"/>
|
|
||||||
<property name="boost.dir" value="${out.dir}/../boost"/>
|
|
||||||
<property name="boostbook.dir" value="${out.dir}/boostbook"/>
|
|
||||||
<property name="boost-mock.dir" value="${boost.dir}/libs/mock"/>
|
|
||||||
|
|
||||||
<target name="clean" description="clean intermediate build artifacts">
|
|
||||||
<delete dir="${out.dir}"/>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="configure" description="update external libraries">
|
|
||||||
<update name="boost"/>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<presetdef name="build-turtle-test">
|
|
||||||
<build-test input="test" depends="boost" mode="all" excludes="bench_*,fail_*">
|
|
||||||
<compilerarg value="-Wno-uninitialized" location="mid" if="is-cygwin"/>
|
|
||||||
<compilerarg value="-Wno-strict-aliasing" location="mid" if="is-gcc"/>
|
|
||||||
<compilerarg value="/wd4505" if="is-msvc"/>
|
|
||||||
</build-test>
|
|
||||||
</presetdef>
|
|
||||||
|
|
||||||
<target name="test" description="run unit tests">
|
|
||||||
<delete dir="${tests.dir}/test/bin"/>
|
|
||||||
<build-turtle-test name="turtle"/>
|
|
||||||
<build-turtle-test name="turtle_max_args">
|
|
||||||
<defineset>
|
|
||||||
<define name="MOCK_MAX_ARGS" value="21"/>
|
|
||||||
</defineset>
|
|
||||||
</build-turtle-test>
|
|
||||||
<build-turtle-test name="turtle_use_conversions">
|
|
||||||
<defineset define="MOCK_USE_CONVERSIONS"/>
|
|
||||||
</build-turtle-test>
|
|
||||||
<build-turtle-test name="turtle_no_decltype">
|
|
||||||
<defineset define="MOCK_NO_DECLTYPE"/>
|
|
||||||
</build-turtle-test>
|
|
||||||
<build-turtle-test name="turtle_no_variadic_macros">
|
|
||||||
<defineset define="MOCK_NO_VARIADIC_MACROS"/>
|
|
||||||
</build-turtle-test>
|
|
||||||
<build-turtle-test name="turtle_thread_safe">
|
|
||||||
<defineset define="MOCK_THREAD_SAFE"/>
|
|
||||||
</build-turtle-test>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="analyse" description="run errors analyser">
|
|
||||||
<quiet>
|
|
||||||
<mkdir dir="${reports.dir}"/>
|
|
||||||
<delete file="${reports.dir}/errors-${platform}.log"/>
|
|
||||||
<touch file="${reports.dir}/errors-${platform}.log"/>
|
|
||||||
</quiet>
|
|
||||||
<for param="file">
|
|
||||||
<fileset dir="${tests.dir}/test" includes="fail*.cpp"/>
|
|
||||||
<sequential>
|
|
||||||
<record name="${reports.dir}/errors-${platform}.log" action="start" append="true"/>
|
|
||||||
<ant target="-analyse">
|
|
||||||
<property name="file" value="@{file}"/>
|
|
||||||
</ant>
|
|
||||||
<record name="${reports.dir}/errors-${platform}.log" action="stop"/>
|
|
||||||
</sequential>
|
|
||||||
</for>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="-analyse">
|
|
||||||
<trycatch>
|
|
||||||
<try>
|
|
||||||
<echo>${file}</echo>
|
|
||||||
<compile name="errors" input="${tests.dir}/errors_test" outdir="${out.dir}/errors_test" excludes="**">
|
|
||||||
<includepath path="${libraries.dir}"/>
|
|
||||||
<fileset file="${file}"/>
|
|
||||||
</compile>
|
|
||||||
</try>
|
|
||||||
</trycatch>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="bench" description="run compilation benchmark">
|
|
||||||
<mkdir dir="${reports.dir}"/>
|
|
||||||
<quiet>
|
|
||||||
<delete file="${reports.dir}/benchmark-${platform}.log"/>
|
|
||||||
<touch file="${reports.dir}/benchmark-${platform}.log"/>
|
|
||||||
<delete dir="${out.dir}/bench_test"/>
|
|
||||||
<delete dir="${tests.dir}/test/bin"/>
|
|
||||||
</quiet>
|
|
||||||
<for param="file">
|
|
||||||
<fileset dir="${tests.dir}/test" includes="bench_*.cpp"/>
|
|
||||||
<sequential>
|
|
||||||
<record name="${reports.dir}/benchmark-${platform}.log" action="start" append="true"/>
|
|
||||||
<ant target="-bench">
|
|
||||||
<property name="file" value="@{file}"/>
|
|
||||||
</ant>
|
|
||||||
<record name="${reports.dir}/benchmark-${platform}.log" action="stop"/>
|
|
||||||
</sequential>
|
|
||||||
</for>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="-bench">
|
|
||||||
<echo>${file}</echo>
|
|
||||||
<stopwatch name="bench"/>
|
|
||||||
<quiet>
|
|
||||||
<compile name="bench" input="${tests.dir}/test" outdir="${out.dir}/bench_test" excludes="**">
|
|
||||||
<includepath path="${libraries.dir}"/>
|
|
||||||
<fileset file="${file}"/>
|
|
||||||
</compile>
|
|
||||||
</quiet>
|
|
||||||
<stopwatch name="bench" action="total"/>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="reports" description="generate code analysis reports">
|
<target name="reports" description="generate code analysis reports">
|
||||||
<headers name="turtle" excludes="**/*_iterate.hpp,**/*_template.hpp"/>
|
<headers name="turtle" excludes="**/*_iterate.hpp,**/*_template.hpp"/>
|
||||||
<check name="turtle"/>
|
<check name="turtle"/>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<target name="export" description="export distribution">
|
<target name="build" description="build tests and documentation">
|
||||||
<sync todir="${dist.dir}/include">
|
<run dir="." script="build"/>
|
||||||
<fileset dir="${libraries.dir}" includes="turtle/**"/>
|
|
||||||
</sync>
|
|
||||||
<info version="svn rev ${svn.revision}" todir="${dist.dir}"/>
|
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<target name="package" depends="export" description="package distribution">
|
<target name="release" depends="build" description="produce release packages">
|
||||||
<mkdir dir="${dist.dir}"/>
|
<fail unless="version" message="missing version property"/>
|
||||||
<zip destfile="${dist.dir}/${ant.project.name}.zip">
|
<copy file="version.hpp" tofile="${out.dir}/version.hpp">
|
||||||
|
<filterset>
|
||||||
|
<filter token="MOCK_VERSION" value="${version}"/>
|
||||||
|
</filterset>
|
||||||
|
</copy>
|
||||||
|
<zip destfile="${dist.dir}/${ant.project.name}-${version}.zip">
|
||||||
<fileset dir="${dist.dir}" includes="include/**"/>
|
<fileset dir="${dist.dir}" includes="include/**"/>
|
||||||
|
<zipfileset dir="${doc.dir}/html" prefix="doc"/>
|
||||||
|
<zipfileset dir="${out.dir}" includes="version.hpp" prefix="include/turtle"/>
|
||||||
</zip>
|
</zip>
|
||||||
<tar destfile="${dist.dir}/${ant.project.name}.tar.bz2" compression="bzip2">
|
<tar destfile="${dist.dir}/${ant.project.name}-${version}.tar.bz2" compression="bzip2">
|
||||||
<fileset dir="${dist.dir}" includes="include/**"/>
|
<fileset dir="${dist.dir}" includes="include/**"/>
|
||||||
|
<zipfileset dir="${doc.dir}/html" prefix="doc"/>
|
||||||
|
<zipfileset dir="${out.dir}" includes="version.hpp" prefix="include/turtle"/>
|
||||||
</tar>
|
</tar>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<condition property="b2.toolset" value="--toolset=${boost.toolset}" else="">
|
<target name="all" depends="build,reports,release" description="build documentation, run tests and package distribution"/>
|
||||||
<isset property="boost.toolset"/>
|
|
||||||
</condition>
|
|
||||||
<condition property="b2" value="b2.exe" else="b2">
|
|
||||||
<os family="windows"/>
|
|
||||||
</condition>
|
|
||||||
<presetdef name="b2">
|
|
||||||
<exec taskname="b2" failonerror="true" executable="${boost.root}/${b2}">
|
|
||||||
<arg value="-q"/>
|
|
||||||
<arg value="${b2.toolset}"/>
|
|
||||||
</exec>
|
|
||||||
</presetdef>
|
|
||||||
|
|
||||||
<target name="boost.generate" description="generate boost.mock into ${boost.dir}">
|
<target name="boost.convert" description="convert Boost.Mock">
|
||||||
<delete dir="${boost-mock.dir}"/>
|
<delete dir="${boost-mock.dir}"/>
|
||||||
<copy todir="${boost-mock.dir}/include/turtle">
|
<copy todir="${boost-mock.dir}">
|
||||||
<fileset dir="${libraries.dir}/turtle"/>
|
<fileset dir="${root.dir}"/>
|
||||||
</copy>
|
</copy>
|
||||||
<copy todir="${boostbook.dir}">
|
|
||||||
<fileset dir="${boost.root}/tools/boostbook" includes="xsl/**,dtd/**"/>
|
|
||||||
</copy>
|
|
||||||
<copy todir="${boostbook.dir}" overwrite="true">
|
|
||||||
<fileset dir="boostbook"/>
|
|
||||||
</copy>
|
|
||||||
<copy todir="${boost-mock.dir}/doc/html">
|
|
||||||
<fileset dir="${boost.root}/doc/src" includes="**/boostbook.css,**/**.png"/>
|
|
||||||
<fileset dir="boost/doc" includes="images/*.png"/>
|
|
||||||
</copy>
|
|
||||||
<copy todir="${boost-mock.dir}" overwrite="true">
|
|
||||||
<fileset dir="${tests.dir}" includes="test/**"/>
|
|
||||||
<fileset dir="boost" includes="test/**,doc/**,index.html"/>
|
|
||||||
</copy>
|
|
||||||
<copy todir="${boost.dir}">
|
|
||||||
<fileset dir="boost" includes="LICENSE_1_0.txt,Jamroot.jam,Jamfile.v2"/>
|
|
||||||
</copy>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="boost.convert" description="convert boost.mock in ${boost.dir}">
|
|
||||||
<move file="${boost-mock.dir}/include/turtle" tofile="${boost-mock.dir}/include/boost/mock"/>
|
<move file="${boost-mock.dir}/include/turtle" tofile="${boost-mock.dir}/include/boost/mock"/>
|
||||||
<replaceregexp match="MOCK" replace="BOOST_MOCK" flags="g">
|
<replaceregexp match="MOCK" replace="BOOST_MOCK" flags="g">
|
||||||
<fileset dir="${boost-mock.dir}" includes="**/*.cpp,**/*.hpp,**/*.qbk"/>
|
<fileset dir="${boost-mock.dir}" includes="**/*.cpp,**/*.hpp,**/*.qbk"/>
|
||||||
|
|
@ -214,55 +101,23 @@
|
||||||
<replaceregexp match="\[include changelog.qbk\]" replace="" flags="g">
|
<replaceregexp match="\[include changelog.qbk\]" replace="" flags="g">
|
||||||
<fileset dir="${boost-mock.dir}" includes="**/mock.qbk"/>
|
<fileset dir="${boost-mock.dir}" includes="**/mock.qbk"/>
|
||||||
</replaceregexp>
|
</replaceregexp>
|
||||||
<copy todir="${boostbook.dir}" overwrite="true">
|
|
||||||
<fileset dir="${boost.root}/tools/boostbook" includes="xsl/**,dtd/**"/>
|
|
||||||
</copy>
|
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<target name="boost.test" description="run boost.mock tests in ${boost.dir}">
|
<target name="boost.build" depends="boost.convert" description="build Boost.Mock tests and documentation">
|
||||||
<b2 dir="${boost-mock.dir}/test"/>
|
<run dir="${boost-mock.dir}/build" script="build"/>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<target name="boost.doc" description="generate boost.mock documentation in ${boost.dir}">
|
<target name="boost.package" depends="boost.build" description="package Boost.Mock">
|
||||||
<b2 dir="${boost-mock.dir}/doc">
|
|
||||||
<env key="BOOSTBOOK_DIR" value="${boostbook.dir}"/>
|
|
||||||
</b2>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="boost.package" description="package boost.mock">
|
|
||||||
<zip destfile="${out.dir}/boost-mock.zip">
|
<zip destfile="${out.dir}/boost-mock.zip">
|
||||||
<fileset dir="${boost.dir}" includes="libs/mock/**" excludes="**/bin/**"/>
|
<fileset dir="${boost-mock.dir}" includes="libs/mock/**" excludes="**/bin/**"/>
|
||||||
<fileset dir="${boost.dir}" includes="LICENSE_1_0.txt"/>
|
<fileset dir="${boost-mock.dir}" includes="LICENSE_1_0.txt"/>
|
||||||
</zip>
|
</zip>
|
||||||
<tar destfile="${out.dir}/boost-mock.tar.bz2" compression="bzip2">
|
<tar destfile="${out.dir}/boost-mock.tar.bz2" compression="bzip2">
|
||||||
<fileset dir="${boost.dir}" includes="libs/mock/**" excludes="**/bin/**"/>
|
<fileset dir="${boost-mock.dir}" includes="libs/mock/**" excludes="**/bin/**"/>
|
||||||
<fileset dir="${boost.dir}" includes="LICENSE_1_0.txt"/>
|
<fileset dir="${boost-mock.dir}" includes="LICENSE_1_0.txt"/>
|
||||||
</tar>
|
</tar>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<target name="documentation" depends="boost.generate,boost.doc" description="generate documentation"/>
|
<target name="boost" depends="boost.convert,boost.build,boost.package" description="convert to boost with documentation and tests"/>
|
||||||
|
|
||||||
<target name="boost" depends="boost.generate,boost.convert,boost.doc,boost.test,boost.package" description="convert to boost with documentation and tests"/>
|
|
||||||
|
|
||||||
<target name="release" depends="documentation,package" description="produce release packages">
|
|
||||||
<fail unless="version" message="missing version property"/>
|
|
||||||
<copy file="version.hpp" tofile="${out.dir}/version.hpp">
|
|
||||||
<filterset>
|
|
||||||
<filter token="MOCK_VERSION" value="${version}"/>
|
|
||||||
</filterset>
|
|
||||||
</copy>
|
|
||||||
<zip destfile="${dist.dir}/${ant.project.name}-${version}.zip">
|
|
||||||
<fileset dir="${dist.dir}" includes="include/**"/>
|
|
||||||
<zipfileset dir="${boost-mock.dir}/doc/html" prefix="doc"/>
|
|
||||||
<zipfileset dir="${out.dir}" includes="version.hpp" prefix="include/turtle"/>
|
|
||||||
</zip>
|
|
||||||
<tar destfile="${dist.dir}/${ant.project.name}-${version}.tar.bz2" compression="bzip2">
|
|
||||||
<fileset dir="${dist.dir}" includes="include/**"/>
|
|
||||||
<zipfileset dir="${boost-mock.dir}/doc/html" prefix="doc"/>
|
|
||||||
<zipfileset dir="${out.dir}" includes="version.hpp" prefix="include/turtle"/>
|
|
||||||
</tar>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="all" depends="configure,test,bench,reports,export,package" description="configure, build and run tests and benchmark, export and package distribution"/>
|
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
||||||
3
build/vc100/.gitignore
vendored
Normal file
3
build/vc100/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
/*.opensdf
|
||||||
|
/*.sdf
|
||||||
|
/*.suo
|
||||||
|
|
@ -19,45 +19,45 @@
|
||||||
</ProjectConfiguration>
|
</ProjectConfiguration>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\..\turtle\config.hpp" />
|
<ClInclude Include="..\..\include\turtle\config.hpp" />
|
||||||
<ClInclude Include="..\..\turtle\constraint.hpp" />
|
<ClInclude Include="..\..\include\turtle\constraint.hpp" />
|
||||||
<ClInclude Include="..\..\turtle\constraints.hpp" />
|
<ClInclude Include="..\..\include\turtle\constraints.hpp" />
|
||||||
<ClInclude Include="..\..\turtle\detail\action.hpp" />
|
<ClInclude Include="..\..\include\turtle\detail\action.hpp" />
|
||||||
<ClInclude Include="..\..\turtle\detail\addressof.hpp" />
|
<ClInclude Include="..\..\include\turtle\detail\addressof.hpp" />
|
||||||
<ClInclude Include="..\..\turtle\detail\child.hpp" />
|
<ClInclude Include="..\..\include\turtle\detail\child.hpp" />
|
||||||
<ClInclude Include="..\..\turtle\detail\cleanup.hpp" />
|
<ClInclude Include="..\..\include\turtle\detail\cleanup.hpp" />
|
||||||
<ClInclude Include="..\..\turtle\detail\context.hpp" />
|
<ClInclude Include="..\..\include\turtle\detail\context.hpp" />
|
||||||
<ClInclude Include="..\..\turtle\detail\expectation_template.hpp" />
|
<ClInclude Include="..\..\include\turtle\detail\expectation_template.hpp" />
|
||||||
<ClInclude Include="..\..\turtle\detail\formatter.hpp" />
|
<ClInclude Include="..\..\include\turtle\detail\formatter.hpp" />
|
||||||
<ClInclude Include="..\..\turtle\detail\function.hpp" />
|
<ClInclude Include="..\..\include\turtle\detail\function.hpp" />
|
||||||
<ClInclude Include="..\..\turtle\detail\function_impl_template.hpp" />
|
<ClInclude Include="..\..\include\turtle\detail\function_impl_template.hpp" />
|
||||||
<ClInclude Include="..\..\turtle\detail\function_iterate.hpp" />
|
<ClInclude Include="..\..\include\turtle\detail\function_iterate.hpp" />
|
||||||
<ClInclude Include="..\..\turtle\detail\function_template.hpp" />
|
<ClInclude Include="..\..\include\turtle\detail\function_template.hpp" />
|
||||||
<ClInclude Include="..\..\turtle\detail\functor.hpp" />
|
<ClInclude Include="..\..\include\turtle\detail\functor.hpp" />
|
||||||
<ClInclude Include="..\..\turtle\detail\group.hpp" />
|
<ClInclude Include="..\..\include\turtle\detail\group.hpp" />
|
||||||
<ClInclude Include="..\..\turtle\detail\invocation.hpp" />
|
<ClInclude Include="..\..\include\turtle\detail\invocation.hpp" />
|
||||||
<ClInclude Include="..\..\turtle\detail\is_functor.hpp" />
|
<ClInclude Include="..\..\include\turtle\detail\is_functor.hpp" />
|
||||||
<ClInclude Include="..\..\turtle\detail\matcher_base_template.hpp" />
|
<ClInclude Include="..\..\include\turtle\detail\matcher_base_template.hpp" />
|
||||||
<ClInclude Include="..\..\turtle\detail\mutex.hpp" />
|
<ClInclude Include="..\..\include\turtle\detail\mutex.hpp" />
|
||||||
<ClInclude Include="..\..\turtle\detail\object_impl.hpp" />
|
<ClInclude Include="..\..\include\turtle\detail\object_impl.hpp" />
|
||||||
<ClInclude Include="..\..\turtle\detail\parameter.hpp" />
|
<ClInclude Include="..\..\include\turtle\detail\parameter.hpp" />
|
||||||
<ClInclude Include="..\..\turtle\detail\parent.hpp" />
|
<ClInclude Include="..\..\include\turtle\detail\parent.hpp" />
|
||||||
<ClInclude Include="..\..\turtle\detail\root.hpp" />
|
<ClInclude Include="..\..\include\turtle\detail\root.hpp" />
|
||||||
<ClInclude Include="..\..\turtle\detail\sequence_impl.hpp" />
|
<ClInclude Include="..\..\include\turtle\detail\sequence_impl.hpp" />
|
||||||
<ClInclude Include="..\..\turtle\detail\signature.hpp" />
|
<ClInclude Include="..\..\include\turtle\detail\signature.hpp" />
|
||||||
<ClInclude Include="..\..\turtle\detail\type_name.hpp" />
|
<ClInclude Include="..\..\include\turtle\detail\type_name.hpp" />
|
||||||
<ClInclude Include="..\..\turtle\detail\verifiable.hpp" />
|
<ClInclude Include="..\..\include\turtle\detail\verifiable.hpp" />
|
||||||
<ClInclude Include="..\..\turtle\error.hpp" />
|
<ClInclude Include="..\..\include\turtle\error.hpp" />
|
||||||
<ClInclude Include="..\..\turtle\exception.hpp" />
|
<ClInclude Include="..\..\include\turtle\exception.hpp" />
|
||||||
<ClInclude Include="..\..\turtle\format.hpp" />
|
<ClInclude Include="..\..\include\turtle\format.hpp" />
|
||||||
<ClInclude Include="..\..\turtle\log.hpp" />
|
<ClInclude Include="..\..\include\turtle\log.hpp" />
|
||||||
<ClInclude Include="..\..\turtle\matcher.hpp" />
|
<ClInclude Include="..\..\include\turtle\matcher.hpp" />
|
||||||
<ClInclude Include="..\..\turtle\mock.hpp" />
|
<ClInclude Include="..\..\include\turtle\mock.hpp" />
|
||||||
<ClInclude Include="..\..\turtle\object.hpp" />
|
<ClInclude Include="..\..\include\turtle\object.hpp" />
|
||||||
<ClInclude Include="..\..\turtle\reset.hpp" />
|
<ClInclude Include="..\..\include\turtle\reset.hpp" />
|
||||||
<ClInclude Include="..\..\turtle\sequence.hpp" />
|
<ClInclude Include="..\..\include\turtle\sequence.hpp" />
|
||||||
<ClInclude Include="..\..\turtle\stream.hpp" />
|
<ClInclude Include="..\..\include\turtle\stream.hpp" />
|
||||||
<ClInclude Include="..\..\turtle\verify.hpp" />
|
<ClInclude Include="..\..\include\turtle\verify.hpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<PropertyGroup Label="Globals">
|
<PropertyGroup Label="Globals">
|
||||||
<ProjectGuid>{831F2DEE-1E35-4533-A3B2-12C01BA8DA1D}</ProjectGuid>
|
<ProjectGuid>{831F2DEE-1E35-4533-A3B2-12C01BA8DA1D}</ProjectGuid>
|
||||||
|
|
|
||||||
|
|
@ -10,121 +10,121 @@
|
||||||
</Filter>
|
</Filter>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\..\turtle\config.hpp">
|
<ClInclude Include="..\..\include\turtle\config.hpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\turtle\constraint.hpp">
|
<ClInclude Include="..\..\include\turtle\constraint.hpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\turtle\constraints.hpp">
|
<ClInclude Include="..\..\include\turtle\constraints.hpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\turtle\error.hpp">
|
<ClInclude Include="..\..\include\turtle\error.hpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\turtle\log.hpp">
|
<ClInclude Include="..\..\include\turtle\exception.hpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\turtle\mock.hpp">
|
<ClInclude Include="..\..\include\turtle\format.hpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\turtle\object.hpp">
|
<ClInclude Include="..\..\include\turtle\log.hpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\turtle\sequence.hpp">
|
<ClInclude Include="..\..\include\turtle\matcher.hpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\turtle\detail\signature.hpp">
|
<ClInclude Include="..\..\include\turtle\mock.hpp">
|
||||||
<Filter>Source Files\detail</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\turtle\detail\child.hpp">
|
|
||||||
<Filter>Source Files\detail</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\turtle\detail\group.hpp">
|
|
||||||
<Filter>Source Files\detail</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\turtle\detail\context.hpp">
|
|
||||||
<Filter>Source Files\detail</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\turtle\detail\parent.hpp">
|
|
||||||
<Filter>Source Files\detail</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\turtle\detail\root.hpp">
|
|
||||||
<Filter>Source Files\detail</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\turtle\detail\type_name.hpp">
|
|
||||||
<Filter>Source Files\detail</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\turtle\detail\verifiable.hpp">
|
|
||||||
<Filter>Source Files\detail</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\turtle\detail\action.hpp">
|
|
||||||
<Filter>Source Files\detail</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\turtle\detail\expectation_template.hpp">
|
|
||||||
<Filter>Source Files\detail</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\turtle\detail\function.hpp">
|
|
||||||
<Filter>Source Files\detail</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\turtle\detail\function_iterate.hpp">
|
|
||||||
<Filter>Source Files\detail</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\turtle\detail\function_template.hpp">
|
|
||||||
<Filter>Source Files\detail</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\turtle\detail\invocation.hpp">
|
|
||||||
<Filter>Source Files\detail</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\turtle\detail\object_impl.hpp">
|
|
||||||
<Filter>Source Files\detail</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\turtle\detail\function_impl_template.hpp">
|
|
||||||
<Filter>Source Files\detail</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\turtle\detail\is_functor.hpp">
|
|
||||||
<Filter>Source Files\detail</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\turtle\stream.hpp">
|
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\turtle\format.hpp">
|
<ClInclude Include="..\..\include\turtle\object.hpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\turtle\verify.hpp">
|
<ClInclude Include="..\..\include\turtle\reset.hpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\turtle\reset.hpp">
|
<ClInclude Include="..\..\include\turtle\sequence.hpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\turtle\detail\functor.hpp">
|
<ClInclude Include="..\..\include\turtle\stream.hpp">
|
||||||
<Filter>Source Files\detail</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\turtle\detail\parameter.hpp">
|
|
||||||
<Filter>Source Files\detail</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\turtle\detail\sequence_impl.hpp">
|
|
||||||
<Filter>Source Files\detail</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\turtle\detail\formatter.hpp">
|
|
||||||
<Filter>Source Files\detail</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\turtle\detail\cleanup.hpp">
|
|
||||||
<Filter>Source Files\detail</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\turtle\matcher.hpp">
|
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\turtle\exception.hpp">
|
<ClInclude Include="..\..\include\turtle\verify.hpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\turtle\detail\addressof.hpp">
|
<ClInclude Include="..\..\include\turtle\detail\function.hpp">
|
||||||
<Filter>Source Files\detail</Filter>
|
<Filter>Source Files\detail</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\turtle\detail\mutex.hpp">
|
<ClInclude Include="..\..\include\turtle\detail\function_impl_template.hpp">
|
||||||
<Filter>Source Files\detail</Filter>
|
<Filter>Source Files\detail</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\turtle\detail\matcher_base_template.hpp">
|
<ClInclude Include="..\..\include\turtle\detail\function_iterate.hpp">
|
||||||
|
<Filter>Source Files\detail</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\include\turtle\detail\function_template.hpp">
|
||||||
|
<Filter>Source Files\detail</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\include\turtle\detail\functor.hpp">
|
||||||
|
<Filter>Source Files\detail</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\include\turtle\detail\group.hpp">
|
||||||
|
<Filter>Source Files\detail</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\include\turtle\detail\invocation.hpp">
|
||||||
|
<Filter>Source Files\detail</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\include\turtle\detail\is_functor.hpp">
|
||||||
|
<Filter>Source Files\detail</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\include\turtle\detail\matcher_base_template.hpp">
|
||||||
|
<Filter>Source Files\detail</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\include\turtle\detail\mutex.hpp">
|
||||||
|
<Filter>Source Files\detail</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\include\turtle\detail\object_impl.hpp">
|
||||||
|
<Filter>Source Files\detail</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\include\turtle\detail\parameter.hpp">
|
||||||
|
<Filter>Source Files\detail</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\include\turtle\detail\parent.hpp">
|
||||||
|
<Filter>Source Files\detail</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\include\turtle\detail\root.hpp">
|
||||||
|
<Filter>Source Files\detail</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\include\turtle\detail\sequence_impl.hpp">
|
||||||
|
<Filter>Source Files\detail</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\include\turtle\detail\signature.hpp">
|
||||||
|
<Filter>Source Files\detail</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\include\turtle\detail\type_name.hpp">
|
||||||
|
<Filter>Source Files\detail</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\include\turtle\detail\verifiable.hpp">
|
||||||
|
<Filter>Source Files\detail</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\include\turtle\detail\action.hpp">
|
||||||
|
<Filter>Source Files\detail</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\include\turtle\detail\addressof.hpp">
|
||||||
|
<Filter>Source Files\detail</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\include\turtle\detail\child.hpp">
|
||||||
|
<Filter>Source Files\detail</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\include\turtle\detail\cleanup.hpp">
|
||||||
|
<Filter>Source Files\detail</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\include\turtle\detail\context.hpp">
|
||||||
|
<Filter>Source Files\detail</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\include\turtle\detail\expectation_template.hpp">
|
||||||
|
<Filter>Source Files\detail</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\include\turtle\detail\formatter.hpp">
|
||||||
<Filter>Source Files\detail</Filter>
|
<Filter>Source Files\detail</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
[section Changelog]
|
[section Changelog]
|
||||||
|
|
||||||
[section trunk]
|
[section unreleased]
|
||||||
Not yet released
|
Not yet released
|
||||||
|
|
||||||
* Dropped support for obsolete Boost.Phoenix V2
|
* Dropped support for obsolete Boost.Phoenix V2
|
||||||
|
|
@ -1,48 +1,48 @@
|
||||||
// http://turtle.sourceforge.net
|
// http://turtle.sourceforge.net
|
||||||
//
|
//
|
||||||
// Copyright Mathieu Champlon 2014
|
// Copyright Mathieu Champlon 2014
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#define BOOST_AUTO_TEST_MAIN
|
#define BOOST_AUTO_TEST_MAIN
|
||||||
#include <boost/test/auto_unit_test.hpp>
|
#include <boost/test/auto_unit_test.hpp>
|
||||||
#include <turtle/mock.hpp>
|
#include <turtle/mock.hpp>
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
//[ limitations_comma_in_macro_problem
|
//[ limitations_comma_in_macro_problem
|
||||||
template< typename T1, typename T2 >
|
template< typename T1, typename T2 >
|
||||||
struct my_base_class
|
struct my_base_class
|
||||||
{};
|
{};
|
||||||
//]
|
//]
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace limitations_comma_in_macro_solution_1
|
namespace limitations_comma_in_macro_solution_1
|
||||||
{
|
{
|
||||||
//[ limitations_comma_in_macro_solution_1
|
//[ limitations_comma_in_macro_solution_1
|
||||||
typedef my_base_class< int, int > my_base_type;
|
typedef my_base_class< int, int > my_base_type;
|
||||||
|
|
||||||
MOCK_BASE_CLASS( my_mock, my_base_type )
|
MOCK_BASE_CLASS( my_mock, my_base_type )
|
||||||
{};
|
{};
|
||||||
//]
|
//]
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace limitations_comma_in_macro_solution_2
|
namespace limitations_comma_in_macro_solution_2
|
||||||
{
|
{
|
||||||
//[ limitations_comma_in_macro_solution_2
|
//[ limitations_comma_in_macro_solution_2
|
||||||
template< typename T1, typename T2 >
|
template< typename T1, typename T2 >
|
||||||
MOCK_BASE_CLASS( my_mock, my_base_class< T1 BOOST_PP_COMMA() T2 > )
|
MOCK_BASE_CLASS( my_mock, my_base_class< T1 BOOST_PP_COMMA() T2 > )
|
||||||
{};
|
{};
|
||||||
//]
|
//]
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace limitations_comma_in_macro_solution_3
|
namespace limitations_comma_in_macro_solution_3
|
||||||
{
|
{
|
||||||
//[ limitations_comma_in_macro_solution_3
|
//[ limitations_comma_in_macro_solution_3
|
||||||
template< typename T1, typename T2 >
|
template< typename T1, typename T2 >
|
||||||
struct my_mock : my_base_class< T1, T2 >, mock::object
|
struct my_mock : my_base_class< T1, T2 >, mock::object
|
||||||
{};
|
{};
|
||||||
//]
|
//]
|
||||||
}
|
}
|
||||||
|
|
@ -1,50 +1,50 @@
|
||||||
// http://turtle.sourceforge.net
|
// http://turtle.sourceforge.net
|
||||||
//
|
//
|
||||||
// Copyright Mathieu Champlon 2014
|
// Copyright Mathieu Champlon 2014
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#define BOOST_AUTO_TEST_MAIN
|
#define BOOST_AUTO_TEST_MAIN
|
||||||
#include <boost/test/auto_unit_test.hpp>
|
#include <boost/test/auto_unit_test.hpp>
|
||||||
#include <turtle/mock.hpp>
|
#include <turtle/mock.hpp>
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
//[ limitations_const_parameter_warning_problem
|
//[ limitations_const_parameter_warning_problem
|
||||||
class base
|
class base
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual void method( const int ) = 0;
|
virtual void method( const int ) = 0;
|
||||||
};
|
};
|
||||||
//]
|
//]
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace limitations_const_parameter_warning_explanation
|
namespace limitations_const_parameter_warning_explanation
|
||||||
{
|
{
|
||||||
//[ limitations_const_parameter_warning_explanation
|
//[ limitations_const_parameter_warning_explanation
|
||||||
class derived : public base
|
class derived : public base
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual void method( const int );
|
virtual void method( const int );
|
||||||
};
|
};
|
||||||
|
|
||||||
void derived::method( int )
|
void derived::method( int )
|
||||||
{}
|
{}
|
||||||
//]
|
//]
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace limitations_const_parameter_warning_solution
|
namespace limitations_const_parameter_warning_solution
|
||||||
{
|
{
|
||||||
//[ limitations_const_parameter_warning_solution
|
//[ limitations_const_parameter_warning_solution
|
||||||
MOCK_BASE_CLASS( mock_base, base )
|
MOCK_BASE_CLASS( mock_base, base )
|
||||||
{
|
{
|
||||||
void method( const int i )
|
void method( const int i )
|
||||||
{
|
{
|
||||||
method_stub( i );
|
method_stub( i );
|
||||||
}
|
}
|
||||||
MOCK_METHOD( method_stub, 1, void( int ), method )
|
MOCK_METHOD( method_stub, 1, void( int ), method )
|
||||||
};
|
};
|
||||||
//]
|
//]
|
||||||
}
|
}
|
||||||
|
|
@ -1,43 +1,43 @@
|
||||||
// http://turtle.sourceforge.net
|
// http://turtle.sourceforge.net
|
||||||
//
|
//
|
||||||
// Copyright Mathieu Champlon 2014
|
// Copyright Mathieu Champlon 2014
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#define BOOST_AUTO_TEST_MAIN
|
#define BOOST_AUTO_TEST_MAIN
|
||||||
#include <boost/test/auto_unit_test.hpp>
|
#include <boost/test/auto_unit_test.hpp>
|
||||||
#include <turtle/mock.hpp>
|
#include <turtle/mock.hpp>
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
//[ limitations_literal_zero_problem
|
//[ limitations_literal_zero_problem
|
||||||
class base
|
class base
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual void method( int* i ) = 0;
|
virtual void method( int* i ) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
MOCK_BASE_CLASS( mock_base, base )
|
MOCK_BASE_CLASS( mock_base, base )
|
||||||
{
|
{
|
||||||
MOCK_METHOD( method, 1 )
|
MOCK_METHOD( method, 1 )
|
||||||
};
|
};
|
||||||
//]
|
//]
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE( literal_zero )
|
BOOST_AUTO_TEST_CASE( literal_zero )
|
||||||
{
|
{
|
||||||
mock_base m;
|
mock_base m;
|
||||||
//[ limitations_literal_zero_solution_1
|
//[ limitations_literal_zero_solution_1
|
||||||
MOCK_EXPECT( m.method ).with( mock::equal< int* >( 0 ) ); // this compiles
|
MOCK_EXPECT( m.method ).with( mock::equal< int* >( 0 ) ); // this compiles
|
||||||
//]
|
//]
|
||||||
//[ limitations_literal_zero_solution_2
|
//[ limitations_literal_zero_solution_2
|
||||||
MOCK_EXPECT( m.method ).with( mock::negate );
|
MOCK_EXPECT( m.method ).with( mock::negate );
|
||||||
//]
|
//]
|
||||||
#ifdef MOCK_NULLPTR
|
#ifdef MOCK_NULLPTR
|
||||||
//[ limitations_literal_zero_solution_3
|
//[ limitations_literal_zero_solution_3
|
||||||
MOCK_EXPECT( m.method ).with( nullptr );
|
MOCK_EXPECT( m.method ).with( nullptr );
|
||||||
//]
|
//]
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
@ -1,27 +1,27 @@
|
||||||
// http://turtle.sourceforge.net
|
// http://turtle.sourceforge.net
|
||||||
//
|
//
|
||||||
// Copyright Mathieu Champlon 2014
|
// Copyright Mathieu Champlon 2014
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#define BOOST_AUTO_TEST_MAIN
|
#define BOOST_AUTO_TEST_MAIN
|
||||||
#include <boost/test/auto_unit_test.hpp>
|
#include <boost/test/auto_unit_test.hpp>
|
||||||
#include <turtle/mock.hpp>
|
#include <turtle/mock.hpp>
|
||||||
|
|
||||||
//[ limitations_non_virtual_method_problem
|
//[ limitations_non_virtual_method_problem
|
||||||
class base
|
class base
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void method() // the method is not virtual
|
void method() // the method is not virtual
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
//]
|
//]
|
||||||
|
|
||||||
//[ limitations_non_virtual_method_problem_2
|
//[ limitations_non_virtual_method_problem_2
|
||||||
MOCK_BASE_CLASS( mock_base, base )
|
MOCK_BASE_CLASS( mock_base, base )
|
||||||
{
|
{
|
||||||
MOCK_METHOD( method, 0 )
|
MOCK_METHOD( method, 0 )
|
||||||
};
|
};
|
||||||
//]
|
//]
|
||||||
|
|
@ -1,29 +1,29 @@
|
||||||
// http://turtle.sourceforge.net
|
// http://turtle.sourceforge.net
|
||||||
//
|
//
|
||||||
// Copyright Mathieu Champlon 2014
|
// Copyright Mathieu Champlon 2014
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#define BOOST_AUTO_TEST_MAIN
|
#define BOOST_AUTO_TEST_MAIN
|
||||||
#include <boost/test/auto_unit_test.hpp>
|
#include <boost/test/auto_unit_test.hpp>
|
||||||
#include <turtle/mock.hpp>
|
#include <turtle/mock.hpp>
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
//[ limitations_private_method_problem
|
//[ limitations_private_method_problem
|
||||||
class base
|
class base
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
virtual void method() = 0;
|
virtual void method() = 0;
|
||||||
};
|
};
|
||||||
//]
|
//]
|
||||||
|
|
||||||
//[ limitations_private_method_solution
|
//[ limitations_private_method_solution
|
||||||
MOCK_BASE_CLASS( mock_base, base )
|
MOCK_BASE_CLASS( mock_base, base )
|
||||||
{
|
{
|
||||||
MOCK_METHOD( method, 0, void() )
|
MOCK_METHOD( method, 0, void() )
|
||||||
};
|
};
|
||||||
//]
|
//]
|
||||||
}
|
}
|
||||||
|
|
@ -1,83 +1,83 @@
|
||||||
// http://turtle.sourceforge.net
|
// http://turtle.sourceforge.net
|
||||||
//
|
//
|
||||||
// Copyright Mathieu Champlon 2014
|
// Copyright Mathieu Champlon 2014
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#define BOOST_AUTO_TEST_MAIN
|
#define BOOST_AUTO_TEST_MAIN
|
||||||
#include <boost/test/auto_unit_test.hpp>
|
#include <boost/test/auto_unit_test.hpp>
|
||||||
#include <turtle/mock.hpp>
|
#include <turtle/mock.hpp>
|
||||||
|
|
||||||
namespace limitations_template_method_problem
|
namespace limitations_template_method_problem
|
||||||
{
|
{
|
||||||
//[ limitations_template_method_problem
|
//[ limitations_template_method_problem
|
||||||
class concept
|
class concept
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
template< typename T >
|
template< typename T >
|
||||||
void method( T t )
|
void method( T t )
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
template< typename T >
|
template< typename T >
|
||||||
void function_under_test( T t ) // T is supposed to model the previous concept
|
void function_under_test( T t ) // T is supposed to model the previous concept
|
||||||
{
|
{
|
||||||
t.method( 42 );
|
t.method( 42 );
|
||||||
t.method( "string" );
|
t.method( "string" );
|
||||||
}
|
}
|
||||||
//]
|
//]
|
||||||
|
|
||||||
//[ limitations_template_method_solution
|
//[ limitations_template_method_solution
|
||||||
MOCK_CLASS( mock_concept )
|
MOCK_CLASS( mock_concept )
|
||||||
{
|
{
|
||||||
MOCK_METHOD( method, 1, void( int ), method_int )
|
MOCK_METHOD( method, 1, void( int ), method_int )
|
||||||
MOCK_METHOD( method, 1, void( const char* ), method_string )
|
MOCK_METHOD( method, 1, void( const char* ), method_string )
|
||||||
};
|
};
|
||||||
//]
|
//]
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace limitations_template_method_problem_2
|
namespace limitations_template_method_problem_2
|
||||||
{
|
{
|
||||||
//[ limitations_template_method_problem_2
|
//[ limitations_template_method_problem_2
|
||||||
class concept
|
class concept
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
template< typename T >
|
template< typename T >
|
||||||
T create()
|
T create()
|
||||||
{
|
{
|
||||||
return T();
|
return T();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template< typename T >
|
template< typename T >
|
||||||
void function_under_test( T t ) // T is supposed to model the previous concept
|
void function_under_test( T t ) // T is supposed to model the previous concept
|
||||||
{
|
{
|
||||||
t.create< int >();
|
t.template create< int >();
|
||||||
t.create< std::string >();
|
t.template create< std::string >();
|
||||||
}
|
}
|
||||||
//]
|
//]
|
||||||
|
|
||||||
//[ limitations_template_method_solution_2
|
//[ limitations_template_method_solution_2
|
||||||
MOCK_CLASS( mock_concept )
|
MOCK_CLASS( mock_concept )
|
||||||
{
|
{
|
||||||
template< typename T >
|
template< typename T >
|
||||||
T create();
|
T create();
|
||||||
|
|
||||||
template<>
|
MOCK_METHOD( create_int, 0, int(), create_int )
|
||||||
int create< int >()
|
MOCK_METHOD( create_string, 0, std::string(), create_string )
|
||||||
{
|
};
|
||||||
return create_int();
|
|
||||||
}
|
template<>
|
||||||
template<>
|
int mock_concept::create< int >()
|
||||||
std::string create< std::string >()
|
{
|
||||||
{
|
return create_int();
|
||||||
return create_string();
|
}
|
||||||
}
|
template<>
|
||||||
|
std::string mock_concept::create< std::string >()
|
||||||
MOCK_METHOD( create_int, 0, int(), create_int )
|
{
|
||||||
MOCK_METHOD( create_string, 0, std::string(), create_string )
|
return create_string();
|
||||||
};
|
}
|
||||||
//]
|
//]
|
||||||
}
|
}
|
||||||
|
|
@ -1,35 +1,35 @@
|
||||||
// http://turtle.sourceforge.net
|
// http://turtle.sourceforge.net
|
||||||
//
|
//
|
||||||
// Copyright Mathieu Champlon 2014
|
// Copyright Mathieu Champlon 2014
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#define BOOST_AUTO_TEST_MAIN
|
#define BOOST_AUTO_TEST_MAIN
|
||||||
#include <boost/test/auto_unit_test.hpp>
|
#include <boost/test/auto_unit_test.hpp>
|
||||||
#include <turtle/mock.hpp>
|
#include <turtle/mock.hpp>
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
//[ limitations_throw_specifier_problem
|
//[ limitations_throw_specifier_problem
|
||||||
struct base_class
|
struct base_class
|
||||||
{
|
{
|
||||||
virtual ~base_class()
|
virtual ~base_class()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
virtual void method() throw ();
|
virtual void method() throw ();
|
||||||
};
|
};
|
||||||
//]
|
//]
|
||||||
|
|
||||||
//[ limitations_throw_specifier_solution
|
//[ limitations_throw_specifier_solution
|
||||||
MOCK_BASE_CLASS( mock_class, base_class )
|
MOCK_BASE_CLASS( mock_class, base_class )
|
||||||
{
|
{
|
||||||
void method() throw ()
|
void method() throw ()
|
||||||
{
|
{
|
||||||
method_proxy();
|
method_proxy();
|
||||||
}
|
}
|
||||||
MOCK_METHOD( method_proxy, 0, void(), method )
|
MOCK_METHOD( method_proxy, 0, void(), method )
|
||||||
};
|
};
|
||||||
//]
|
//]
|
||||||
}
|
}
|
||||||
|
|
@ -1,76 +1,76 @@
|
||||||
// http://turtle.sourceforge.net
|
// http://turtle.sourceforge.net
|
||||||
//
|
//
|
||||||
// Copyright Mathieu Champlon 2014
|
// Copyright Mathieu Champlon 2014
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#define BOOST_AUTO_TEST_MAIN
|
#define BOOST_AUTO_TEST_MAIN
|
||||||
#include <boost/test/auto_unit_test.hpp>
|
#include <boost/test/auto_unit_test.hpp>
|
||||||
#include <boost/mock/mock.hpp>
|
#include <turtle/mock.hpp>
|
||||||
#include "calculator.hpp"
|
#include "calculator.hpp"
|
||||||
#include "mock_view.hpp"
|
#include "mock_view.hpp"
|
||||||
|
|
||||||
namespace simple
|
namespace simple
|
||||||
{
|
{
|
||||||
//[ simple_calculator
|
//[ simple_calculator
|
||||||
class calculator
|
class calculator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
int add( int a, int b );
|
int add( int a, int b );
|
||||||
};
|
};
|
||||||
//]
|
//]
|
||||||
|
|
||||||
//[ simple_zero_plus_zero_is_zero
|
//[ simple_zero_plus_zero_is_zero
|
||||||
BOOST_AUTO_TEST_CASE( zero_plus_zero_is_zero )
|
BOOST_AUTO_TEST_CASE( zero_plus_zero_is_zero )
|
||||||
{
|
{
|
||||||
calculator c;
|
calculator c;
|
||||||
BOOST_CHECK_EQUAL( 0, c.add( 0, 0 ) );
|
BOOST_CHECK_EQUAL( 0, c.add( 0, 0 ) );
|
||||||
}
|
}
|
||||||
//]
|
//]
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace without_mock_object
|
namespace without_mock_object
|
||||||
{
|
{
|
||||||
//[ my_view
|
//[ my_view
|
||||||
class my_view : public view
|
class my_view : public view
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
my_view()
|
my_view()
|
||||||
: called( false )
|
: called( false )
|
||||||
{}
|
{}
|
||||||
virtual void display( int result )
|
virtual void display( int result )
|
||||||
{
|
{
|
||||||
called = true;
|
called = true;
|
||||||
value = result;
|
value = result;
|
||||||
}
|
}
|
||||||
bool called;
|
bool called;
|
||||||
int value;
|
int value;
|
||||||
};
|
};
|
||||||
//]
|
//]
|
||||||
|
|
||||||
//[ zero_plus_zero_is_zero_without_mock_object
|
//[ zero_plus_zero_is_zero_without_mock_object
|
||||||
BOOST_AUTO_TEST_CASE( zero_plus_zero_is_zero )
|
BOOST_AUTO_TEST_CASE( zero_plus_zero_is_zero )
|
||||||
{
|
{
|
||||||
my_view v;
|
my_view v;
|
||||||
calculator c( v );
|
calculator c( v );
|
||||||
c.add( 0, 0 );
|
c.add( 0, 0 );
|
||||||
BOOST_REQUIRE( v.called );
|
BOOST_REQUIRE( v.called );
|
||||||
BOOST_CHECK_EQUAL( 0, v.value );
|
BOOST_CHECK_EQUAL( 0, v.value );
|
||||||
}
|
}
|
||||||
//]
|
//]
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace with_mock_object
|
namespace with_mock_object
|
||||||
{
|
{
|
||||||
//[ zero_plus_zero_is_zero_with_mock_object
|
//[ zero_plus_zero_is_zero_with_mock_object
|
||||||
BOOST_AUTO_TEST_CASE( zero_plus_zero_is_zero )
|
BOOST_AUTO_TEST_CASE( zero_plus_zero_is_zero )
|
||||||
{
|
{
|
||||||
mock_view v;
|
mock_view v;
|
||||||
calculator c( 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
|
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 );
|
c.add( 0, 0 );
|
||||||
}
|
}
|
||||||
//]
|
//]
|
||||||
}
|
}
|
||||||
|
|
@ -1,61 +1,62 @@
|
||||||
// http://turtle.sourceforge.net
|
// http://turtle.sourceforge.net
|
||||||
//
|
//
|
||||||
// Copyright Mathieu Champlon 2014
|
// Copyright Mathieu Champlon 2014
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
//[ async_call_problem
|
//[ async_call_problem
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
class base_class
|
class base_class
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual void method() = 0;
|
virtual void method() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class my_class
|
class my_class
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit my_class( base_class& );
|
explicit my_class( base_class& );
|
||||||
|
|
||||||
void flush(); // repetitively calling this method will in turn call base_class::method at some point
|
void flush(); // repetitively calling this method will in turn call base_class::method at some point
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
//]
|
//]
|
||||||
|
|
||||||
//[ async_call_solution
|
//[ async_call_solution
|
||||||
#define BOOST_AUTO_TEST_MAIN
|
#define BOOST_AUTO_TEST_MAIN
|
||||||
#include <boost/test/auto_unit_test.hpp>
|
#include <boost/test/auto_unit_test.hpp>
|
||||||
#include <boost/lambda/lambda.hpp>
|
#include <boost/lambda/lambda.hpp>
|
||||||
#include <boost/thread.hpp>
|
#include <boost/thread.hpp>
|
||||||
#include <turtle/mock.hpp>
|
#include <turtle/mock.hpp>
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
template< typename F >
|
template< typename F >
|
||||||
void wait( bool& condition, F flush, int timeout = 100, int sleep = 100 )
|
void check( bool& condition, F flush, int attempts = 100, int sleep = 100 )
|
||||||
{
|
{
|
||||||
while( !condition && timeout > 0 )
|
while( !condition && attempts > 0 )
|
||||||
{
|
{
|
||||||
--timeout;
|
--attempts;
|
||||||
boost::this_thread::sleep( boost::posix_time::milliseconds( sleep ) );
|
boost::this_thread::sleep( boost::posix_time::milliseconds( sleep ) );
|
||||||
flush();
|
flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MOCK_BASE_CLASS( mock_base_class, base_class )
|
|
||||||
{
|
MOCK_BASE_CLASS( mock_base_class, base_class )
|
||||||
MOCK_METHOD( method, 0 )
|
{
|
||||||
};
|
MOCK_METHOD( method, 0 )
|
||||||
}
|
};
|
||||||
|
}
|
||||||
BOOST_AUTO_TEST_CASE( method_is_called )
|
|
||||||
{
|
BOOST_AUTO_TEST_CASE( method_is_called )
|
||||||
mock_base_class mock;
|
{
|
||||||
my_class c( mock );
|
mock_base_class m;
|
||||||
bool done = false;
|
my_class c( m );
|
||||||
MOCK_EXPECT( mock.method ).once().calls( boost::lambda::var( done ) = true ); // when method is called it will set done to true
|
bool done = false;
|
||||||
wait( done, boost::bind( &my_class::flush, &c ) ); // just wait on done, flushing from time to time
|
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
|
||||||
//]
|
}
|
||||||
|
//]
|
||||||
|
|
@ -1,44 +1,44 @@
|
||||||
// http://turtle.sourceforge.net
|
// http://turtle.sourceforge.net
|
||||||
//
|
//
|
||||||
// Copyright Mathieu Champlon 2014
|
// Copyright Mathieu Champlon 2014
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
//[ invoke_functor_problem
|
//[ invoke_functor_problem
|
||||||
#include <boost/function.hpp>
|
#include <boost/function.hpp>
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
class base_class
|
class base_class
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual void method( boost::function< void( int ) > functor ) = 0;
|
virtual void method( boost::function< void( int ) > functor ) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
void function( base_class& ); // the function will call 'method' with a functor to be applied
|
void function( base_class& ); // the function will call 'method' with a functor to be applied
|
||||||
}
|
}
|
||||||
//]
|
//]
|
||||||
|
|
||||||
//[ invoke_functor_solution
|
//[ invoke_functor_solution
|
||||||
#define BOOST_AUTO_TEST_MAIN
|
#define BOOST_AUTO_TEST_MAIN
|
||||||
#include <boost/test/auto_unit_test.hpp>
|
#include <boost/test/auto_unit_test.hpp>
|
||||||
#include <boost/bind/apply.hpp>
|
#include <boost/bind/apply.hpp>
|
||||||
#include <turtle/mock.hpp>
|
#include <turtle/mock.hpp>
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
MOCK_BASE_CLASS( mock_class, base_class )
|
MOCK_BASE_CLASS( mock_class, base_class )
|
||||||
{
|
{
|
||||||
MOCK_METHOD( method, 1 )
|
MOCK_METHOD( method, 1 )
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE( how_to_invoke_a_functor_passed_as_parameter_of_a_mock_method )
|
BOOST_AUTO_TEST_CASE( how_to_invoke_a_functor_passed_as_parameter_of_a_mock_method )
|
||||||
{
|
{
|
||||||
mock_class mock;
|
mock_class mock;
|
||||||
MOCK_EXPECT( mock.method ).calls( boost::bind( boost::apply< void >(), _1, 42 ) ); // whenever 'method' is called, invoke the functor with 42
|
MOCK_EXPECT( mock.method ).calls( boost::bind( boost::apply< void >(), _1, 42 ) ); // whenever 'method' is called, invoke the functor with 42
|
||||||
function( mock );
|
function( mock );
|
||||||
}
|
}
|
||||||
//]
|
//]
|
||||||
|
|
@ -1,54 +1,54 @@
|
||||||
// http://turtle.sourceforge.net
|
// http://turtle.sourceforge.net
|
||||||
//
|
//
|
||||||
// Copyright Mathieu Champlon 2014
|
// Copyright Mathieu Champlon 2014
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
//[ quick_constraint_problem
|
//[ quick_constraint_problem
|
||||||
#define BOOST_AUTO_TEST_MAIN
|
#define BOOST_AUTO_TEST_MAIN
|
||||||
#include <boost/test/auto_unit_test.hpp>
|
#include <boost/test/auto_unit_test.hpp>
|
||||||
#include <turtle/mock.hpp>
|
#include <turtle/mock.hpp>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
class my_class
|
class my_class
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit my_class( int data )
|
explicit my_class( int data )
|
||||||
: data_( data )
|
: data_( data )
|
||||||
{}
|
{}
|
||||||
int data_;
|
int data_;
|
||||||
};
|
};
|
||||||
std::ostream& operator<<( std::ostream& os, const my_class& c ) // my_class is serializable to an std::ostream
|
std::ostream& operator<<( std::ostream& os, const my_class& c ) // my_class is serializable to an std::ostream
|
||||||
{
|
{
|
||||||
return os << "my_class( " << c.data_ << " )";
|
return os << "my_class( " << c.data_ << " )";
|
||||||
}
|
}
|
||||||
|
|
||||||
MOCK_CLASS( my_mock )
|
MOCK_CLASS( my_mock )
|
||||||
{
|
{
|
||||||
MOCK_METHOD( method, 1, void( const my_class& ) ) // how to simply write a custom constraint ?
|
MOCK_METHOD( method, 1, void( const my_class& ) ) // how to simply write a custom constraint ?
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
//]
|
//]
|
||||||
|
|
||||||
//[ quick_constraint_solution
|
//[ quick_constraint_solution
|
||||||
#include <boost/lexical_cast.hpp>
|
#include <boost/lexical_cast.hpp>
|
||||||
|
|
||||||
namespace mock // it could also be in the namespace of 'my_class'
|
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
|
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;
|
return boost::lexical_cast< std::string >( actual ) == expected;
|
||||||
}
|
}
|
||||||
} // mock
|
} // mock
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE( method_is_called )
|
BOOST_AUTO_TEST_CASE( method_is_called )
|
||||||
{
|
{
|
||||||
my_mock mock;
|
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_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 ) );
|
mock.method( my_class( 42 ) );
|
||||||
}
|
}
|
||||||
//]
|
//]
|
||||||
|
|
@ -1,50 +1,50 @@
|
||||||
// http://turtle.sourceforge.net
|
// http://turtle.sourceforge.net
|
||||||
//
|
//
|
||||||
// Copyright Mathieu Champlon 2014
|
// Copyright Mathieu Champlon 2014
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
//[ retrieve_cref_problem
|
//[ retrieve_cref_problem
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
class base_class
|
class base_class
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual void method( int value ) = 0;
|
virtual void method( int value ) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class my_class
|
class my_class
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit my_class( base_class& );
|
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
|
void process(); // the processing will call 'method' two times with the same value, but we don't know what value beforehand
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
//]
|
//]
|
||||||
|
|
||||||
//[ retrieve_cref_solution
|
//[ retrieve_cref_solution
|
||||||
#define BOOST_AUTO_TEST_MAIN
|
#define BOOST_AUTO_TEST_MAIN
|
||||||
#include <boost/test/auto_unit_test.hpp>
|
#include <boost/test/auto_unit_test.hpp>
|
||||||
#include <turtle/mock.hpp>
|
#include <turtle/mock.hpp>
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
MOCK_BASE_CLASS( mock_base_class, base_class )
|
MOCK_BASE_CLASS( mock_base_class, base_class )
|
||||||
{
|
{
|
||||||
MOCK_METHOD( method, 1 )
|
MOCK_METHOD( method, 1 )
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE( method_is_called_two_times_with_the_same_value )
|
BOOST_AUTO_TEST_CASE( method_is_called_two_times_with_the_same_value )
|
||||||
{
|
{
|
||||||
mock_base_class mock;
|
mock_base_class mock;
|
||||||
my_class c( mock );
|
my_class c( mock );
|
||||||
int value;
|
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( 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
|
MOCK_EXPECT( mock.method ).once().with( boost::cref( value ) ); // on second call compare the previously retrieved value with the newly received one
|
||||||
c.process();
|
c.process();
|
||||||
}
|
}
|
||||||
//]
|
//]
|
||||||
File diff suppressed because it is too large
Load diff
4
doc/html/.gitignore
vendored
Normal file
4
doc/html/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
*.css
|
||||||
|
*.html
|
||||||
|
*.png
|
||||||
|
standalone_HTML.manifest
|
||||||
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
|
|
@ -1,85 +1,85 @@
|
||||||
// http://turtle.sourceforge.net
|
// http://turtle.sourceforge.net
|
||||||
//
|
//
|
||||||
// Copyright Mathieu Champlon 2009
|
// Copyright Mathieu Champlon 2009
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// boost-no-inspect
|
// boost-no-inspect
|
||||||
|
|
||||||
#ifndef MOCK_CONFIG_HPP_INCLUDED
|
#ifndef MOCK_CONFIG_HPP_INCLUDED
|
||||||
#define MOCK_CONFIG_HPP_INCLUDED
|
#define MOCK_CONFIG_HPP_INCLUDED
|
||||||
|
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
#include <boost/preprocessor/arithmetic/inc.hpp>
|
#include <boost/preprocessor/arithmetic/inc.hpp>
|
||||||
#include <boost/preprocessor/comparison/less.hpp>
|
#include <boost/preprocessor/comparison/less.hpp>
|
||||||
|
|
||||||
#ifndef MOCK_ERROR_POLICY
|
#ifndef MOCK_ERROR_POLICY
|
||||||
# define MOCK_ERROR_POLICY mock::error
|
# define MOCK_ERROR_POLICY mock::error
|
||||||
# define MOCK_USE_BOOST_TEST
|
# define MOCK_USE_BOOST_TEST
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef MOCK_MAX_ARGS
|
#ifndef MOCK_MAX_ARGS
|
||||||
# define MOCK_MAX_ARGS 9
|
# define MOCK_MAX_ARGS 9
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef MOCK_MAX_SEQUENCES
|
#ifndef MOCK_MAX_SEQUENCES
|
||||||
# define MOCK_MAX_SEQUENCES 10
|
# define MOCK_MAX_SEQUENCES 10
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef BOOST_FUNCTION_MAX_ARGS
|
#ifndef BOOST_FUNCTION_MAX_ARGS
|
||||||
# define BOOST_FUNCTION_MAX_ARGS MOCK_MAX_ARGS
|
# define BOOST_FUNCTION_MAX_ARGS MOCK_MAX_ARGS
|
||||||
#elif BOOST_PP_LESS(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
|
# error BOOST_FUNCTION_MAX_ARGS must be set to MOCK_MAX_ARGS or higher
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef BOOST_FT_MAX_ARITY
|
#ifndef BOOST_FT_MAX_ARITY
|
||||||
# define BOOST_FT_MAX_ARITY BOOST_PP_INC(MOCK_MAX_ARGS)
|
# define BOOST_FT_MAX_ARITY BOOST_PP_INC(MOCK_MAX_ARGS)
|
||||||
#elif BOOST_PP_LESS_EQUAL(BOOST_FT_MAX_ARITY, 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
|
# error BOOST_FT_MAX_ARITY must be set to MOCK_MAX_ARGS + 1 or higher
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(BOOST_NO_CXX11_NULLPTR) && !defined(BOOST_NO_NULLPTR)
|
#if !defined(BOOST_NO_CXX11_NULLPTR) && !defined(BOOST_NO_NULLPTR)
|
||||||
# ifndef MOCK_NO_NULLPTR
|
# ifndef MOCK_NO_NULLPTR
|
||||||
# define MOCK_NULLPTR
|
# define MOCK_NULLPTR
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(BOOST_NO_CXX11_DECLTYPE) && !defined(BOOST_NO_DECLTYPE)
|
#if !defined(BOOST_NO_CXX11_DECLTYPE) && !defined(BOOST_NO_DECLTYPE)
|
||||||
# ifndef MOCK_NO_DECLTYPE
|
# ifndef MOCK_NO_DECLTYPE
|
||||||
# define MOCK_DECLTYPE
|
# define MOCK_DECLTYPE
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(BOOST_NO_CXX11_VARIADIC_MACROS) && !defined(BOOST_NO_VARIADIC_MACROS)
|
#if !defined(BOOST_NO_CXX11_VARIADIC_MACROS) && !defined(BOOST_NO_VARIADIC_MACROS)
|
||||||
# ifndef MOCK_NO_VARIADIC_MACROS
|
# ifndef MOCK_NO_VARIADIC_MACROS
|
||||||
# define MOCK_VARIADIC_MACROS
|
# define MOCK_VARIADIC_MACROS
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(BOOST_NO_CXX11_SMART_PTR) && !defined(BOOST_NO_SMART_PTR)
|
#if !defined(BOOST_NO_CXX11_SMART_PTR) && !defined(BOOST_NO_SMART_PTR)
|
||||||
# ifndef MOCK_NO_SMART_PTR
|
# ifndef MOCK_NO_SMART_PTR
|
||||||
# define MOCK_SMART_PTR
|
# define MOCK_SMART_PTR
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_NO_RVALUE_REFERENCES)
|
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_NO_RVALUE_REFERENCES)
|
||||||
# ifndef MOCK_NO_RVALUE_REFERENCES
|
# ifndef MOCK_NO_RVALUE_REFERENCES
|
||||||
# define MOCK_RVALUE_REFERENCES
|
# define MOCK_RVALUE_REFERENCES
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(BOOST_NO_CXX11_HDR_MUTEX) && !defined(BOOST_NO_0X_HDR_MUTEX)
|
#if !defined(BOOST_NO_CXX11_HDR_MUTEX) && !defined(BOOST_NO_0X_HDR_MUTEX)
|
||||||
# ifndef MOCK_NO_HDR_MUTEX
|
# ifndef MOCK_NO_HDR_MUTEX
|
||||||
# define MOCK_HDR_MUTEX
|
# define MOCK_HDR_MUTEX
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(BOOST_NO_CXX11_LAMBDAS) && !defined(BOOST_NO_LAMBDAS)
|
#if !defined(BOOST_NO_CXX11_LAMBDAS) && !defined(BOOST_NO_LAMBDAS)
|
||||||
# ifndef MOCK_NO_LAMBDAS
|
# ifndef MOCK_NO_LAMBDAS
|
||||||
# define MOCK_LAMBDAS
|
# define MOCK_LAMBDAS
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // MOCK_CONFIG_HPP_INCLUDED
|
#endif // MOCK_CONFIG_HPP_INCLUDED
|
||||||
|
|
@ -1,247 +1,247 @@
|
||||||
// http://turtle.sourceforge.net
|
// http://turtle.sourceforge.net
|
||||||
//
|
//
|
||||||
// Copyright Mathieu Champlon 2008
|
// Copyright Mathieu Champlon 2008
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#ifndef MOCK_CONSTRAINT_HPP_INCLUDED
|
#ifndef MOCK_CONSTRAINT_HPP_INCLUDED
|
||||||
#define MOCK_CONSTRAINT_HPP_INCLUDED
|
#define MOCK_CONSTRAINT_HPP_INCLUDED
|
||||||
|
|
||||||
#include "config.hpp"
|
#include "config.hpp"
|
||||||
#include "log.hpp"
|
#include "log.hpp"
|
||||||
#include <boost/ref.hpp>
|
#include <boost/ref.hpp>
|
||||||
#include <boost/preprocessor/stringize.hpp>
|
#include <boost/preprocessor/stringize.hpp>
|
||||||
#include <boost/preprocessor/control/if.hpp>
|
#include <boost/preprocessor/control/if.hpp>
|
||||||
#include <boost/preprocessor/variadic/to_array.hpp>
|
#include <boost/preprocessor/variadic/to_array.hpp>
|
||||||
#include <boost/preprocessor/repetition/enum_binary_params.hpp>
|
#include <boost/preprocessor/repetition/enum_binary_params.hpp>
|
||||||
#include <boost/preprocessor/repetition/enum_params.hpp>
|
#include <boost/preprocessor/repetition/enum_params.hpp>
|
||||||
#include <boost/preprocessor/repetition/enum.hpp>
|
#include <boost/preprocessor/repetition/enum.hpp>
|
||||||
#include <boost/preprocessor/array.hpp>
|
#include <boost/preprocessor/array.hpp>
|
||||||
|
|
||||||
namespace mock
|
namespace mock
|
||||||
{
|
{
|
||||||
template< typename Constraint >
|
template< typename Constraint >
|
||||||
struct constraint
|
struct constraint
|
||||||
{
|
{
|
||||||
constraint()
|
constraint()
|
||||||
{}
|
{}
|
||||||
constraint( const Constraint& c )
|
constraint( const Constraint& c )
|
||||||
: c_( c )
|
: c_( c )
|
||||||
{}
|
{}
|
||||||
Constraint c_;
|
Constraint c_;
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
template< typename Lhs, typename Rhs >
|
template< typename Lhs, typename Rhs >
|
||||||
class and_
|
class and_
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
and_( const Lhs& lhs, const Rhs& rhs )
|
and_( const Lhs& lhs, const Rhs& rhs )
|
||||||
: lhs_( lhs )
|
: lhs_( lhs )
|
||||||
, rhs_( rhs )
|
, rhs_( rhs )
|
||||||
{}
|
{}
|
||||||
template< typename Actual >
|
template< typename Actual >
|
||||||
bool operator()( const Actual& actual ) const
|
bool operator()( const Actual& actual ) const
|
||||||
{
|
{
|
||||||
return lhs_( actual ) && rhs_( actual );
|
return lhs_( actual ) && rhs_( actual );
|
||||||
}
|
}
|
||||||
friend std::ostream& operator<<( std::ostream& s, const and_& a )
|
friend std::ostream& operator<<( std::ostream& s, const and_& a )
|
||||||
{
|
{
|
||||||
return s << "( " << mock::format( a.lhs_ )
|
return s << "( " << mock::format( a.lhs_ )
|
||||||
<< " && " << mock::format( a.rhs_ ) << " )";
|
<< " && " << mock::format( a.rhs_ ) << " )";
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
Lhs lhs_;
|
Lhs lhs_;
|
||||||
Rhs rhs_;
|
Rhs rhs_;
|
||||||
};
|
};
|
||||||
|
|
||||||
template< typename Lhs, typename Rhs >
|
template< typename Lhs, typename Rhs >
|
||||||
class or_
|
class or_
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
or_( const Lhs& lhs, const Rhs& rhs )
|
or_( const Lhs& lhs, const Rhs& rhs )
|
||||||
: lhs_( lhs )
|
: lhs_( lhs )
|
||||||
, rhs_( rhs )
|
, rhs_( rhs )
|
||||||
{}
|
{}
|
||||||
template< typename Actual >
|
template< typename Actual >
|
||||||
bool operator()( const Actual& actual ) const
|
bool operator()( const Actual& actual ) const
|
||||||
{
|
{
|
||||||
return lhs_( actual ) || rhs_( actual );
|
return lhs_( actual ) || rhs_( actual );
|
||||||
}
|
}
|
||||||
friend std::ostream& operator<<( std::ostream& s, const or_& o )
|
friend std::ostream& operator<<( std::ostream& s, const or_& o )
|
||||||
{
|
{
|
||||||
return s << "( " << mock::format( o.lhs_ )
|
return s << "( " << mock::format( o.lhs_ )
|
||||||
<< " || " << mock::format( o.rhs_ )<< " )";
|
<< " || " << mock::format( o.rhs_ )<< " )";
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
Lhs lhs_;
|
Lhs lhs_;
|
||||||
Rhs rhs_;
|
Rhs rhs_;
|
||||||
};
|
};
|
||||||
|
|
||||||
template< typename Constraint >
|
template< typename Constraint >
|
||||||
class not_
|
class not_
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit not_( const Constraint& c )
|
explicit not_( const Constraint& c )
|
||||||
: c_( c )
|
: c_( c )
|
||||||
{}
|
{}
|
||||||
template< typename Actual >
|
template< typename Actual >
|
||||||
bool operator()( const Actual& actual ) const
|
bool operator()( const Actual& actual ) const
|
||||||
{
|
{
|
||||||
return ! c_( actual );
|
return ! c_( actual );
|
||||||
}
|
}
|
||||||
friend std::ostream& operator<<( std::ostream& s, const not_& n )
|
friend std::ostream& operator<<( std::ostream& s, const not_& n )
|
||||||
{
|
{
|
||||||
return s << "! " << mock::format( n.c_ );
|
return s << "! " << mock::format( n.c_ );
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
Constraint c_;
|
Constraint c_;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
template< typename Lhs, typename Rhs >
|
template< typename Lhs, typename Rhs >
|
||||||
const constraint< detail::or_< Lhs, Rhs > >
|
const constraint< detail::or_< Lhs, Rhs > >
|
||||||
operator||( const constraint< Lhs >& lhs,
|
operator||( const constraint< Lhs >& lhs,
|
||||||
const constraint< Rhs >& rhs )
|
const constraint< Rhs >& rhs )
|
||||||
{
|
{
|
||||||
return detail::or_< Lhs, Rhs >( lhs.c_, rhs.c_ );
|
return detail::or_< Lhs, Rhs >( lhs.c_, rhs.c_ );
|
||||||
}
|
}
|
||||||
|
|
||||||
template< typename Lhs, typename Rhs >
|
template< typename Lhs, typename Rhs >
|
||||||
const constraint< detail::and_< Lhs, Rhs > >
|
const constraint< detail::and_< Lhs, Rhs > >
|
||||||
operator&&( const constraint< Lhs >& lhs,
|
operator&&( const constraint< Lhs >& lhs,
|
||||||
const constraint< Rhs >& rhs )
|
const constraint< Rhs >& rhs )
|
||||||
{
|
{
|
||||||
return detail::and_< Lhs, Rhs >( lhs.c_, rhs.c_ );
|
return detail::and_< Lhs, Rhs >( lhs.c_, rhs.c_ );
|
||||||
}
|
}
|
||||||
|
|
||||||
template< typename Constraint >
|
template< typename Constraint >
|
||||||
const constraint< detail::not_< Constraint > >
|
const constraint< detail::not_< Constraint > >
|
||||||
operator!( const constraint< Constraint >& c )
|
operator!( const constraint< Constraint >& c )
|
||||||
{
|
{
|
||||||
return detail::not_< Constraint >( c.c_ );
|
return detail::not_< Constraint >( c.c_ );
|
||||||
}
|
}
|
||||||
} // mock
|
} // mock
|
||||||
|
|
||||||
#define MOCK_UNARY_CONSTRAINT(Name, n, Args, Expr) \
|
#define MOCK_UNARY_CONSTRAINT(Name, n, Args, Expr) \
|
||||||
namespace detail \
|
namespace detail \
|
||||||
{ \
|
{ \
|
||||||
struct Name \
|
struct Name \
|
||||||
{ \
|
{ \
|
||||||
template< typename Actual > \
|
template< typename Actual > \
|
||||||
bool operator()( const Actual& actual ) const \
|
bool operator()( const Actual& actual ) const \
|
||||||
{ \
|
{ \
|
||||||
return Expr; \
|
return Expr; \
|
||||||
} \
|
} \
|
||||||
friend std::ostream& operator<<( std::ostream& s, const Name& ) \
|
friend std::ostream& operator<<( std::ostream& s, const Name& ) \
|
||||||
{ \
|
{ \
|
||||||
return s << BOOST_STRINGIZE(Name); \
|
return s << BOOST_STRINGIZE(Name); \
|
||||||
} \
|
} \
|
||||||
}; \
|
}; \
|
||||||
} \
|
} \
|
||||||
const mock::constraint< detail::Name > Name;
|
const mock::constraint< detail::Name > Name;
|
||||||
|
|
||||||
#define MOCK_CONSTRAINT_ASSIGN(z, n, d) \
|
#define MOCK_CONSTRAINT_ASSIGN(z, n, d) \
|
||||||
expected##n( e##n )
|
expected##n( e##n )
|
||||||
|
|
||||||
#define MOCK_CONSTRAINT_UNWRAP_REF(z, n, d) \
|
#define MOCK_CONSTRAINT_UNWRAP_REF(z, n, d) \
|
||||||
boost::unwrap_ref( expected##n )
|
boost::unwrap_ref( expected##n )
|
||||||
|
|
||||||
#define MOCK_CONSTRAINT_FORMAT(z, n, d) \
|
#define MOCK_CONSTRAINT_FORMAT(z, n, d) \
|
||||||
BOOST_PP_IF(n, << ", " <<,) mock::format( c.expected##n )
|
BOOST_PP_IF(n, << ", " <<,) mock::format( c.expected##n )
|
||||||
|
|
||||||
#define MOCK_CONSTRAINT_MEMBER(z, n, d) \
|
#define MOCK_CONSTRAINT_MEMBER(z, n, d) \
|
||||||
Expected_##n expected##n;
|
Expected_##n expected##n;
|
||||||
|
|
||||||
#define MOCK_CONSTRAINT_CREF_PARAM(z, n, Args) \
|
#define MOCK_CONSTRAINT_CREF_PARAM(z, n, Args) \
|
||||||
typename \
|
typename \
|
||||||
boost::unwrap_reference< Expected_##n >::type \
|
boost::unwrap_reference< Expected_##n >::type \
|
||||||
BOOST_PP_ARRAY_ELEM(n, Args)
|
BOOST_PP_ARRAY_ELEM(n, Args)
|
||||||
|
|
||||||
#define MOCK_CONSTRAINT_PARAM(z, n, Args) \
|
#define MOCK_CONSTRAINT_PARAM(z, n, Args) \
|
||||||
T##n BOOST_PP_ARRAY_ELEM(n, Args)
|
T##n BOOST_PP_ARRAY_ELEM(n, Args)
|
||||||
|
|
||||||
#define MOCK_NARY_CONSTRAINT(Name, n, Args, Expr) \
|
#define MOCK_NARY_CONSTRAINT(Name, n, Args, Expr) \
|
||||||
namespace detail \
|
namespace detail \
|
||||||
{ \
|
{ \
|
||||||
template< BOOST_PP_ENUM_PARAMS(n, typename Expected_) > \
|
template< BOOST_PP_ENUM_PARAMS(n, typename Expected_) > \
|
||||||
struct Name \
|
struct Name \
|
||||||
{ \
|
{ \
|
||||||
explicit Name( \
|
explicit Name( \
|
||||||
BOOST_PP_ENUM_BINARY_PARAMS(n, const Expected_, & e) ) \
|
BOOST_PP_ENUM_BINARY_PARAMS(n, const Expected_, & e) ) \
|
||||||
: BOOST_PP_ENUM(n, MOCK_CONSTRAINT_ASSIGN, _) \
|
: BOOST_PP_ENUM(n, MOCK_CONSTRAINT_ASSIGN, _) \
|
||||||
{} \
|
{} \
|
||||||
template< typename Actual > \
|
template< typename Actual > \
|
||||||
bool operator()( const Actual& actual ) const \
|
bool operator()( const Actual& actual ) const \
|
||||||
{ \
|
{ \
|
||||||
return test( actual, \
|
return test( actual, \
|
||||||
BOOST_PP_ENUM(n, MOCK_CONSTRAINT_UNWRAP_REF, _) ); \
|
BOOST_PP_ENUM(n, MOCK_CONSTRAINT_UNWRAP_REF, _) ); \
|
||||||
} \
|
} \
|
||||||
template< typename Actual > \
|
template< typename Actual > \
|
||||||
bool test( const Actual& actual, \
|
bool test( const Actual& actual, \
|
||||||
BOOST_PP_ENUM(n, \
|
BOOST_PP_ENUM(n, \
|
||||||
MOCK_CONSTRAINT_CREF_PARAM, (n, Args)) ) const \
|
MOCK_CONSTRAINT_CREF_PARAM, (n, Args)) ) const \
|
||||||
{ \
|
{ \
|
||||||
return Expr; \
|
return Expr; \
|
||||||
} \
|
} \
|
||||||
friend std::ostream& operator<<( std::ostream& s, const Name& c ) \
|
friend std::ostream& operator<<( std::ostream& s, const Name& c ) \
|
||||||
{ \
|
{ \
|
||||||
return s << BOOST_STRINGIZE(Name) << "( " \
|
return s << BOOST_STRINGIZE(Name) << "( " \
|
||||||
<< BOOST_PP_REPEAT(n, MOCK_CONSTRAINT_FORMAT, _) \
|
<< BOOST_PP_REPEAT(n, MOCK_CONSTRAINT_FORMAT, _) \
|
||||||
<< " )"; \
|
<< " )"; \
|
||||||
} \
|
} \
|
||||||
BOOST_PP_REPEAT(n, MOCK_CONSTRAINT_MEMBER, _) \
|
BOOST_PP_REPEAT(n, MOCK_CONSTRAINT_MEMBER, _) \
|
||||||
}; \
|
}; \
|
||||||
} \
|
} \
|
||||||
template< BOOST_PP_ENUM_PARAMS(n, typename T) > \
|
template< BOOST_PP_ENUM_PARAMS(n, typename T) > \
|
||||||
mock::constraint< \
|
mock::constraint< \
|
||||||
detail::Name< BOOST_PP_ENUM_PARAMS(n, T) > \
|
detail::Name< BOOST_PP_ENUM_PARAMS(n, T) > \
|
||||||
> Name( BOOST_PP_ENUM(n, MOCK_CONSTRAINT_PARAM, (n, Args)) ) \
|
> Name( BOOST_PP_ENUM(n, MOCK_CONSTRAINT_PARAM, (n, Args)) ) \
|
||||||
{ \
|
{ \
|
||||||
return detail::Name< BOOST_PP_ENUM_PARAMS(n, T) > Args; \
|
return detail::Name< BOOST_PP_ENUM_PARAMS(n, T) > Args; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define MOCK_CONSTRAINT_EXT(Name, n, Args, Expr) \
|
#define MOCK_CONSTRAINT_EXT(Name, n, Args, Expr) \
|
||||||
BOOST_PP_IF(n, \
|
BOOST_PP_IF(n, \
|
||||||
MOCK_NARY_CONSTRAINT, \
|
MOCK_NARY_CONSTRAINT, \
|
||||||
MOCK_UNARY_CONSTRAINT)(Name, n, Args, Expr)
|
MOCK_UNARY_CONSTRAINT)(Name, n, Args, Expr)
|
||||||
|
|
||||||
#ifdef MOCK_VARIADIC_MACROS
|
#ifdef MOCK_VARIADIC_MACROS
|
||||||
|
|
||||||
#if BOOST_MSVC
|
#if BOOST_MSVC
|
||||||
# define MOCK_VARIADIC_SIZE(...) \
|
# define MOCK_VARIADIC_SIZE(...) \
|
||||||
BOOST_PP_CAT(MOCK_VARIADIC_SIZE_I(__VA_ARGS__, \
|
BOOST_PP_CAT(MOCK_VARIADIC_SIZE_I(__VA_ARGS__, \
|
||||||
32, 31, 30, 29, 28, 27, 26, 25, 24, 23, \
|
32, 31, 30, 29, 28, 27, 26, 25, 24, 23, \
|
||||||
22, 21, 20, 19, 18, 17, 16, 15, 14, 13, \
|
22, 21, 20, 19, 18, 17, 16, 15, 14, 13, \
|
||||||
12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1,),)
|
12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1,),)
|
||||||
#else // BOOST_MSVC
|
#else // BOOST_MSVC
|
||||||
# define MOCK_VARIADIC_SIZE(...) \
|
# define MOCK_VARIADIC_SIZE(...) \
|
||||||
MOCK_VARIADIC_SIZE_I(__VA_ARGS__, \
|
MOCK_VARIADIC_SIZE_I(__VA_ARGS__, \
|
||||||
32, 31, 30, 29, 28, 27, 26, 25, 24, 23, \
|
32, 31, 30, 29, 28, 27, 26, 25, 24, 23, \
|
||||||
22, 21, 20, 19, 18, 17, 16, 15, 14, 13, \
|
22, 21, 20, 19, 18, 17, 16, 15, 14, 13, \
|
||||||
12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1,)
|
12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1,)
|
||||||
#endif // BOOST_MSVC
|
#endif // BOOST_MSVC
|
||||||
#define MOCK_VARIADIC_SIZE_I( \
|
#define MOCK_VARIADIC_SIZE_I( \
|
||||||
e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, \
|
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, \
|
e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, \
|
||||||
e25, e26, e27, e28, e29, e30, e31, size, ...) size
|
e25, e26, e27, e28, e29, e30, e31, size, ...) size
|
||||||
|
|
||||||
#define MOCK_CONSTRAINT_AUX_AUX(Name, n, Array) \
|
#define MOCK_CONSTRAINT_AUX_AUX(Name, n, Array) \
|
||||||
MOCK_CONSTRAINT_EXT( \
|
MOCK_CONSTRAINT_EXT( \
|
||||||
Name, n, \
|
Name, n, \
|
||||||
BOOST_PP_ARRAY_TO_TUPLE(BOOST_PP_ARRAY_POP_BACK(Array)), \
|
BOOST_PP_ARRAY_TO_TUPLE(BOOST_PP_ARRAY_POP_BACK(Array)), \
|
||||||
BOOST_PP_ARRAY_ELEM(n, Array))
|
BOOST_PP_ARRAY_ELEM(n, Array))
|
||||||
|
|
||||||
#define MOCK_CONSTRAINT_AUX(Name, Size, Tuple) \
|
#define MOCK_CONSTRAINT_AUX(Name, Size, Tuple) \
|
||||||
MOCK_CONSTRAINT_AUX_AUX(Name, BOOST_PP_DEC(Size), (Size,Tuple))
|
MOCK_CONSTRAINT_AUX_AUX(Name, BOOST_PP_DEC(Size), (Size,Tuple))
|
||||||
|
|
||||||
#define MOCK_CONSTRAINT(Name, ...) \
|
#define MOCK_CONSTRAINT(Name, ...) \
|
||||||
MOCK_CONSTRAINT_AUX( \
|
MOCK_CONSTRAINT_AUX( \
|
||||||
Name, MOCK_VARIADIC_SIZE(__VA_ARGS__), (__VA_ARGS__))
|
Name, MOCK_VARIADIC_SIZE(__VA_ARGS__), (__VA_ARGS__))
|
||||||
|
|
||||||
#endif // MOCK_VARIADIC_MACROS
|
#endif // MOCK_VARIADIC_MACROS
|
||||||
|
|
||||||
#endif // MOCK_CONSTRAINT_HPP_INCLUDED
|
#endif // MOCK_CONSTRAINT_HPP_INCLUDED
|
||||||
|
|
@ -1,201 +1,201 @@
|
||||||
// http://turtle.sourceforge.net
|
// http://turtle.sourceforge.net
|
||||||
//
|
//
|
||||||
// Copyright Mathieu Champlon 2008
|
// Copyright Mathieu Champlon 2008
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#ifndef MOCK_CONSTRAINTS_HPP_INCLUDED
|
#ifndef MOCK_CONSTRAINTS_HPP_INCLUDED
|
||||||
#define MOCK_CONSTRAINTS_HPP_INCLUDED
|
#define MOCK_CONSTRAINTS_HPP_INCLUDED
|
||||||
|
|
||||||
#include "config.hpp"
|
#include "config.hpp"
|
||||||
#include "constraint.hpp"
|
#include "constraint.hpp"
|
||||||
#include "detail/addressof.hpp"
|
#include "detail/addressof.hpp"
|
||||||
#include <boost/ref.hpp>
|
#include <boost/ref.hpp>
|
||||||
#include <boost/utility/enable_if.hpp>
|
#include <boost/utility/enable_if.hpp>
|
||||||
#include <boost/type_traits/is_convertible.hpp>
|
#include <boost/type_traits/is_convertible.hpp>
|
||||||
#include <boost/test/floating_point_comparison.hpp>
|
#include <boost/test/floating_point_comparison.hpp>
|
||||||
|
|
||||||
namespace mock
|
namespace mock
|
||||||
{
|
{
|
||||||
MOCK_UNARY_CONSTRAINT( any, 0,, true && &actual )
|
MOCK_UNARY_CONSTRAINT( any, 0,, true && &actual )
|
||||||
MOCK_UNARY_CONSTRAINT( affirm, 0,, !! actual )
|
MOCK_UNARY_CONSTRAINT( affirm, 0,, !! actual )
|
||||||
MOCK_UNARY_CONSTRAINT( negate, 0,, ! actual )
|
MOCK_UNARY_CONSTRAINT( negate, 0,, ! actual )
|
||||||
MOCK_UNARY_CONSTRAINT( evaluate, 0,, actual() )
|
MOCK_UNARY_CONSTRAINT( evaluate, 0,, actual() )
|
||||||
|
|
||||||
MOCK_NARY_CONSTRAINT( equal, 1, ( expected ), actual == expected )
|
MOCK_NARY_CONSTRAINT( equal, 1, ( expected ), actual == expected )
|
||||||
MOCK_NARY_CONSTRAINT( less, 1, ( expected ), actual < expected )
|
MOCK_NARY_CONSTRAINT( less, 1, ( expected ), actual < expected )
|
||||||
MOCK_NARY_CONSTRAINT( greater, 1, ( expected ), actual > expected )
|
MOCK_NARY_CONSTRAINT( greater, 1, ( expected ), actual > expected )
|
||||||
MOCK_NARY_CONSTRAINT( less_equal, 1, ( expected ), actual <= expected )
|
MOCK_NARY_CONSTRAINT( less_equal, 1, ( expected ), actual <= expected )
|
||||||
MOCK_NARY_CONSTRAINT( greater_equal, 1, ( expected ), actual >= expected )
|
MOCK_NARY_CONSTRAINT( greater_equal, 1, ( expected ), actual >= expected )
|
||||||
|
|
||||||
#ifdef BOOST_MSVC
|
#ifdef BOOST_MSVC
|
||||||
# pragma push_macro( "small" )
|
# pragma push_macro( "small" )
|
||||||
# undef small
|
# undef small
|
||||||
#endif
|
#endif
|
||||||
MOCK_NARY_CONSTRAINT( small, 1, ( expected ), \
|
MOCK_NARY_CONSTRAINT( small, 1, ( expected ), \
|
||||||
( boost::test_tools::check_is_small( actual, expected ) ) )
|
( boost::test_tools::check_is_small( actual, expected ) ) )
|
||||||
#ifdef BOOST_MSVC
|
#ifdef BOOST_MSVC
|
||||||
# pragma pop_macro( "small" )
|
# pragma pop_macro( "small" )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
MOCK_NARY_CONSTRAINT( close, 2, ( expected, tolerance ), \
|
MOCK_NARY_CONSTRAINT( close, 2, ( expected, tolerance ), \
|
||||||
( boost::test_tools::check_is_close( \
|
( boost::test_tools::check_is_close( \
|
||||||
actual, expected, \
|
actual, expected, \
|
||||||
boost::test_tools::percent_tolerance( tolerance ) ) ) )
|
boost::test_tools::percent_tolerance( tolerance ) ) ) )
|
||||||
MOCK_NARY_CONSTRAINT( close_fraction, 2, ( expected, tolerance ), \
|
MOCK_NARY_CONSTRAINT( close_fraction, 2, ( expected, tolerance ), \
|
||||||
( boost::test_tools::check_is_close( \
|
( boost::test_tools::check_is_close( \
|
||||||
actual, expected, \
|
actual, expected, \
|
||||||
boost::test_tools::fraction_tolerance( tolerance ) ) ) )
|
boost::test_tools::fraction_tolerance( tolerance ) ) ) )
|
||||||
|
|
||||||
#ifdef BOOST_MSVC
|
#ifdef BOOST_MSVC
|
||||||
# pragma push_macro( "near" )
|
# pragma push_macro( "near" )
|
||||||
# undef near
|
# undef near
|
||||||
#endif
|
#endif
|
||||||
MOCK_NARY_CONSTRAINT( near, 2, ( expected, tolerance ), \
|
MOCK_NARY_CONSTRAINT( near, 2, ( expected, tolerance ), \
|
||||||
std::abs( actual - expected ) < tolerance )
|
std::abs( actual - expected ) < tolerance )
|
||||||
#ifdef BOOST_MSVC
|
#ifdef BOOST_MSVC
|
||||||
# pragma pop_macro( "near" )
|
# pragma pop_macro( "near" )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
template< typename Expected >
|
template< typename Expected >
|
||||||
struct same
|
struct same
|
||||||
{
|
{
|
||||||
explicit same( const Expected& expected )
|
explicit same( const Expected& expected )
|
||||||
: expected_( detail::addressof( boost::unwrap_ref( expected ) ) )
|
: expected_( detail::addressof( boost::unwrap_ref( expected ) ) )
|
||||||
{}
|
{}
|
||||||
template< typename Actual >
|
template< typename Actual >
|
||||||
bool operator()( const Actual& actual ) const
|
bool operator()( const Actual& actual ) const
|
||||||
{
|
{
|
||||||
return detail::addressof( actual ) == expected_;
|
return detail::addressof( actual ) == expected_;
|
||||||
}
|
}
|
||||||
friend std::ostream& operator<<( std::ostream& os, const same& s )
|
friend std::ostream& operator<<( std::ostream& os, const same& s )
|
||||||
{
|
{
|
||||||
return os << "same( " << mock::format( *s.expected_ ) << " )";
|
return os << "same( " << mock::format( *s.expected_ ) << " )";
|
||||||
}
|
}
|
||||||
const typename
|
const typename
|
||||||
boost::unwrap_reference< Expected >::type* expected_;
|
boost::unwrap_reference< Expected >::type* expected_;
|
||||||
};
|
};
|
||||||
|
|
||||||
template< typename Expected >
|
template< typename Expected >
|
||||||
struct retrieve
|
struct retrieve
|
||||||
{
|
{
|
||||||
explicit retrieve( Expected& expected )
|
explicit retrieve( Expected& expected )
|
||||||
: expected_( detail::addressof( boost::unwrap_ref( expected ) ) )
|
: expected_( detail::addressof( boost::unwrap_ref( expected ) ) )
|
||||||
{}
|
{}
|
||||||
template< typename Actual >
|
template< typename Actual >
|
||||||
bool operator()( const Actual& actual,
|
bool operator()( const Actual& actual,
|
||||||
typename boost::disable_if<
|
typename boost::disable_if<
|
||||||
boost::is_convertible<
|
boost::is_convertible<
|
||||||
const Actual*,
|
const Actual*,
|
||||||
typename
|
typename
|
||||||
boost::unwrap_reference< Expected >::type
|
boost::unwrap_reference< Expected >::type
|
||||||
>
|
>
|
||||||
>::type* = 0 ) const
|
>::type* = 0 ) const
|
||||||
{
|
{
|
||||||
*expected_ = actual;
|
*expected_ = actual;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
template< typename Actual >
|
template< typename Actual >
|
||||||
bool operator()( Actual& actual,
|
bool operator()( Actual& actual,
|
||||||
typename boost::enable_if<
|
typename boost::enable_if<
|
||||||
boost::is_convertible< Actual*,
|
boost::is_convertible< Actual*,
|
||||||
typename
|
typename
|
||||||
boost::unwrap_reference< Expected >::type
|
boost::unwrap_reference< Expected >::type
|
||||||
>
|
>
|
||||||
>::type* = 0 ) const
|
>::type* = 0 ) const
|
||||||
{
|
{
|
||||||
*expected_ = detail::addressof( actual );
|
*expected_ = detail::addressof( actual );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
friend std::ostream& operator<<( std::ostream& s, const retrieve& r )
|
friend std::ostream& operator<<( std::ostream& s, const retrieve& r )
|
||||||
{
|
{
|
||||||
return s << "retrieve( " << mock::format( *r.expected_ ) << " )";
|
return s << "retrieve( " << mock::format( *r.expected_ ) << " )";
|
||||||
}
|
}
|
||||||
typename
|
typename
|
||||||
boost::unwrap_reference< Expected >::type* expected_;
|
boost::unwrap_reference< Expected >::type* expected_;
|
||||||
};
|
};
|
||||||
|
|
||||||
template< typename Expected >
|
template< typename Expected >
|
||||||
struct assign
|
struct assign
|
||||||
{
|
{
|
||||||
explicit assign( const Expected& expected )
|
explicit assign( const Expected& expected )
|
||||||
: expected_( expected )
|
: expected_( expected )
|
||||||
{}
|
{}
|
||||||
template< typename Actual >
|
template< typename Actual >
|
||||||
bool operator()( Actual& actual ) const
|
bool operator()( Actual& actual ) const
|
||||||
{
|
{
|
||||||
actual = boost::unwrap_ref( expected_ );
|
actual = boost::unwrap_ref( expected_ );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
template< typename Actual >
|
template< typename Actual >
|
||||||
bool operator()( Actual* actual,
|
bool operator()( Actual* actual,
|
||||||
typename boost::enable_if<
|
typename boost::enable_if<
|
||||||
boost::is_convertible<
|
boost::is_convertible<
|
||||||
typename
|
typename
|
||||||
boost::unwrap_reference< Expected >::type,
|
boost::unwrap_reference< Expected >::type,
|
||||||
Actual
|
Actual
|
||||||
>
|
>
|
||||||
>::type* = 0 ) const
|
>::type* = 0 ) const
|
||||||
{
|
{
|
||||||
*actual = boost::unwrap_ref( expected_ );
|
*actual = boost::unwrap_ref( expected_ );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
friend std::ostream& operator<<( std::ostream& s, const assign& a )
|
friend std::ostream& operator<<( std::ostream& s, const assign& a )
|
||||||
{
|
{
|
||||||
return s << "assign( " << mock::format( a.expected_ ) << " )";
|
return s << "assign( " << mock::format( a.expected_ ) << " )";
|
||||||
}
|
}
|
||||||
Expected expected_;
|
Expected expected_;
|
||||||
};
|
};
|
||||||
|
|
||||||
template< typename Expected >
|
template< typename Expected >
|
||||||
struct contain
|
struct contain
|
||||||
{
|
{
|
||||||
explicit contain( const Expected& expected )
|
explicit contain( const Expected& expected )
|
||||||
: expected_( expected )
|
: expected_( expected )
|
||||||
{}
|
{}
|
||||||
bool operator()( const std::string& actual ) const
|
bool operator()( const std::string& actual ) const
|
||||||
{
|
{
|
||||||
return actual.find( boost::unwrap_ref( expected_ ) )
|
return actual.find( boost::unwrap_ref( expected_ ) )
|
||||||
!= std::string::npos;
|
!= std::string::npos;
|
||||||
}
|
}
|
||||||
friend std::ostream& operator<<( std::ostream& s, const contain& n )
|
friend std::ostream& operator<<( std::ostream& s, const contain& n )
|
||||||
{
|
{
|
||||||
return s << "contain( " << mock::format( n.expected_ ) << " )";
|
return s << "contain( " << mock::format( n.expected_ ) << " )";
|
||||||
}
|
}
|
||||||
Expected expected_;
|
Expected expected_;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
template< typename T >
|
template< typename T >
|
||||||
constraint< detail::same< T > > same( T& t )
|
constraint< detail::same< T > > same( T& t )
|
||||||
{
|
{
|
||||||
return detail::same< T >( t );
|
return detail::same< T >( t );
|
||||||
}
|
}
|
||||||
template< typename T >
|
template< typename T >
|
||||||
constraint< detail::retrieve< T > > retrieve( T& t )
|
constraint< detail::retrieve< T > > retrieve( T& t )
|
||||||
{
|
{
|
||||||
return detail::retrieve< T >( t );
|
return detail::retrieve< T >( t );
|
||||||
}
|
}
|
||||||
template< typename T >
|
template< typename T >
|
||||||
constraint< detail::assign< T > > assign( T t )
|
constraint< detail::assign< T > > assign( T t )
|
||||||
{
|
{
|
||||||
return detail::assign< T >( t );
|
return detail::assign< T >( t );
|
||||||
}
|
}
|
||||||
template< typename T >
|
template< typename T >
|
||||||
constraint< detail::contain< T > > contain( T t )
|
constraint< detail::contain< T > > contain( T t )
|
||||||
{
|
{
|
||||||
return detail::contain< T >( t );
|
return detail::contain< T >( t );
|
||||||
}
|
}
|
||||||
|
|
||||||
template< typename T >
|
template< typename T >
|
||||||
constraint< T > call( T t )
|
constraint< T > call( T t )
|
||||||
{
|
{
|
||||||
return constraint< T >( t );
|
return constraint< T >( t );
|
||||||
}
|
}
|
||||||
} // mock
|
} // mock
|
||||||
|
|
||||||
#endif // MOCK_CONSTRAINTS_HPP_INCLUDED
|
#endif // MOCK_CONSTRAINTS_HPP_INCLUDED
|
||||||
|
|
@ -1,214 +1,214 @@
|
||||||
// http://turtle.sourceforge.net
|
// http://turtle.sourceforge.net
|
||||||
//
|
//
|
||||||
// Copyright Mathieu Champlon 2008
|
// Copyright Mathieu Champlon 2008
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#ifndef MOCK_ACTION_HPP_INCLUDED
|
#ifndef MOCK_ACTION_HPP_INCLUDED
|
||||||
#define MOCK_ACTION_HPP_INCLUDED
|
#define MOCK_ACTION_HPP_INCLUDED
|
||||||
|
|
||||||
#include "../config.hpp"
|
#include "../config.hpp"
|
||||||
#include <boost/type_traits/remove_reference.hpp>
|
#include <boost/type_traits/remove_reference.hpp>
|
||||||
#include <boost/type_traits/remove_const.hpp>
|
#include <boost/type_traits/remove_const.hpp>
|
||||||
#include <boost/noncopyable.hpp>
|
#include <boost/noncopyable.hpp>
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
#include <boost/move/move.hpp>
|
#include <boost/move/move.hpp>
|
||||||
#include <boost/function.hpp>
|
#include <boost/function.hpp>
|
||||||
#include <boost/bind.hpp>
|
#include <boost/bind.hpp>
|
||||||
#include <boost/ref.hpp>
|
#include <boost/ref.hpp>
|
||||||
|
|
||||||
namespace mock
|
namespace mock
|
||||||
{
|
{
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
template< typename Result, typename Signature >
|
template< typename Result, typename Signature >
|
||||||
class action_base
|
class action_base
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
typedef boost::function< Signature > functor_type;
|
typedef boost::function< Signature > functor_type;
|
||||||
typedef boost::function< Result() > action_type;
|
typedef boost::function< Result() > action_type;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
const functor_type& functor() const
|
const functor_type& functor() const
|
||||||
{
|
{
|
||||||
return f_;
|
return f_;
|
||||||
}
|
}
|
||||||
bool valid() const
|
bool valid() const
|
||||||
{
|
{
|
||||||
return f_ || a_;
|
return f_ || a_;
|
||||||
}
|
}
|
||||||
Result trigger() const
|
Result trigger() const
|
||||||
{
|
{
|
||||||
return a_();
|
return a_();
|
||||||
}
|
}
|
||||||
|
|
||||||
void calls( const functor_type& f )
|
void calls( const functor_type& f )
|
||||||
{
|
{
|
||||||
if( ! f )
|
if( ! f )
|
||||||
throw std::invalid_argument( "null functor" );
|
throw std::invalid_argument( "null functor" );
|
||||||
f_ = f;
|
f_ = f;
|
||||||
}
|
}
|
||||||
|
|
||||||
template< typename Exception >
|
template< typename Exception >
|
||||||
void throws( Exception e )
|
void throws( Exception e )
|
||||||
{
|
{
|
||||||
a_ = boost::bind( &do_throw< Exception >, e );
|
a_ = boost::bind( &do_throw< Exception >, e );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void set( const action_type& a )
|
void set( const action_type& a )
|
||||||
{
|
{
|
||||||
a_ = a;
|
a_ = a;
|
||||||
}
|
}
|
||||||
template< typename Y >
|
template< typename Y >
|
||||||
void set( const boost::reference_wrapper< Y >& r )
|
void set( const boost::reference_wrapper< Y >& r )
|
||||||
{
|
{
|
||||||
a_ = boost::bind( &do_ref< Y >, r.get_pointer() );
|
a_ = boost::bind( &do_ref< Y >, r.get_pointer() );
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
template< typename T >
|
template< typename T >
|
||||||
static T& do_ref( T* t )
|
static T& do_ref( T* t )
|
||||||
{
|
{
|
||||||
return *t;
|
return *t;
|
||||||
}
|
}
|
||||||
template< typename T >
|
template< typename T >
|
||||||
static Result do_throw( T t )
|
static Result do_throw( T t )
|
||||||
{
|
{
|
||||||
throw t;
|
throw t;
|
||||||
}
|
}
|
||||||
|
|
||||||
functor_type f_;
|
functor_type f_;
|
||||||
action_type a_;
|
action_type a_;
|
||||||
};
|
};
|
||||||
|
|
||||||
template< typename Result, typename Signature >
|
template< typename Result, typename Signature >
|
||||||
class action : public action_base< Result, Signature >
|
class action : public action_base< Result, Signature >
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
template< typename Value >
|
template< typename Value >
|
||||||
void returns( const Value& v )
|
void returns( const Value& v )
|
||||||
{
|
{
|
||||||
this->set( boost::ref( store( v ) ) );
|
this->set( boost::ref( store( v ) ) );
|
||||||
}
|
}
|
||||||
template< typename Y >
|
template< typename Y >
|
||||||
void returns( const boost::reference_wrapper< Y >& r )
|
void returns( const boost::reference_wrapper< Y >& r )
|
||||||
{
|
{
|
||||||
this->set( r );
|
this->set( r );
|
||||||
}
|
}
|
||||||
|
|
||||||
template< typename Value >
|
template< typename Value >
|
||||||
void moves( BOOST_RV_REF( Value ) v )
|
void moves( BOOST_RV_REF( Value ) v )
|
||||||
{
|
{
|
||||||
this->set(
|
this->set(
|
||||||
boost::bind(
|
boost::bind(
|
||||||
&boost::move< BOOST_RV_REF( Value ) >,
|
&boost::move< BOOST_RV_REF( Value ) >,
|
||||||
boost::ref( store( boost::move( v ) ) ) ) );
|
boost::ref( store( boost::move( v ) ) ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct value : boost::noncopyable
|
struct value : boost::noncopyable
|
||||||
{
|
{
|
||||||
virtual ~value()
|
virtual ~value()
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
template< typename T >
|
template< typename T >
|
||||||
struct value_imp : value
|
struct value_imp : value
|
||||||
{
|
{
|
||||||
typedef
|
typedef
|
||||||
typename boost::remove_const<
|
typename boost::remove_const<
|
||||||
typename boost::remove_reference<
|
typename boost::remove_reference<
|
||||||
T
|
T
|
||||||
>::type
|
>::type
|
||||||
>::type value_type;
|
>::type value_type;
|
||||||
|
|
||||||
value_imp( BOOST_RV_REF( value_type ) t )
|
value_imp( BOOST_RV_REF( value_type ) t )
|
||||||
: t_( boost::move( t ) )
|
: t_( boost::move( t ) )
|
||||||
{}
|
{}
|
||||||
value_imp( const T& t )
|
value_imp( const T& t )
|
||||||
: t_( t )
|
: t_( t )
|
||||||
{}
|
{}
|
||||||
template< typename Y >
|
template< typename Y >
|
||||||
value_imp( Y* y )
|
value_imp( Y* y )
|
||||||
: t_( y )
|
: t_( y )
|
||||||
{}
|
{}
|
||||||
value_type t_;
|
value_type t_;
|
||||||
};
|
};
|
||||||
|
|
||||||
template< typename T >
|
template< typename T >
|
||||||
T& store( BOOST_RV_REF( T ) t )
|
T& store( BOOST_RV_REF( T ) t )
|
||||||
{
|
{
|
||||||
v_.reset( new value_imp< T >( boost::move( t ) ) );
|
v_.reset( new value_imp< T >( boost::move( t ) ) );
|
||||||
return static_cast< value_imp< T >& >( *v_ ).t_;
|
return static_cast< value_imp< T >& >( *v_ ).t_;
|
||||||
}
|
}
|
||||||
template< typename T >
|
template< typename T >
|
||||||
T& store( const T& t )
|
T& store( const T& t )
|
||||||
{
|
{
|
||||||
v_.reset( new value_imp< T >( t ) );
|
v_.reset( new value_imp< T >( t ) );
|
||||||
return static_cast< value_imp< T >& >( *v_ ).t_;
|
return static_cast< value_imp< T >& >( *v_ ).t_;
|
||||||
}
|
}
|
||||||
template< typename T >
|
template< typename T >
|
||||||
Result& store( T* t )
|
Result& store( T* t )
|
||||||
{
|
{
|
||||||
v_.reset( new value_imp< Result >( t ) );
|
v_.reset( new value_imp< Result >( t ) );
|
||||||
return static_cast< value_imp< Result >& >( *v_ ).t_;
|
return static_cast< value_imp< Result >& >( *v_ ).t_;
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::shared_ptr< value > v_;
|
boost::shared_ptr< value > v_;
|
||||||
};
|
};
|
||||||
|
|
||||||
template< typename Signature >
|
template< typename Signature >
|
||||||
class action< void, Signature > : public action_base< void, Signature >
|
class action< void, Signature > : public action_base< void, Signature >
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
action()
|
action()
|
||||||
{
|
{
|
||||||
this->set( boost::bind( &do_nothing ) );
|
this->set( boost::bind( &do_nothing ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void do_nothing()
|
static void do_nothing()
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
template< typename Result, typename Signature >
|
template< typename Result, typename Signature >
|
||||||
class action< std::auto_ptr< Result >, Signature >
|
class action< std::auto_ptr< Result >, Signature >
|
||||||
: public action_base< std::auto_ptr< Result >, Signature >
|
: public action_base< std::auto_ptr< Result >, Signature >
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
action()
|
action()
|
||||||
{}
|
{}
|
||||||
action( const action& rhs )
|
action( const action& rhs )
|
||||||
: v_( rhs.v_.release() )
|
: v_( rhs.v_.release() )
|
||||||
{
|
{
|
||||||
if( v_.get() )
|
if( v_.get() )
|
||||||
returns( boost::ref( v_ ) );
|
returns( boost::ref( v_ ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
template< typename Y >
|
template< typename Y >
|
||||||
void returns( Y* r )
|
void returns( Y* r )
|
||||||
{
|
{
|
||||||
v_.reset( r );
|
v_.reset( r );
|
||||||
this->set( boost::ref( v_ ) );
|
this->set( boost::ref( v_ ) );
|
||||||
}
|
}
|
||||||
template< typename Y >
|
template< typename Y >
|
||||||
void returns( std::auto_ptr< Y > r )
|
void returns( std::auto_ptr< Y > r )
|
||||||
{
|
{
|
||||||
v_ = r;
|
v_ = r;
|
||||||
this->set( boost::ref( v_ ) );
|
this->set( boost::ref( v_ ) );
|
||||||
}
|
}
|
||||||
template< typename Y >
|
template< typename Y >
|
||||||
void returns( const boost::reference_wrapper< Y >& r )
|
void returns( const boost::reference_wrapper< Y >& r )
|
||||||
{
|
{
|
||||||
this->set( r );
|
this->set( r );
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
mutable std::auto_ptr< Result > v_;
|
mutable std::auto_ptr< Result > v_;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
} // mock
|
} // mock
|
||||||
|
|
||||||
#endif // MOCK_ACTION_HPP_INCLUDED
|
#endif // MOCK_ACTION_HPP_INCLUDED
|
||||||
|
|
@ -1,36 +1,36 @@
|
||||||
// http://turtle.sourceforge.net
|
// http://turtle.sourceforge.net
|
||||||
//
|
//
|
||||||
// Copyright Mathieu Champlon 2013
|
// Copyright Mathieu Champlon 2013
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#ifndef MOCK_ADDRESSOF_HPP_INCLUDED
|
#ifndef MOCK_ADDRESSOF_HPP_INCLUDED
|
||||||
#define MOCK_ADDRESSOF_HPP_INCLUDED
|
#define MOCK_ADDRESSOF_HPP_INCLUDED
|
||||||
|
|
||||||
#include "../config.hpp"
|
#include "../config.hpp"
|
||||||
#include <boost/utility/addressof.hpp>
|
#include <boost/utility/addressof.hpp>
|
||||||
|
|
||||||
namespace mock
|
namespace mock
|
||||||
{
|
{
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
using boost::addressof;
|
using boost::addressof;
|
||||||
|
|
||||||
#ifdef MOCK_NULLPTR
|
#ifdef MOCK_NULLPTR
|
||||||
|
|
||||||
inline const std::nullptr_t* addressof( const std::nullptr_t& p )
|
inline const std::nullptr_t* addressof( const std::nullptr_t& p )
|
||||||
{
|
{
|
||||||
return &p;
|
return &p;
|
||||||
}
|
}
|
||||||
inline std::nullptr_t* addressof( std::nullptr_t& p )
|
inline std::nullptr_t* addressof( std::nullptr_t& p )
|
||||||
{
|
{
|
||||||
return &p;
|
return &p;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
} // mock
|
} // mock
|
||||||
|
|
||||||
#endif // MOCK_ADDRESSOF_HPP_INCLUDED
|
#endif // MOCK_ADDRESSOF_HPP_INCLUDED
|
||||||
|
|
@ -1,52 +1,52 @@
|
||||||
// http://turtle.sourceforge.net
|
// http://turtle.sourceforge.net
|
||||||
//
|
//
|
||||||
// Copyright Mathieu Champlon 2011
|
// Copyright Mathieu Champlon 2011
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#ifndef MOCK_CHILD_HPP_INCLUDED
|
#ifndef MOCK_CHILD_HPP_INCLUDED
|
||||||
#define MOCK_CHILD_HPP_INCLUDED
|
#define MOCK_CHILD_HPP_INCLUDED
|
||||||
|
|
||||||
#include "../config.hpp"
|
#include "../config.hpp"
|
||||||
#include "type_name.hpp"
|
#include "type_name.hpp"
|
||||||
#include "parent.hpp"
|
#include "parent.hpp"
|
||||||
#include <boost/test/utils/basic_cstring/basic_cstring.hpp>
|
#include <boost/test/utils/basic_cstring/basic_cstring.hpp>
|
||||||
#include <boost/optional.hpp>
|
#include <boost/optional.hpp>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
|
|
||||||
namespace mock
|
namespace mock
|
||||||
{
|
{
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
class child
|
class child
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
child()
|
child()
|
||||||
: parent_( 0 )
|
: parent_( 0 )
|
||||||
{}
|
{}
|
||||||
void update( parent& p,
|
void update( parent& p,
|
||||||
boost::unit_test::const_string instance,
|
boost::unit_test::const_string instance,
|
||||||
boost::optional< type_name > type,
|
boost::optional< type_name > type,
|
||||||
boost::unit_test::const_string name )
|
boost::unit_test::const_string name )
|
||||||
{
|
{
|
||||||
if( instance != "?." || name_.empty() )
|
if( instance != "?." || name_.empty() )
|
||||||
p = parent( instance, type );
|
p = parent( instance, type );
|
||||||
parent_ = &p;
|
parent_ = &p;
|
||||||
name_ = name;
|
name_ = name;
|
||||||
}
|
}
|
||||||
friend std::ostream& operator<<( std::ostream& s, const child& c )
|
friend std::ostream& operator<<( std::ostream& s, const child& c )
|
||||||
{
|
{
|
||||||
if( c.parent_ )
|
if( c.parent_ )
|
||||||
s << *c.parent_;
|
s << *c.parent_;
|
||||||
return s << c.name_;
|
return s << c.name_;
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
const parent* parent_;
|
const parent* parent_;
|
||||||
boost::unit_test::const_string name_;
|
boost::unit_test::const_string name_;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
} // mock
|
} // mock
|
||||||
|
|
||||||
#endif // MOCK_CHILD_HPP_INCLUDED
|
#endif // MOCK_CHILD_HPP_INCLUDED
|
||||||
|
|
@ -1,37 +1,37 @@
|
||||||
// http://turtle.sourceforge.net
|
// http://turtle.sourceforge.net
|
||||||
//
|
//
|
||||||
// Copyright Mathieu Champlon 2011
|
// Copyright Mathieu Champlon 2011
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#ifndef MOCK_CLEANUP_HPP_INCLUDED
|
#ifndef MOCK_CLEANUP_HPP_INCLUDED
|
||||||
#define MOCK_CLEANUP_HPP_INCLUDED
|
#define MOCK_CLEANUP_HPP_INCLUDED
|
||||||
|
|
||||||
#include "../config.hpp"
|
#include "../config.hpp"
|
||||||
#ifdef MOCK_USE_BOOST_TEST
|
#ifdef MOCK_USE_BOOST_TEST
|
||||||
#include "../verify.hpp"
|
#include "../verify.hpp"
|
||||||
#include "../reset.hpp"
|
#include "../reset.hpp"
|
||||||
#include <boost/test/unit_test_suite.hpp>
|
#include <boost/test/unit_test_suite.hpp>
|
||||||
|
|
||||||
namespace mock
|
namespace mock
|
||||||
{
|
{
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
struct cleanup
|
struct cleanup
|
||||||
{
|
{
|
||||||
~cleanup()
|
~cleanup()
|
||||||
{
|
{
|
||||||
// see https://svn.boost.org/trac/boost/ticket/5563
|
// see https://svn.boost.org/trac/boost/ticket/5563
|
||||||
//mock::verify();
|
//mock::verify();
|
||||||
mock::reset();
|
mock::reset();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
BOOST_GLOBAL_FIXTURE( cleanup )
|
BOOST_GLOBAL_FIXTURE( cleanup )
|
||||||
}
|
}
|
||||||
} // mock
|
} // mock
|
||||||
|
|
||||||
#endif // MOCK_USE_BOOST_TEST
|
#endif // MOCK_USE_BOOST_TEST
|
||||||
|
|
||||||
#endif // MOCK_CLEANUP_HPP_INCLUDED
|
#endif // MOCK_CLEANUP_HPP_INCLUDED
|
||||||
|
|
@ -1,44 +1,44 @@
|
||||||
// http://turtle.sourceforge.net
|
// http://turtle.sourceforge.net
|
||||||
//
|
//
|
||||||
// Copyright Mathieu Champlon 2011
|
// Copyright Mathieu Champlon 2011
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#ifndef MOCK_CONTEXT_HPP_INCLUDED
|
#ifndef MOCK_CONTEXT_HPP_INCLUDED
|
||||||
#define MOCK_CONTEXT_HPP_INCLUDED
|
#define MOCK_CONTEXT_HPP_INCLUDED
|
||||||
|
|
||||||
#include "../config.hpp"
|
#include "../config.hpp"
|
||||||
#include "type_name.hpp"
|
#include "type_name.hpp"
|
||||||
#include <boost/noncopyable.hpp>
|
#include <boost/noncopyable.hpp>
|
||||||
#include <boost/optional.hpp>
|
#include <boost/optional.hpp>
|
||||||
#include <boost/test/utils/basic_cstring/basic_cstring.hpp>
|
#include <boost/test/utils/basic_cstring/basic_cstring.hpp>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
|
|
||||||
namespace mock
|
namespace mock
|
||||||
{
|
{
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
class verifiable;
|
class verifiable;
|
||||||
|
|
||||||
class context : boost::noncopyable
|
class context : boost::noncopyable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
context() {}
|
context() {}
|
||||||
virtual ~context() {}
|
virtual ~context() {}
|
||||||
|
|
||||||
virtual void add( const void* p, verifiable& v,
|
virtual void add( const void* p, verifiable& v,
|
||||||
boost::unit_test::const_string instance,
|
boost::unit_test::const_string instance,
|
||||||
boost::optional< type_name > type,
|
boost::optional< type_name > type,
|
||||||
boost::unit_test::const_string name ) = 0;
|
boost::unit_test::const_string name ) = 0;
|
||||||
virtual void add( verifiable& v ) = 0;
|
virtual void add( verifiable& v ) = 0;
|
||||||
virtual void remove( verifiable& v ) = 0;
|
virtual void remove( verifiable& v ) = 0;
|
||||||
|
|
||||||
virtual void serialize( std::ostream& s,
|
virtual void serialize( std::ostream& s,
|
||||||
const verifiable& v ) const = 0;
|
const verifiable& v ) const = 0;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
} // mock
|
} // mock
|
||||||
|
|
||||||
#endif // MOCK_CONTEXT_HPP_INCLUDED
|
#endif // MOCK_CONTEXT_HPP_INCLUDED
|
||||||
|
|
@ -1,263 +1,263 @@
|
||||||
// http://turtle.sourceforge.net
|
// http://turtle.sourceforge.net
|
||||||
//
|
//
|
||||||
// Copyright Mathieu Champlon 2012
|
// Copyright Mathieu Champlon 2012
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#include "matcher_base_template.hpp"
|
#include "matcher_base_template.hpp"
|
||||||
|
|
||||||
#define MOCK_EXPECTATION_INITIALIZE(z, n, d) \
|
#define MOCK_EXPECTATION_INITIALIZE(z, n, d) \
|
||||||
BOOST_PP_COMMA_IF(n) c##n##_( c##n )
|
BOOST_PP_COMMA_IF(n) c##n##_( c##n )
|
||||||
|
|
||||||
#define MOCK_EXPECTATION_MEMBER(z, n, d) \
|
#define MOCK_EXPECTATION_MEMBER(z, n, d) \
|
||||||
matcher< T##n, Constraint_##n > c##n##_;
|
matcher< T##n, Constraint_##n > c##n##_;
|
||||||
|
|
||||||
#define MOCK_EXPECTATION_IS_VALID(z, n, d) \
|
#define MOCK_EXPECTATION_IS_VALID(z, n, d) \
|
||||||
BOOST_PP_IF(n, &&,) c##n##_( a##n )
|
BOOST_PP_IF(n, &&,) c##n##_( a##n )
|
||||||
|
|
||||||
#define MOCK_EXPECTATION_SERIALIZE(z, n, d) \
|
#define MOCK_EXPECTATION_SERIALIZE(z, n, d) \
|
||||||
BOOST_PP_IF(n, << ", " <<,) c##n##_
|
BOOST_PP_IF(n, << ", " <<,) c##n##_
|
||||||
|
|
||||||
#define MOCK_EXPECTATION_SERIALIZE_ANY(z, n, d) \
|
#define MOCK_EXPECTATION_SERIALIZE_ANY(z, n, d) \
|
||||||
BOOST_PP_IF(n, << ", " <<,) "any"
|
BOOST_PP_IF(n, << ", " <<,) "any"
|
||||||
|
|
||||||
namespace mock
|
namespace mock
|
||||||
{
|
{
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
template< typename Signature > class default_matcher;
|
template< typename Signature > class default_matcher;
|
||||||
|
|
||||||
template<
|
template<
|
||||||
BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, typename T) >
|
BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, typename T) >
|
||||||
class default_matcher< void( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, 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) ) >
|
: public matcher_base< void( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) ) >
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
virtual bool operator()(
|
virtual bool operator()(
|
||||||
BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) )
|
BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) )
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
virtual void serialize( std::ostream& s ) const
|
virtual void serialize( std::ostream& s ) const
|
||||||
{
|
{
|
||||||
s << "" BOOST_PP_REPEAT(MOCK_NUM_ARGS,
|
s << "" BOOST_PP_REPEAT(MOCK_NUM_ARGS,
|
||||||
MOCK_EXPECTATION_SERIALIZE_ANY, _ );
|
MOCK_EXPECTATION_SERIALIZE_ANY, _ );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef MOCK_NUM_ARGS_0
|
#ifndef MOCK_NUM_ARGS_0
|
||||||
|
|
||||||
template< typename Constraint, typename Signature > class single_matcher;
|
template< typename Constraint, typename Signature > class single_matcher;
|
||||||
|
|
||||||
template<
|
template<
|
||||||
BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, typename Constraint_),
|
BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, typename Constraint_),
|
||||||
BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, typename T)
|
BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, typename T)
|
||||||
>
|
>
|
||||||
class single_matcher<
|
class single_matcher<
|
||||||
void( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, Constraint_) ),
|
void( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, Constraint_) ),
|
||||||
void( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) )
|
void( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) )
|
||||||
>
|
>
|
||||||
: public matcher_base< void( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) ) >
|
: public matcher_base< void( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) ) >
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
single_matcher(
|
single_matcher(
|
||||||
BOOST_PP_ENUM_BINARY_PARAMS(MOCK_NUM_ARGS, Constraint_, c) )
|
BOOST_PP_ENUM_BINARY_PARAMS(MOCK_NUM_ARGS, Constraint_, c) )
|
||||||
: BOOST_PP_REPEAT(MOCK_NUM_ARGS,
|
: BOOST_PP_REPEAT(MOCK_NUM_ARGS,
|
||||||
MOCK_EXPECTATION_INITIALIZE, _)
|
MOCK_EXPECTATION_INITIALIZE, _)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual bool operator()(
|
virtual bool operator()(
|
||||||
BOOST_PP_ENUM_BINARY_PARAMS(MOCK_NUM_ARGS, T, a) )
|
BOOST_PP_ENUM_BINARY_PARAMS(MOCK_NUM_ARGS, T, a) )
|
||||||
{
|
{
|
||||||
return BOOST_PP_REPEAT(MOCK_NUM_ARGS,
|
return BOOST_PP_REPEAT(MOCK_NUM_ARGS,
|
||||||
MOCK_EXPECTATION_IS_VALID, _);
|
MOCK_EXPECTATION_IS_VALID, _);
|
||||||
}
|
}
|
||||||
virtual void serialize( std::ostream& s ) const
|
virtual void serialize( std::ostream& s ) const
|
||||||
{
|
{
|
||||||
s << BOOST_PP_REPEAT(MOCK_NUM_ARGS,
|
s << BOOST_PP_REPEAT(MOCK_NUM_ARGS,
|
||||||
MOCK_EXPECTATION_SERIALIZE, _ );
|
MOCK_EXPECTATION_SERIALIZE, _ );
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BOOST_PP_REPEAT(
|
BOOST_PP_REPEAT(
|
||||||
MOCK_NUM_ARGS, MOCK_EXPECTATION_MEMBER, _ )
|
MOCK_NUM_ARGS, MOCK_EXPECTATION_MEMBER, _ )
|
||||||
};
|
};
|
||||||
|
|
||||||
template< typename F, typename Signature > class multi_matcher;
|
template< typename F, typename Signature > class multi_matcher;
|
||||||
|
|
||||||
template< typename F,
|
template< typename F,
|
||||||
BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, typename T) >
|
BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, typename T) >
|
||||||
class multi_matcher< F, void( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, 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 matcher_base< void( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS,T) ) >
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
multi_matcher( const F& f )
|
multi_matcher( const F& f )
|
||||||
: f_( f )
|
: f_( f )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual bool operator()(
|
virtual bool operator()(
|
||||||
BOOST_PP_ENUM_BINARY_PARAMS( MOCK_NUM_ARGS, T, a ) )
|
BOOST_PP_ENUM_BINARY_PARAMS( MOCK_NUM_ARGS, T, a ) )
|
||||||
{
|
{
|
||||||
return f_( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, a ) );
|
return f_( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, a ) );
|
||||||
}
|
}
|
||||||
virtual void serialize( std::ostream& s ) const
|
virtual void serialize( std::ostream& s ) const
|
||||||
{
|
{
|
||||||
s << mock::format( f_ );
|
s << mock::format( f_ );
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
F f_;
|
F f_;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
template< typename Signature > class expectation;
|
template< typename Signature > class expectation;
|
||||||
|
|
||||||
template< typename R
|
template< typename R
|
||||||
BOOST_PP_ENUM_TRAILING_PARAMS(MOCK_NUM_ARGS, typename T) >
|
BOOST_PP_ENUM_TRAILING_PARAMS(MOCK_NUM_ARGS, typename T) >
|
||||||
class expectation< R (BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS,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 action< R, R (BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS,T)) >
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
expectation()
|
expectation()
|
||||||
: invocation_( boost::make_shared< unlimited >() )
|
: invocation_( boost::make_shared< unlimited >() )
|
||||||
, matcher_(
|
, matcher_(
|
||||||
boost::make_shared<
|
boost::make_shared<
|
||||||
default_matcher<
|
default_matcher<
|
||||||
void( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) )
|
void( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) )
|
||||||
>
|
>
|
||||||
> () )
|
> () )
|
||||||
, file_( "unknown location" )
|
, file_( "unknown location" )
|
||||||
, line_( 0 )
|
, line_( 0 )
|
||||||
{}
|
{}
|
||||||
expectation( const char* file, int line )
|
expectation( const char* file, int line )
|
||||||
: invocation_( boost::make_shared< unlimited >() )
|
: invocation_( boost::make_shared< unlimited >() )
|
||||||
, matcher_(
|
, matcher_(
|
||||||
boost::make_shared<
|
boost::make_shared<
|
||||||
default_matcher<
|
default_matcher<
|
||||||
void( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) )
|
void( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) )
|
||||||
>
|
>
|
||||||
> () )
|
> () )
|
||||||
, file_( file )
|
, file_( file )
|
||||||
, line_( line )
|
, line_( line )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
~expectation()
|
~expectation()
|
||||||
{
|
{
|
||||||
for( sequences_cit it = sequences_.begin();
|
for( sequences_cit it = sequences_.begin();
|
||||||
it != sequences_.end(); ++it )
|
it != sequences_.end(); ++it )
|
||||||
(*it)->remove( this );
|
(*it)->remove( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
void invoke( const boost::shared_ptr< invocation >& i )
|
void invoke( const boost::shared_ptr< invocation >& i )
|
||||||
{
|
{
|
||||||
invocation_ = i;
|
invocation_ = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef MOCK_NUM_ARGS_0
|
#ifndef MOCK_NUM_ARGS_0
|
||||||
template<
|
template<
|
||||||
BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, typename Constraint_)
|
BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, typename Constraint_)
|
||||||
>
|
>
|
||||||
expectation& with(
|
expectation& with(
|
||||||
BOOST_PP_ENUM_BINARY_PARAMS(MOCK_NUM_ARGS, Constraint_, c) )
|
BOOST_PP_ENUM_BINARY_PARAMS(MOCK_NUM_ARGS, Constraint_, c) )
|
||||||
{
|
{
|
||||||
matcher_ =
|
matcher_.reset(
|
||||||
boost::make_shared< single_matcher<
|
new single_matcher<
|
||||||
void( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, Constraint_) ),
|
void( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, Constraint_) ),
|
||||||
void( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) )
|
void( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) )
|
||||||
> >(
|
>( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, c) ) );
|
||||||
BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, c) );
|
return *this;
|
||||||
return *this;
|
}
|
||||||
}
|
#if MOCK_NUM_ARGS > 1
|
||||||
#if MOCK_NUM_ARGS > 1
|
template< typename Constraint >
|
||||||
template< typename Constraint >
|
expectation& with( const Constraint& c )
|
||||||
expectation& with( const Constraint& c )
|
{
|
||||||
{
|
matcher_.reset(
|
||||||
matcher_ =
|
new multi_matcher<
|
||||||
boost::make_shared< multi_matcher<
|
Constraint,
|
||||||
Constraint,
|
void( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) )
|
||||||
void( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) ) > >( c );
|
>( c ) );
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void add( sequence& s )
|
void add( sequence& s )
|
||||||
{
|
{
|
||||||
s.impl_->add( this );
|
s.impl_->add( this );
|
||||||
sequences_.push_back( s.impl_ );
|
sequences_.push_back( s.impl_ );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool verify() const
|
bool verify() const
|
||||||
{
|
{
|
||||||
return invocation_->verify();
|
return invocation_->verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_valid(
|
bool is_valid(
|
||||||
BOOST_PP_ENUM_BINARY_PARAMS(MOCK_NUM_ARGS, T, a) ) const
|
BOOST_PP_ENUM_BINARY_PARAMS(MOCK_NUM_ARGS, T, a) ) const
|
||||||
{
|
{
|
||||||
return !invocation_->exhausted()
|
return !invocation_->exhausted()
|
||||||
&& (*matcher_)( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, a) );
|
&& (*matcher_)( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, a) );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool invoke() const
|
bool invoke() const
|
||||||
{
|
{
|
||||||
for( sequences_cit it = sequences_.begin();
|
for( sequences_cit it = sequences_.begin();
|
||||||
it != sequences_.end(); ++it )
|
it != sequences_.end(); ++it )
|
||||||
if( ! (*it)->is_valid( this ) )
|
if( ! (*it)->is_valid( this ) )
|
||||||
return false;
|
return false;
|
||||||
bool result = invocation_->invoke();
|
bool result = invocation_->invoke();
|
||||||
for( sequences_cit it = sequences_.begin();
|
for( sequences_cit it = sequences_.begin();
|
||||||
it != sequences_.end(); ++it )
|
it != sequences_.end(); ++it )
|
||||||
(*it)->invalidate( this );
|
(*it)->invalidate( this );
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* file() const
|
const char* file() const
|
||||||
{
|
{
|
||||||
return file_;
|
return file_;
|
||||||
}
|
}
|
||||||
int line() const
|
int line() const
|
||||||
{
|
{
|
||||||
return line_;
|
return line_;
|
||||||
}
|
}
|
||||||
|
|
||||||
friend std::ostream& operator<<(
|
friend std::ostream& operator<<(
|
||||||
std::ostream& s, const expectation& e )
|
std::ostream& s, const expectation& e )
|
||||||
{
|
{
|
||||||
return s << ( e.invocation_->exhausted() ? 'v' : '.' )
|
return s << ( e.invocation_->exhausted() ? 'v' : '.' )
|
||||||
<< ' ' << *e.invocation_
|
<< ' ' << *e.invocation_
|
||||||
#ifndef MOCK_NUM_ARGS_0
|
#ifndef MOCK_NUM_ARGS_0
|
||||||
<< ".with( " << *e.matcher_ << " )"
|
<< ".with( " << *e.matcher_ << " )"
|
||||||
#endif
|
#endif
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef std::vector<
|
typedef std::vector<
|
||||||
boost::shared_ptr< sequence_impl >
|
boost::shared_ptr< sequence_impl >
|
||||||
> sequences_type;
|
> sequences_type;
|
||||||
typedef sequences_type::const_iterator sequences_cit;
|
typedef sequences_type::const_iterator sequences_cit;
|
||||||
|
|
||||||
boost::shared_ptr< invocation > invocation_;
|
boost::shared_ptr< invocation > invocation_;
|
||||||
boost::shared_ptr<
|
boost::shared_ptr<
|
||||||
matcher_base<
|
matcher_base<
|
||||||
void( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) )
|
void( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) )
|
||||||
>
|
>
|
||||||
> matcher_;
|
> matcher_;
|
||||||
sequences_type sequences_;
|
sequences_type sequences_;
|
||||||
const char* file_;
|
const char* file_;
|
||||||
int line_;
|
int line_;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
} // mock
|
} // mock
|
||||||
|
|
||||||
#undef MOCK_EXPECTATION_INITIALIZE
|
#undef MOCK_EXPECTATION_INITIALIZE
|
||||||
#undef MOCK_EXPECTATION_MEMBER
|
#undef MOCK_EXPECTATION_MEMBER
|
||||||
#undef MOCK_EXPECTATION_IS_VALID
|
#undef MOCK_EXPECTATION_IS_VALID
|
||||||
#undef MOCK_EXPECTATION_SERIALIZE
|
#undef MOCK_EXPECTATION_SERIALIZE
|
||||||
#undef MOCK_EXPECTATION_SERIALIZE_ANY
|
#undef MOCK_EXPECTATION_SERIALIZE_ANY
|
||||||
|
|
@ -1,50 +1,50 @@
|
||||||
// http://turtle.sourceforge.net
|
// http://turtle.sourceforge.net
|
||||||
//
|
//
|
||||||
// Copyright Mathieu Champlon 2012
|
// Copyright Mathieu Champlon 2012
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#ifndef MOCK_FORMATTER_HPP_INCLUDED
|
#ifndef MOCK_FORMATTER_HPP_INCLUDED
|
||||||
#define MOCK_FORMATTER_HPP_INCLUDED
|
#define MOCK_FORMATTER_HPP_INCLUDED
|
||||||
|
|
||||||
#include "../config.hpp"
|
#include "../config.hpp"
|
||||||
#include "../stream.hpp"
|
#include "../stream.hpp"
|
||||||
#include "addressof.hpp"
|
#include "addressof.hpp"
|
||||||
|
|
||||||
namespace mock
|
namespace mock
|
||||||
{
|
{
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
template< typename T >
|
template< typename T >
|
||||||
struct formatter
|
struct formatter
|
||||||
{
|
{
|
||||||
explicit formatter( const T& t )
|
explicit formatter( const T& t )
|
||||||
: t_( detail::addressof( t ) )
|
: t_( detail::addressof( t ) )
|
||||||
{}
|
{}
|
||||||
void serialize( stream& s ) const
|
void serialize( stream& s ) const
|
||||||
{
|
{
|
||||||
detail::serialize( s, *t_ );
|
detail::serialize( s, *t_ );
|
||||||
}
|
}
|
||||||
const T* t_;
|
const T* t_;
|
||||||
};
|
};
|
||||||
|
|
||||||
template< typename T >
|
template< typename T >
|
||||||
stream& operator<<( stream& s, const formatter< T >& f )
|
stream& operator<<( stream& s, const formatter< T >& f )
|
||||||
{
|
{
|
||||||
f.serialize( s );
|
f.serialize( s );
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
template< typename T >
|
template< typename T >
|
||||||
std::ostream& operator<<( std::ostream& s, const formatter< T >& f )
|
std::ostream& operator<<( std::ostream& s, const formatter< T >& f )
|
||||||
{
|
{
|
||||||
stream ss( s );
|
stream ss( s );
|
||||||
f.serialize( ss );
|
f.serialize( ss );
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // mock
|
} // mock
|
||||||
|
|
||||||
#endif // MOCK_FORMATTER_HPP_INCLUDED
|
#endif // MOCK_FORMATTER_HPP_INCLUDED
|
||||||
|
|
@ -1,103 +1,103 @@
|
||||||
// http://turtle.sourceforge.net
|
// http://turtle.sourceforge.net
|
||||||
//
|
//
|
||||||
// Copyright Mathieu Champlon 2008
|
// Copyright Mathieu Champlon 2008
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#ifndef MOCK_FUNCTION_HPP_INCLUDED
|
#ifndef MOCK_FUNCTION_HPP_INCLUDED
|
||||||
#define MOCK_FUNCTION_HPP_INCLUDED
|
#define MOCK_FUNCTION_HPP_INCLUDED
|
||||||
|
|
||||||
#include "../config.hpp"
|
#include "../config.hpp"
|
||||||
#include "../error.hpp"
|
#include "../error.hpp"
|
||||||
#include "../log.hpp"
|
#include "../log.hpp"
|
||||||
#include "../constraints.hpp"
|
#include "../constraints.hpp"
|
||||||
#include "../sequence.hpp"
|
#include "../sequence.hpp"
|
||||||
#include "../matcher.hpp"
|
#include "../matcher.hpp"
|
||||||
#include "action.hpp"
|
#include "action.hpp"
|
||||||
#include "verifiable.hpp"
|
#include "verifiable.hpp"
|
||||||
#include "invocation.hpp"
|
#include "invocation.hpp"
|
||||||
#include "type_name.hpp"
|
#include "type_name.hpp"
|
||||||
#include "context.hpp"
|
#include "context.hpp"
|
||||||
#include "mutex.hpp"
|
#include "mutex.hpp"
|
||||||
#include <boost/preprocessor/iteration/iterate.hpp>
|
#include <boost/preprocessor/iteration/iterate.hpp>
|
||||||
#include <boost/preprocessor/repetition/repeat_from_to.hpp>
|
#include <boost/preprocessor/repetition/repeat_from_to.hpp>
|
||||||
#include <boost/preprocessor/repetition/enum_params.hpp>
|
#include <boost/preprocessor/repetition/enum_params.hpp>
|
||||||
#include <boost/preprocessor/repetition/enum_binary_params.hpp>
|
#include <boost/preprocessor/repetition/enum_binary_params.hpp>
|
||||||
#include <boost/preprocessor/comparison/equal.hpp>
|
#include <boost/preprocessor/comparison/equal.hpp>
|
||||||
#include <boost/preprocessor/comparison/greater.hpp>
|
#include <boost/preprocessor/comparison/greater.hpp>
|
||||||
#include <boost/test/utils/basic_cstring/basic_cstring.hpp>
|
#include <boost/test/utils/basic_cstring/basic_cstring.hpp>
|
||||||
#include <boost/test/utils/lazy_ostream.hpp>
|
#include <boost/test/utils/lazy_ostream.hpp>
|
||||||
#include <boost/enable_shared_from_this.hpp>
|
#include <boost/enable_shared_from_this.hpp>
|
||||||
#include <boost/call_traits.hpp>
|
#include <boost/call_traits.hpp>
|
||||||
#include <boost/make_shared.hpp>
|
#include <boost/make_shared.hpp>
|
||||||
#include <boost/noncopyable.hpp>
|
#include <boost/noncopyable.hpp>
|
||||||
#include <boost/optional.hpp>
|
#include <boost/optional.hpp>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
namespace mock
|
namespace mock
|
||||||
{
|
{
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
template< typename R, typename E >
|
template< typename R, typename E >
|
||||||
struct wrapper_base
|
struct wrapper_base
|
||||||
{
|
{
|
||||||
wrapper_base( E& e )
|
wrapper_base( E& e )
|
||||||
: e_( &e )
|
: e_( &e )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
template< typename T >
|
template< typename T >
|
||||||
void returns( T t )
|
void returns( T t )
|
||||||
{
|
{
|
||||||
e_->returns( t );
|
e_->returns( t );
|
||||||
}
|
}
|
||||||
|
|
||||||
E* e_;
|
E* e_;
|
||||||
};
|
};
|
||||||
template< typename E >
|
template< typename E >
|
||||||
struct wrapper_base< void, E >
|
struct wrapper_base< void, E >
|
||||||
{
|
{
|
||||||
wrapper_base( E& e )
|
wrapper_base( E& e )
|
||||||
: e_( &e )
|
: e_( &e )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
E* e_;
|
E* e_;
|
||||||
};
|
};
|
||||||
template< typename R, typename E >
|
template< typename R, typename E >
|
||||||
struct wrapper_base< R*, E >
|
struct wrapper_base< R*, E >
|
||||||
{
|
{
|
||||||
wrapper_base( E& e )
|
wrapper_base( E& e )
|
||||||
: e_( &e )
|
: e_( &e )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void returns( R* r )
|
void returns( R* r )
|
||||||
{
|
{
|
||||||
e_->returns( r );
|
e_->returns( r );
|
||||||
}
|
}
|
||||||
template< typename Y >
|
template< typename Y >
|
||||||
void returns( const boost::reference_wrapper< Y >& r )
|
void returns( const boost::reference_wrapper< Y >& r )
|
||||||
{
|
{
|
||||||
e_->returns( r );
|
e_->returns( r );
|
||||||
}
|
}
|
||||||
|
|
||||||
E* e_;
|
E* e_;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
} // mock
|
} // mock
|
||||||
|
|
||||||
#define MOCK_NUM_ARGS 0
|
#define MOCK_NUM_ARGS 0
|
||||||
#define MOCK_NUM_ARGS_0
|
#define MOCK_NUM_ARGS_0
|
||||||
#include "function_template.hpp"
|
#include "function_template.hpp"
|
||||||
#undef MOCK_NUM_ARGS_0
|
#undef MOCK_NUM_ARGS_0
|
||||||
#undef MOCK_NUM_ARGS
|
#undef MOCK_NUM_ARGS
|
||||||
|
|
||||||
#define BOOST_PP_FILENAME_1 <turtle/detail/function_iterate.hpp>
|
#define BOOST_PP_FILENAME_1 <turtle/detail/function_iterate.hpp>
|
||||||
#define BOOST_PP_ITERATION_LIMITS (1, MOCK_MAX_ARGS)
|
#define BOOST_PP_ITERATION_LIMITS (1, MOCK_MAX_ARGS)
|
||||||
#include BOOST_PP_ITERATE()
|
#include BOOST_PP_ITERATE()
|
||||||
#undef BOOST_PP_FILENAME_1
|
#undef BOOST_PP_FILENAME_1
|
||||||
#undef BOOST_PP_ITERATION_LIMITS
|
#undef BOOST_PP_ITERATION_LIMITS
|
||||||
|
|
||||||
#endif // MOCK_FUNCTION_HPP_INCLUDED
|
#endif // MOCK_FUNCTION_HPP_INCLUDED
|
||||||
|
|
@ -1,304 +1,308 @@
|
||||||
// http://turtle.sourceforge.net
|
// http://turtle.sourceforge.net
|
||||||
//
|
//
|
||||||
// Copyright Mathieu Champlon 2012
|
// Copyright Mathieu Champlon 2012
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#include "expectation_template.hpp"
|
#include "expectation_template.hpp"
|
||||||
|
|
||||||
#ifndef MOCK_ERROR_POLICY
|
#ifndef MOCK_ERROR_POLICY
|
||||||
# error no error policy has been set
|
# error no error policy has been set
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define MOCK_FUNCTION_FORMAT(z, n, N) \
|
#define MOCK_FUNCTION_FORMAT(z, n, N) \
|
||||||
<< ' ' << mock::format( t##n ) \
|
<< ' ' << mock::format( t##n ) \
|
||||||
<< BOOST_PP_IF(BOOST_PP_EQUAL(N,n), ' ', ',')
|
<< BOOST_PP_IF(BOOST_PP_EQUAL(N,n), ' ', ',')
|
||||||
|
|
||||||
#define MOCK_FUNCTION_CONTEXT \
|
#define MOCK_FUNCTION_CONTEXT \
|
||||||
boost::unit_test::lazy_ostream::instance() \
|
boost::unit_test::lazy_ostream::instance() \
|
||||||
<< lazy_context( this ) \
|
<< lazy_context( this ) \
|
||||||
<< '(' BOOST_PP_REPEAT(MOCK_NUM_ARGS, MOCK_FUNCTION_FORMAT, \
|
<< '(' BOOST_PP_REPEAT(MOCK_NUM_ARGS, MOCK_FUNCTION_FORMAT, \
|
||||||
BOOST_PP_DEC(MOCK_NUM_ARGS)) \
|
BOOST_PP_DEC(MOCK_NUM_ARGS)) \
|
||||||
<< ')' \
|
<< ')' \
|
||||||
<< lazy_expectations( this )
|
<< lazy_expectations( this )
|
||||||
|
|
||||||
namespace mock
|
namespace mock
|
||||||
{
|
{
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
template< typename Signature > class function_impl;
|
template< typename Signature > class function_impl;
|
||||||
|
|
||||||
template< typename R
|
template< typename R
|
||||||
BOOST_PP_ENUM_TRAILING_PARAMS(MOCK_NUM_ARGS, typename T) >
|
BOOST_PP_ENUM_TRAILING_PARAMS(MOCK_NUM_ARGS, typename T) >
|
||||||
class function_impl< R ( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) ) >
|
class function_impl< R ( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) ) >
|
||||||
: public verifiable, public boost::enable_shared_from_this<
|
: public verifiable, public boost::enable_shared_from_this<
|
||||||
function_impl< R ( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) )> >
|
function_impl< R ( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) )> >
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef safe_error< R, MOCK_ERROR_POLICY< R > > error_type;
|
typedef safe_error< R, MOCK_ERROR_POLICY< R > > error_type;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
function_impl()
|
function_impl()
|
||||||
: context_( 0 )
|
: context_( 0 )
|
||||||
, valid_( true )
|
, valid_( true )
|
||||||
, mutex_( boost::make_shared< mutex >() )
|
, mutex_( boost::make_shared< mutex >() )
|
||||||
{}
|
{}
|
||||||
virtual ~function_impl()
|
virtual ~function_impl()
|
||||||
{
|
{
|
||||||
if( valid_ && ! std::uncaught_exception() )
|
if( valid_ && ! std::uncaught_exception() )
|
||||||
for( expectations_cit it = expectations_.begin();
|
for( expectations_cit it = expectations_.begin();
|
||||||
it != expectations_.end(); ++it )
|
it != expectations_.end(); ++it )
|
||||||
if( ! it->verify() )
|
if( ! it->verify() )
|
||||||
error_type::fail( "untriggered expectation",
|
error_type::fail( "untriggered expectation",
|
||||||
boost::unit_test::lazy_ostream::instance()
|
boost::unit_test::lazy_ostream::instance()
|
||||||
<< lazy_context( this )
|
<< lazy_context( this )
|
||||||
<< lazy_expectations( this ),
|
<< lazy_expectations( this ),
|
||||||
it->file(), it->line() );
|
it->file(), it->line() );
|
||||||
if( context_ )
|
if( context_ )
|
||||||
context_->remove( *this );
|
context_->remove( *this );
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool verify() const
|
virtual bool verify() const
|
||||||
{
|
{
|
||||||
lock _( mutex_ );
|
lock _( mutex_ );
|
||||||
for( expectations_cit it = expectations_.begin();
|
for( expectations_cit it = expectations_.begin();
|
||||||
it != expectations_.end(); ++it )
|
it != expectations_.end(); ++it )
|
||||||
if( ! it->verify() )
|
if( ! it->verify() )
|
||||||
{
|
{
|
||||||
valid_ = false;
|
valid_ = false;
|
||||||
error_type::fail( "verification failed",
|
error_type::fail( "verification failed",
|
||||||
boost::unit_test::lazy_ostream::instance()
|
boost::unit_test::lazy_ostream::instance()
|
||||||
<< lazy_context( this )
|
<< lazy_context( this )
|
||||||
<< lazy_expectations( this ),
|
<< lazy_expectations( this ),
|
||||||
it->file(), it->line() );
|
it->file(), it->line() );
|
||||||
}
|
}
|
||||||
return valid_;
|
return valid_;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void reset()
|
virtual void reset()
|
||||||
{
|
{
|
||||||
lock _( mutex_ );
|
lock _( mutex_ );
|
||||||
valid_ = true;
|
valid_ = true;
|
||||||
boost::shared_ptr< function_impl > guard =
|
boost::shared_ptr< function_impl > guard =
|
||||||
this->shared_from_this();
|
this->shared_from_this();
|
||||||
expectations_.clear();
|
expectations_.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef expectation<
|
typedef expectation<
|
||||||
R( BOOST_PP_ENUM_PARAMS( MOCK_NUM_ARGS, T ) )
|
R( BOOST_PP_ENUM_PARAMS( MOCK_NUM_ARGS, T ) )
|
||||||
> expectation_type;
|
> expectation_type;
|
||||||
|
|
||||||
struct wrapper : wrapper_base< R, expectation_type >
|
struct wrapper : wrapper_base< R, expectation_type >
|
||||||
{
|
{
|
||||||
wrapper( const boost::shared_ptr< mutex >& m, expectation_type& e )
|
wrapper( const boost::shared_ptr< mutex >& m, expectation_type& e )
|
||||||
: wrapper_base< R, expectation_type >( e )
|
: wrapper_base< R, expectation_type >( e )
|
||||||
, lock_( m )
|
, lock_( m )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
wrapper once()
|
wrapper once()
|
||||||
{
|
{
|
||||||
this->e_->invoke( boost::make_shared< detail::once >() );
|
this->e_->invoke( boost::make_shared< detail::once >() );
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
wrapper never()
|
wrapper never()
|
||||||
{
|
{
|
||||||
this->e_->invoke( boost::make_shared< detail::never >() );
|
this->e_->invoke( boost::make_shared< detail::never >() );
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
wrapper exactly( std::size_t count )
|
wrapper exactly( std::size_t count )
|
||||||
{
|
{
|
||||||
this->e_->invoke( boost::make_shared< detail::exactly >( count ) );
|
this->e_->invoke(
|
||||||
return *this;
|
boost::make_shared< detail::exactly >( count ) );
|
||||||
}
|
return *this;
|
||||||
wrapper at_least( std::size_t min )
|
}
|
||||||
{
|
wrapper at_least( std::size_t min )
|
||||||
this->e_->invoke( boost::make_shared< detail::at_least >( min ) );
|
{
|
||||||
return *this;
|
this->e_->invoke(
|
||||||
}
|
boost::make_shared< detail::at_least >( min ) );
|
||||||
wrapper at_most( std::size_t max )
|
return *this;
|
||||||
{
|
}
|
||||||
this->e_->invoke( boost::make_shared< detail::at_most >( max ) );
|
wrapper at_most( std::size_t max )
|
||||||
return *this;
|
{
|
||||||
}
|
this->e_->invoke(
|
||||||
wrapper between( std::size_t min, std::size_t max )
|
boost::make_shared< detail::at_most >( max ) );
|
||||||
{
|
return *this;
|
||||||
this->e_->invoke( boost::make_shared< detail::between >( min, max ) );
|
}
|
||||||
return *this;
|
wrapper between( std::size_t min, std::size_t max )
|
||||||
}
|
{
|
||||||
|
this->e_->invoke(
|
||||||
#ifndef MOCK_NUM_ARGS_0
|
boost::make_shared< detail::between >( min, max ) );
|
||||||
template<
|
return *this;
|
||||||
BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, typename Constraint_)
|
}
|
||||||
>
|
|
||||||
wrapper with(
|
#ifndef MOCK_NUM_ARGS_0
|
||||||
BOOST_PP_ENUM_BINARY_PARAMS(MOCK_NUM_ARGS, Constraint_, c) )
|
template<
|
||||||
{
|
BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, typename Constraint_)
|
||||||
this->e_->with(
|
>
|
||||||
BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, c) );
|
wrapper with(
|
||||||
return *this;
|
BOOST_PP_ENUM_BINARY_PARAMS(MOCK_NUM_ARGS, Constraint_, c) )
|
||||||
}
|
{
|
||||||
#if MOCK_NUM_ARGS > 1
|
this->e_->with(
|
||||||
template< typename Constraint >
|
BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, c) );
|
||||||
wrapper with( const Constraint& c )
|
return *this;
|
||||||
{
|
}
|
||||||
this->e_->with( c );
|
#if MOCK_NUM_ARGS > 1
|
||||||
return *this;
|
template< typename Constraint >
|
||||||
}
|
wrapper with( const Constraint& c )
|
||||||
#endif
|
{
|
||||||
#endif
|
this->e_->with( c );
|
||||||
|
return *this;
|
||||||
#define MOCK_FUNCTION_IN_ADD(z, n, d) \
|
}
|
||||||
this->e_->add( s##n );
|
#endif
|
||||||
|
#endif
|
||||||
#define MOCK_FUNCTION_IN(z, n, d) \
|
|
||||||
wrapper in( BOOST_PP_ENUM_PARAMS(n, sequence& s) ) \
|
#define MOCK_FUNCTION_IN_ADD(z, n, d) \
|
||||||
{ \
|
this->e_->add( s##n );
|
||||||
BOOST_PP_REPEAT(n, MOCK_FUNCTION_IN_ADD, _) \
|
|
||||||
return *this; \
|
#define MOCK_FUNCTION_IN(z, n, d) \
|
||||||
}
|
wrapper in( BOOST_PP_ENUM_PARAMS(n, sequence& s) ) \
|
||||||
|
{ \
|
||||||
BOOST_PP_REPEAT(MOCK_MAX_SEQUENCES,
|
BOOST_PP_REPEAT(n, MOCK_FUNCTION_IN_ADD, _) \
|
||||||
MOCK_FUNCTION_IN, _)
|
return *this; \
|
||||||
|
}
|
||||||
#undef MOCK_FUNCTION_IN
|
|
||||||
#undef MOCK_FUNCTION_IN_ADD
|
BOOST_PP_REPEAT(MOCK_MAX_SEQUENCES,
|
||||||
|
MOCK_FUNCTION_IN, _)
|
||||||
template< typename TT >
|
|
||||||
void calls( TT t )
|
#undef MOCK_FUNCTION_IN
|
||||||
{
|
#undef MOCK_FUNCTION_IN_ADD
|
||||||
this->e_->calls( t );
|
|
||||||
}
|
template< typename TT >
|
||||||
template< typename TT >
|
void calls( TT t )
|
||||||
void throws( TT t )
|
{
|
||||||
{
|
this->e_->calls( t );
|
||||||
this->e_->throws( t );
|
}
|
||||||
}
|
template< typename TT >
|
||||||
template< typename TT >
|
void throws( TT t )
|
||||||
void moves( TT t )
|
{
|
||||||
{
|
this->e_->throws( t );
|
||||||
this->e_->moves( t );
|
}
|
||||||
}
|
template< typename TT >
|
||||||
|
void moves( TT t )
|
||||||
lock lock_;
|
{
|
||||||
};
|
this->e_->moves( t );
|
||||||
|
}
|
||||||
public:
|
|
||||||
typedef wrapper wrapper_type;
|
lock lock_;
|
||||||
|
};
|
||||||
wrapper expect( const char* file, int line )
|
|
||||||
{
|
public:
|
||||||
lock _( mutex_ );
|
typedef wrapper wrapper_type;
|
||||||
expectations_.push_back( expectation_type( file, line ) );
|
|
||||||
valid_ = true;
|
wrapper expect( const char* file, int line )
|
||||||
return wrapper( mutex_, expectations_.back() );
|
{
|
||||||
}
|
lock _( mutex_ );
|
||||||
wrapper expect()
|
expectations_.push_back( expectation_type( file, line ) );
|
||||||
{
|
valid_ = true;
|
||||||
lock _( mutex_ );
|
return wrapper( mutex_, expectations_.back() );
|
||||||
expectations_.push_back( expectation_type() );
|
}
|
||||||
valid_ = true;
|
wrapper expect()
|
||||||
return wrapper( mutex_, expectations_.back() );
|
{
|
||||||
}
|
lock _( mutex_ );
|
||||||
|
expectations_.push_back( expectation_type() );
|
||||||
R operator()(
|
valid_ = true;
|
||||||
BOOST_PP_ENUM_BINARY_PARAMS(MOCK_NUM_ARGS, T, t) ) const
|
return wrapper( mutex_, expectations_.back() );
|
||||||
{
|
}
|
||||||
lock _( mutex_ );
|
|
||||||
valid_ = false;
|
R operator()(
|
||||||
for( expectations_cit it = expectations_.begin();
|
BOOST_PP_ENUM_BINARY_PARAMS(MOCK_NUM_ARGS, T, t) ) const
|
||||||
it != expectations_.end(); ++it )
|
{
|
||||||
if( it->is_valid(
|
lock _( mutex_ );
|
||||||
BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, t) ) )
|
valid_ = false;
|
||||||
{
|
for( expectations_cit it = expectations_.begin();
|
||||||
if( ! it->invoke() )
|
it != expectations_.end(); ++it )
|
||||||
{
|
if( it->is_valid(
|
||||||
error_type::fail( "sequence failed",
|
BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, t) ) )
|
||||||
MOCK_FUNCTION_CONTEXT, it->file(), it->line() );
|
{
|
||||||
return error_type::abort();
|
if( ! it->invoke() )
|
||||||
}
|
{
|
||||||
if( ! it->valid() )
|
error_type::fail( "sequence failed",
|
||||||
{
|
MOCK_FUNCTION_CONTEXT, it->file(), it->line() );
|
||||||
error_type::fail( "missing action",
|
return error_type::abort();
|
||||||
MOCK_FUNCTION_CONTEXT, it->file(), it->line() );
|
}
|
||||||
return error_type::abort();
|
if( ! it->valid() )
|
||||||
}
|
{
|
||||||
valid_ = true;
|
error_type::fail( "missing action",
|
||||||
error_type::call(
|
MOCK_FUNCTION_CONTEXT, it->file(), it->line() );
|
||||||
MOCK_FUNCTION_CONTEXT, it->file(), it->line() );
|
return error_type::abort();
|
||||||
if( it->functor() )
|
}
|
||||||
return it->functor()(
|
valid_ = true;
|
||||||
BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, t) );
|
error_type::call(
|
||||||
return it->trigger();
|
MOCK_FUNCTION_CONTEXT, it->file(), it->line() );
|
||||||
}
|
if( it->functor() )
|
||||||
error_type::fail( "unexpected call", MOCK_FUNCTION_CONTEXT );
|
return it->functor()(
|
||||||
return error_type::abort();
|
BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, t) );
|
||||||
}
|
return it->trigger();
|
||||||
|
}
|
||||||
void add( context& c, const void* p,
|
error_type::fail( "unexpected call", MOCK_FUNCTION_CONTEXT );
|
||||||
boost::unit_test::const_string instance,
|
return error_type::abort();
|
||||||
boost::optional< type_name > type,
|
}
|
||||||
boost::unit_test::const_string name )
|
|
||||||
{
|
void add( context& c, const void* p,
|
||||||
lock _( mutex_ );
|
boost::unit_test::const_string instance,
|
||||||
if( ! context_ )
|
boost::optional< type_name > type,
|
||||||
c.add( *this );
|
boost::unit_test::const_string name )
|
||||||
c.add( p, *this, instance, type, name );
|
{
|
||||||
context_ = &c;
|
lock _( mutex_ );
|
||||||
}
|
if( ! context_ )
|
||||||
|
c.add( *this );
|
||||||
friend std::ostream& operator<<(
|
c.add( p, *this, instance, type, name );
|
||||||
std::ostream& s, const function_impl& impl )
|
context_ = &c;
|
||||||
{
|
}
|
||||||
lock _( impl.mutex_ );
|
|
||||||
return s << lazy_context( &impl ) << lazy_expectations( &impl );
|
friend std::ostream& operator<<(
|
||||||
}
|
std::ostream& s, const function_impl& impl )
|
||||||
|
{
|
||||||
struct lazy_context
|
lock _( impl.mutex_ );
|
||||||
{
|
return s << lazy_context( &impl ) << lazy_expectations( &impl );
|
||||||
lazy_context( const function_impl* impl )
|
}
|
||||||
: impl_( impl )
|
|
||||||
{}
|
struct lazy_context
|
||||||
friend std::ostream& operator<<(
|
{
|
||||||
std::ostream& s, const lazy_context& c )
|
lazy_context( const function_impl* impl )
|
||||||
{
|
: impl_( impl )
|
||||||
if( c.impl_->context_ )
|
{}
|
||||||
c.impl_->context_->serialize( s, *c.impl_ );
|
friend std::ostream& operator<<(
|
||||||
else
|
std::ostream& s, const lazy_context& c )
|
||||||
s << '?';
|
{
|
||||||
return s;
|
if( c.impl_->context_ )
|
||||||
}
|
c.impl_->context_->serialize( s, *c.impl_ );
|
||||||
const function_impl* impl_;
|
else
|
||||||
};
|
s << '?';
|
||||||
|
return s;
|
||||||
struct lazy_expectations
|
}
|
||||||
{
|
const function_impl* impl_;
|
||||||
lazy_expectations( const function_impl* impl )
|
};
|
||||||
: impl_( impl )
|
|
||||||
{}
|
struct lazy_expectations
|
||||||
friend std::ostream& operator<<(
|
{
|
||||||
std::ostream& s, const lazy_expectations& e )
|
lazy_expectations( const function_impl* impl )
|
||||||
{
|
: impl_( impl )
|
||||||
for( expectations_cit it = e.impl_->expectations_.begin();
|
{}
|
||||||
it != e.impl_->expectations_.end(); ++it )
|
friend std::ostream& operator<<(
|
||||||
s << std::endl << *it;
|
std::ostream& s, const lazy_expectations& e )
|
||||||
return s;
|
{
|
||||||
}
|
for( expectations_cit it = e.impl_->expectations_.begin();
|
||||||
const function_impl* impl_;
|
it != e.impl_->expectations_.end(); ++it )
|
||||||
};
|
s << std::endl << *it;
|
||||||
|
return s;
|
||||||
typedef std::list< expectation_type > expectations_type;
|
}
|
||||||
typedef typename expectations_type::const_iterator expectations_cit;
|
const function_impl* impl_;
|
||||||
|
};
|
||||||
expectations_type expectations_;
|
|
||||||
context* context_;
|
typedef std::list< expectation_type > expectations_type;
|
||||||
mutable bool valid_;
|
typedef typename expectations_type::const_iterator expectations_cit;
|
||||||
const boost::shared_ptr< mutex > mutex_;
|
|
||||||
};
|
expectations_type expectations_;
|
||||||
}
|
context* context_;
|
||||||
} // mock
|
mutable bool valid_;
|
||||||
|
const boost::shared_ptr< mutex > mutex_;
|
||||||
#undef MOCK_FUNCTION_FORMAT
|
};
|
||||||
#undef MOCK_FUNCTION_CONTEXT
|
}
|
||||||
|
} // mock
|
||||||
|
|
||||||
|
#undef MOCK_FUNCTION_FORMAT
|
||||||
|
#undef MOCK_FUNCTION_CONTEXT
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
// http://turtle.sourceforge.net
|
// http://turtle.sourceforge.net
|
||||||
//
|
//
|
||||||
// Copyright Mathieu Champlon 2012
|
// Copyright Mathieu Champlon 2012
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#define MOCK_NUM_ARGS BOOST_PP_ITERATION()
|
#define MOCK_NUM_ARGS BOOST_PP_ITERATION()
|
||||||
#include "function_template.hpp"
|
#include "function_template.hpp"
|
||||||
#undef MOCK_NUM_ARGS
|
#undef MOCK_NUM_ARGS
|
||||||
|
|
@ -1,111 +1,111 @@
|
||||||
// http://turtle.sourceforge.net
|
// http://turtle.sourceforge.net
|
||||||
//
|
//
|
||||||
// Copyright Mathieu Champlon 2008
|
// Copyright Mathieu Champlon 2008
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#include "function_impl_template.hpp"
|
#include "function_impl_template.hpp"
|
||||||
|
|
||||||
#define MOCK_FUNCTION_CALL(z, n, d ) \
|
#define MOCK_FUNCTION_CALL(z, n, d ) \
|
||||||
BOOST_PP_COMMA_IF(n) typename \
|
BOOST_PP_COMMA_IF(n) typename \
|
||||||
boost::call_traits< T##n >::param_type
|
boost::call_traits< T##n >::param_type
|
||||||
|
|
||||||
#define MOCK_FUNCTION_PARAM(z, n, d) \
|
#define MOCK_FUNCTION_PARAM(z, n, d) \
|
||||||
MOCK_FUNCTION_CALL(z, n, d) t##n
|
MOCK_FUNCTION_CALL(z, n, d) t##n
|
||||||
|
|
||||||
namespace mock
|
namespace mock
|
||||||
{
|
{
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
template< typename Signature > class function;
|
template< typename Signature > class function;
|
||||||
|
|
||||||
template< typename R
|
template< typename R
|
||||||
BOOST_PP_ENUM_TRAILING_PARAMS(MOCK_NUM_ARGS, typename T) >
|
BOOST_PP_ENUM_TRAILING_PARAMS(MOCK_NUM_ARGS, typename T) >
|
||||||
class function< R ( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) ) >
|
class function< R ( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, T) ) >
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef R result_type;
|
typedef R result_type;
|
||||||
|
|
||||||
template< typename Args >
|
template< typename Args >
|
||||||
struct sig
|
struct sig
|
||||||
{
|
{
|
||||||
typedef R type;
|
typedef R type;
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef function_impl<
|
typedef function_impl<
|
||||||
R ( BOOST_PP_REPEAT(MOCK_NUM_ARGS, MOCK_FUNCTION_CALL, _) )
|
R ( BOOST_PP_REPEAT(MOCK_NUM_ARGS, MOCK_FUNCTION_CALL, _) )
|
||||||
> impl_type;
|
> impl_type;
|
||||||
typedef typename impl_type::wrapper_type expectation_type;
|
typedef typename impl_type::wrapper_type expectation_type;
|
||||||
typedef typename impl_type::error_type error_type;
|
typedef typename impl_type::error_type error_type;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
function()
|
function()
|
||||||
: impl_( boost::make_shared< impl_type >() )
|
: impl_( boost::make_shared< impl_type >() )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
bool verify() const
|
bool verify() const
|
||||||
{
|
{
|
||||||
return impl_->verify();
|
return impl_->verify();
|
||||||
}
|
}
|
||||||
bool verify( const char* file, int line ) const
|
bool verify( const char* file, int line ) const
|
||||||
{
|
{
|
||||||
error_type::pass( file, line );
|
error_type::pass( file, line );
|
||||||
return impl_->verify();
|
return impl_->verify();
|
||||||
}
|
}
|
||||||
void reset()
|
void reset()
|
||||||
{
|
{
|
||||||
impl_->reset();
|
impl_->reset();
|
||||||
}
|
}
|
||||||
void reset( const char* file, int line )
|
void reset( const char* file, int line )
|
||||||
{
|
{
|
||||||
error_type::pass( file, line );
|
error_type::pass( file, line );
|
||||||
impl_->reset();
|
impl_->reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
expectation_type expect( const char* file, int line )
|
expectation_type expect( const char* file, int line )
|
||||||
{
|
{
|
||||||
error_type::pass( file, line );
|
error_type::pass( file, line );
|
||||||
return impl_->expect( file, line );
|
return impl_->expect( file, line );
|
||||||
}
|
}
|
||||||
expectation_type expect()
|
expectation_type expect()
|
||||||
{
|
{
|
||||||
return impl_->expect();
|
return impl_->expect();
|
||||||
}
|
}
|
||||||
|
|
||||||
R operator()(
|
R operator()(
|
||||||
BOOST_PP_REPEAT(MOCK_NUM_ARGS, MOCK_FUNCTION_PARAM, _) ) const
|
BOOST_PP_REPEAT(MOCK_NUM_ARGS, MOCK_FUNCTION_PARAM, _) ) const
|
||||||
{
|
{
|
||||||
return (*impl_)( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, t) );
|
return (*impl_)( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, t) );
|
||||||
}
|
}
|
||||||
|
|
||||||
friend std::ostream& operator<<( std::ostream& s, const function& f )
|
friend std::ostream& operator<<( std::ostream& s, const function& f )
|
||||||
{
|
{
|
||||||
return s << *f.impl_;
|
return s << *f.impl_;
|
||||||
}
|
}
|
||||||
|
|
||||||
function& operator()( context& c,
|
function& operator()( context& c,
|
||||||
boost::unit_test::const_string instance )
|
boost::unit_test::const_string instance )
|
||||||
{
|
{
|
||||||
impl_->add( c, impl_.get(), instance, boost::none, "" );
|
impl_->add( c, impl_.get(), instance, boost::none, "" );
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void configure( context& c, const void* p,
|
void configure( context& c, const void* p,
|
||||||
boost::unit_test::const_string instance,
|
boost::unit_test::const_string instance,
|
||||||
boost::optional< type_name > type,
|
boost::optional< type_name > type,
|
||||||
boost::unit_test::const_string name ) const
|
boost::unit_test::const_string name ) const
|
||||||
{
|
{
|
||||||
impl_->add( c, p, instance, type, name );
|
impl_->add( c, p, instance, type, name );
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
boost::shared_ptr< impl_type > impl_;
|
boost::shared_ptr< impl_type > impl_;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
} // mock
|
} // mock
|
||||||
|
|
||||||
#undef MOCK_FUNCTION_CALL
|
#undef MOCK_FUNCTION_CALL
|
||||||
#undef MOCK_FUNCTION_PARAM
|
#undef MOCK_FUNCTION_PARAM
|
||||||
|
|
@ -1,52 +1,52 @@
|
||||||
// http://turtle.sourceforge.net
|
// http://turtle.sourceforge.net
|
||||||
//
|
//
|
||||||
// Copyright Mathieu Champlon 2012
|
// Copyright Mathieu Champlon 2012
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#ifndef MOCK_FUNCTOR_HPP_INCLUDED
|
#ifndef MOCK_FUNCTOR_HPP_INCLUDED
|
||||||
#define MOCK_FUNCTOR_HPP_INCLUDED
|
#define MOCK_FUNCTOR_HPP_INCLUDED
|
||||||
|
|
||||||
#include "../config.hpp"
|
#include "../config.hpp"
|
||||||
#include "function.hpp"
|
#include "function.hpp"
|
||||||
#include "mutex.hpp"
|
#include "mutex.hpp"
|
||||||
|
|
||||||
namespace mock
|
namespace mock
|
||||||
{
|
{
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
class functor_mutex_t :
|
class functor_mutex_t :
|
||||||
public boost::unit_test::singleton< functor_mutex_t >,
|
public boost::unit_test::singleton< functor_mutex_t >,
|
||||||
public mutex
|
public mutex
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
BOOST_TEST_SINGLETON_CONS( functor_mutex_t );
|
BOOST_TEST_SINGLETON_CONS( functor_mutex_t );
|
||||||
};
|
};
|
||||||
BOOST_TEST_SINGLETON_INST( functor_mutex )
|
BOOST_TEST_SINGLETON_INST( functor_mutex )
|
||||||
|
|
||||||
template< typename Signature >
|
template< typename Signature >
|
||||||
struct functor : function< Signature >
|
struct functor : function< Signature >
|
||||||
{
|
{
|
||||||
functor()
|
functor()
|
||||||
{
|
{
|
||||||
scoped_lock _( functor_mutex );
|
scoped_lock _( functor_mutex );
|
||||||
static functor* f = 0;
|
static functor* f = 0;
|
||||||
if( f )
|
if( f )
|
||||||
{
|
{
|
||||||
*this = *f;
|
*this = *f;
|
||||||
f = 0;
|
f = 0;
|
||||||
functor_mutex.unlock();
|
functor_mutex.unlock();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
functor_mutex.lock();
|
functor_mutex.lock();
|
||||||
f = this;
|
f = this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
} // mock
|
} // mock
|
||||||
|
|
||||||
#endif // MOCK_FUNCTOR_HPP_INCLUDED
|
#endif // MOCK_FUNCTOR_HPP_INCLUDED
|
||||||
|
|
@ -1,64 +1,64 @@
|
||||||
// http://turtle.sourceforge.net
|
// http://turtle.sourceforge.net
|
||||||
//
|
//
|
||||||
// Copyright Mathieu Champlon 2011
|
// Copyright Mathieu Champlon 2011
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#ifndef MOCK_GROUP_HPP_INCLUDED
|
#ifndef MOCK_GROUP_HPP_INCLUDED
|
||||||
#define MOCK_GROUP_HPP_INCLUDED
|
#define MOCK_GROUP_HPP_INCLUDED
|
||||||
|
|
||||||
#include "../config.hpp"
|
#include "../config.hpp"
|
||||||
#include "verifiable.hpp"
|
#include "verifiable.hpp"
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace mock
|
namespace mock
|
||||||
{
|
{
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
class group
|
class group
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void add( verifiable& v )
|
void add( verifiable& v )
|
||||||
{
|
{
|
||||||
verifiables_.push_back( &v );
|
verifiables_.push_back( &v );
|
||||||
}
|
}
|
||||||
void remove( verifiable& v )
|
void remove( verifiable& v )
|
||||||
{
|
{
|
||||||
verifiables_.erase(
|
verifiables_.erase(
|
||||||
std::remove( verifiables_.begin(), verifiables_.end(), &v ),
|
std::remove( verifiables_.begin(), verifiables_.end(), &v ),
|
||||||
verifiables_.end() );
|
verifiables_.end() );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool verify() const
|
bool verify() const
|
||||||
{
|
{
|
||||||
bool valid = true;
|
bool valid = true;
|
||||||
for( verifiables_cit it = verifiables_.begin();
|
for( verifiables_cit it = verifiables_.begin();
|
||||||
it != verifiables_.end(); ++it )
|
it != verifiables_.end(); ++it )
|
||||||
if( ! (*it)->verify() )
|
if( ! (*it)->verify() )
|
||||||
valid = false;
|
valid = false;
|
||||||
return valid;
|
return valid;
|
||||||
}
|
}
|
||||||
void reset()
|
void reset()
|
||||||
{
|
{
|
||||||
const verifiables_t verifiables = verifiables_;
|
const verifiables_t verifiables = verifiables_;
|
||||||
for( verifiables_cit it = verifiables.begin();
|
for( verifiables_cit it = verifiables.begin();
|
||||||
it != verifiables.end(); ++it )
|
it != verifiables.end(); ++it )
|
||||||
if( std::find( verifiables_.begin(), verifiables_.end(), *it )
|
if( std::find( verifiables_.begin(), verifiables_.end(), *it )
|
||||||
!= verifiables_.end() )
|
!= verifiables_.end() )
|
||||||
(*it)->reset();
|
(*it)->reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef std::vector< verifiable* > verifiables_t;
|
typedef std::vector< verifiable* > verifiables_t;
|
||||||
typedef verifiables_t::const_iterator verifiables_cit;
|
typedef verifiables_t::const_iterator verifiables_cit;
|
||||||
|
|
||||||
verifiables_t verifiables_;
|
verifiables_t verifiables_;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
} // mock
|
} // mock
|
||||||
|
|
||||||
#endif // MOCK_GROUP_HPP_INCLUDED
|
#endif // MOCK_GROUP_HPP_INCLUDED
|
||||||
|
|
@ -1,170 +1,170 @@
|
||||||
// http://turtle.sourceforge.net
|
// http://turtle.sourceforge.net
|
||||||
//
|
//
|
||||||
// Copyright Mathieu Champlon 2008
|
// Copyright Mathieu Champlon 2008
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#ifndef MOCK_INVOCATION_HPP_INCLUDED
|
#ifndef MOCK_INVOCATION_HPP_INCLUDED
|
||||||
#define MOCK_INVOCATION_HPP_INCLUDED
|
#define MOCK_INVOCATION_HPP_INCLUDED
|
||||||
|
|
||||||
#include "../config.hpp"
|
#include "../config.hpp"
|
||||||
#include <boost/noncopyable.hpp>
|
#include <boost/noncopyable.hpp>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
namespace mock
|
namespace mock
|
||||||
{
|
{
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
class invocation : private boost::noncopyable
|
class invocation : private boost::noncopyable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
invocation() {}
|
invocation() {}
|
||||||
virtual ~invocation() {}
|
virtual ~invocation() {}
|
||||||
|
|
||||||
virtual bool invoke() = 0;
|
virtual bool invoke() = 0;
|
||||||
virtual bool verify() const = 0;
|
virtual bool verify() const = 0;
|
||||||
|
|
||||||
virtual bool exhausted() const = 0;
|
virtual bool exhausted() const = 0;
|
||||||
|
|
||||||
friend std::ostream& operator<<( std::ostream& s, const invocation& i )
|
friend std::ostream& operator<<( std::ostream& s, const invocation& i )
|
||||||
{
|
{
|
||||||
return i.serialize( s );
|
return i.serialize( s );
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual std::ostream& serialize( std::ostream& s ) const = 0;
|
virtual std::ostream& serialize( std::ostream& s ) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class between : public invocation
|
class between : public invocation
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
between( std::size_t min, std::size_t max )
|
between( std::size_t min, std::size_t max )
|
||||||
: min_( min )
|
: min_( min )
|
||||||
, max_( max )
|
, max_( max )
|
||||||
, count_( 0 )
|
, count_( 0 )
|
||||||
{
|
{
|
||||||
if( min > max )
|
if( min > max )
|
||||||
throw std::invalid_argument( "'min' > 'max'" );
|
throw std::invalid_argument( "'min' > 'max'" );
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool invoke()
|
virtual bool invoke()
|
||||||
{
|
{
|
||||||
if( count_ == max_ )
|
if( count_ == max_ )
|
||||||
return false;
|
return false;
|
||||||
++count_;
|
++count_;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool exhausted() const
|
virtual bool exhausted() const
|
||||||
{
|
{
|
||||||
return count_ >= max_;
|
return count_ >= max_;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool verify() const
|
virtual bool verify() const
|
||||||
{
|
{
|
||||||
return min_ <= count_ && count_ <= max_;
|
return min_ <= count_ && count_ <= max_;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
const std::size_t min_, max_;
|
const std::size_t min_, max_;
|
||||||
std::size_t count_;
|
std::size_t count_;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual std::ostream& serialize( std::ostream& s ) const
|
virtual std::ostream& serialize( std::ostream& s ) const
|
||||||
{
|
{
|
||||||
return s << "between( " << count_
|
return s << "between( " << count_
|
||||||
<< "/[" << min_ << ',' << max_ << "] )";
|
<< "/[" << min_ << ',' << max_ << "] )";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class exactly : public between
|
class exactly : public between
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit exactly( std::size_t count )
|
explicit exactly( std::size_t count )
|
||||||
: between( count, count )
|
: between( count, count )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual std::ostream& serialize( std::ostream& s ) const
|
virtual std::ostream& serialize( std::ostream& s ) const
|
||||||
{
|
{
|
||||||
return s << "exactly( " << count_ << '/' << max_ << " )";
|
return s << "exactly( " << count_ << '/' << max_ << " )";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class never : public exactly
|
class never : public exactly
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
never()
|
never()
|
||||||
: exactly( 0 )
|
: exactly( 0 )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual std::ostream& serialize( std::ostream& s ) const
|
virtual std::ostream& serialize( std::ostream& s ) const
|
||||||
{
|
{
|
||||||
return s << "never()";
|
return s << "never()";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class once : public exactly
|
class once : public exactly
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
once()
|
once()
|
||||||
: exactly( 1 )
|
: exactly( 1 )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual std::ostream& serialize( std::ostream& s ) const
|
virtual std::ostream& serialize( std::ostream& s ) const
|
||||||
{
|
{
|
||||||
return s << "once()";
|
return s << "once()";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class at_least : public between
|
class at_least : public between
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit at_least( std::size_t min )
|
explicit at_least( std::size_t min )
|
||||||
: between( min, (std::numeric_limits< std::size_t >::max)() )
|
: between( min, (std::numeric_limits< std::size_t >::max)() )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual std::ostream& serialize( std::ostream& s ) const
|
virtual std::ostream& serialize( std::ostream& s ) const
|
||||||
{
|
{
|
||||||
return s << "at_least( " << count_ << '/' << min_ << " )";
|
return s << "at_least( " << count_ << '/' << min_ << " )";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class at_most : public between
|
class at_most : public between
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit at_most( std::size_t max )
|
explicit at_most( std::size_t max )
|
||||||
: between( 0, max )
|
: between( 0, max )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual std::ostream& serialize( std::ostream& s ) const
|
virtual std::ostream& serialize( std::ostream& s ) const
|
||||||
{
|
{
|
||||||
return s << "at_most( " << count_ << '/' << max_ << " )";
|
return s << "at_most( " << count_ << '/' << max_ << " )";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class unlimited : public at_least
|
class unlimited : public at_least
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
unlimited()
|
unlimited()
|
||||||
: at_least( 0 )
|
: at_least( 0 )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual std::ostream& serialize( std::ostream& s ) const
|
virtual std::ostream& serialize( std::ostream& s ) const
|
||||||
{
|
{
|
||||||
return s << "unlimited()";
|
return s << "unlimited()";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
} // mock
|
} // mock
|
||||||
|
|
||||||
#endif // MOCK_INVOCATION_HPP_INCLUDED
|
#endif // MOCK_INVOCATION_HPP_INCLUDED
|
||||||
|
|
@ -1,62 +1,62 @@
|
||||||
// http://turtle.sourceforge.net
|
// http://turtle.sourceforge.net
|
||||||
//
|
//
|
||||||
// Copyright Mathieu Champlon 2009
|
// Copyright Mathieu Champlon 2009
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#ifndef MOCK_IS_FUNCTOR_HPP_INCLUDED
|
#ifndef MOCK_IS_FUNCTOR_HPP_INCLUDED
|
||||||
#define MOCK_IS_FUNCTOR_HPP_INCLUDED
|
#define MOCK_IS_FUNCTOR_HPP_INCLUDED
|
||||||
|
|
||||||
#include "../config.hpp"
|
#include "../config.hpp"
|
||||||
#include <boost/function_types/is_callable_builtin.hpp>
|
#include <boost/function_types/is_callable_builtin.hpp>
|
||||||
#include <boost/type_traits/detail/yes_no_type.hpp>
|
#include <boost/type_traits/detail/yes_no_type.hpp>
|
||||||
#include <boost/utility/declval.hpp>
|
#include <boost/utility/declval.hpp>
|
||||||
#include <boost/mpl/has_xxx.hpp>
|
#include <boost/mpl/has_xxx.hpp>
|
||||||
#include <boost/mpl/or.hpp>
|
#include <boost/mpl/or.hpp>
|
||||||
|
|
||||||
namespace mock
|
namespace mock
|
||||||
{
|
{
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
BOOST_MPL_HAS_XXX_TRAIT_DEF( result_type )
|
BOOST_MPL_HAS_XXX_TRAIT_DEF( result_type )
|
||||||
BOOST_MPL_HAS_XXX_TEMPLATE_DEF( sig )
|
BOOST_MPL_HAS_XXX_TEMPLATE_DEF( sig )
|
||||||
BOOST_MPL_HAS_XXX_TEMPLATE_DEF( result )
|
BOOST_MPL_HAS_XXX_TEMPLATE_DEF( result )
|
||||||
|
|
||||||
#ifdef MOCK_DECLTYPE
|
#ifdef MOCK_DECLTYPE
|
||||||
|
|
||||||
template< typename F, typename P >
|
template< typename F, typename P >
|
||||||
struct is_callable
|
struct is_callable
|
||||||
{
|
{
|
||||||
typedef boost::type_traits::yes_type yes_type;
|
typedef boost::type_traits::yes_type yes_type;
|
||||||
typedef boost::type_traits::no_type no_type;
|
typedef boost::type_traits::no_type no_type;
|
||||||
|
|
||||||
template< typename T >
|
template< typename T >
|
||||||
static yes_type check(
|
static yes_type check(
|
||||||
decltype( boost::declval< T >()( boost::declval< P >() ) )* );
|
decltype( boost::declval< T >()( boost::declval< P >() ) )* );
|
||||||
template< typename T >
|
template< typename T >
|
||||||
static no_type check( ... );
|
static no_type check( ... );
|
||||||
|
|
||||||
typedef boost::mpl::bool_<
|
typedef boost::mpl::bool_<
|
||||||
sizeof( check< F >( 0 ) ) == sizeof( yes_type ) > type;
|
sizeof( check< F >( 0 ) ) == sizeof( yes_type ) > type;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MOCK_DECLTYPE
|
#endif // MOCK_DECLTYPE
|
||||||
|
|
||||||
template< typename T, typename P >
|
template< typename T, typename P >
|
||||||
struct is_functor
|
struct is_functor
|
||||||
: boost::mpl::or_<
|
: boost::mpl::or_<
|
||||||
boost::function_types::is_callable_builtin< T >,
|
boost::function_types::is_callable_builtin< T >,
|
||||||
#ifdef MOCK_DECLTYPE
|
#ifdef MOCK_DECLTYPE
|
||||||
is_callable< T, P >,
|
is_callable< T, P >,
|
||||||
#endif
|
#endif
|
||||||
has_result_type< T >,
|
has_result_type< T >,
|
||||||
has_result< T >,
|
has_result< T >,
|
||||||
has_sig< T >
|
has_sig< T >
|
||||||
>
|
>
|
||||||
{};
|
{};
|
||||||
}
|
}
|
||||||
} // mock
|
} // mock
|
||||||
|
|
||||||
#endif // MOCK_IS_FUNCTOR_HPP_INCLUDED
|
#endif // MOCK_IS_FUNCTOR_HPP_INCLUDED
|
||||||
|
|
@ -1,37 +1,37 @@
|
||||||
// http://turtle.sourceforge.net
|
// http://turtle.sourceforge.net
|
||||||
//
|
//
|
||||||
// Copyright Mathieu Champlon 2012
|
// Copyright Mathieu Champlon 2012
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
namespace mock
|
namespace mock
|
||||||
{
|
{
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
template< typename Signature > class matcher_base;
|
template< typename Signature > class matcher_base;
|
||||||
|
|
||||||
template<
|
template<
|
||||||
BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, typename Actual_) >
|
BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, typename Actual_) >
|
||||||
class matcher_base< void( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, Actual_) ) >
|
class matcher_base< void( BOOST_PP_ENUM_PARAMS(MOCK_NUM_ARGS, Actual_) ) >
|
||||||
: boost::noncopyable
|
: boost::noncopyable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~matcher_base() {}
|
virtual ~matcher_base() {}
|
||||||
|
|
||||||
virtual bool operator()(
|
virtual bool operator()(
|
||||||
BOOST_PP_ENUM_BINARY_PARAMS(MOCK_NUM_ARGS, Actual_, actual_) ) = 0;
|
BOOST_PP_ENUM_BINARY_PARAMS(MOCK_NUM_ARGS, Actual_, actual_) ) = 0;
|
||||||
|
|
||||||
friend std::ostream& operator<<(
|
friend std::ostream& operator<<(
|
||||||
std::ostream& s, const matcher_base& m )
|
std::ostream& s, const matcher_base& m )
|
||||||
{
|
{
|
||||||
m.serialize( s );
|
m.serialize( s );
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual void serialize( std::ostream& ) const = 0;
|
virtual void serialize( std::ostream& ) const = 0;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
} // mock
|
} // mock
|
||||||
|
|
@ -1,141 +1,141 @@
|
||||||
// http://turtle.sourceforge.net
|
// http://turtle.sourceforge.net
|
||||||
//
|
//
|
||||||
// Copyright Mathieu Champlon 2014
|
// Copyright Mathieu Champlon 2014
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#ifndef MOCK_MUTEX_HPP_INCLUDED
|
#ifndef MOCK_MUTEX_HPP_INCLUDED
|
||||||
#define MOCK_MUTEX_HPP_INCLUDED
|
#define MOCK_MUTEX_HPP_INCLUDED
|
||||||
|
|
||||||
#include "../config.hpp"
|
#include "../config.hpp"
|
||||||
#include <boost/test/utils/trivial_singleton.hpp>
|
#include <boost/test/utils/trivial_singleton.hpp>
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
|
|
||||||
#ifdef MOCK_THREAD_SAFE
|
#ifdef MOCK_THREAD_SAFE
|
||||||
|
|
||||||
#ifdef MOCK_HDR_MUTEX
|
#ifdef MOCK_HDR_MUTEX
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#else
|
#else
|
||||||
#include <boost/thread/recursive_mutex.hpp>
|
#include <boost/thread/recursive_mutex.hpp>
|
||||||
#include <boost/thread/lock_guard.hpp>
|
#include <boost/thread/lock_guard.hpp>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace mock
|
namespace mock
|
||||||
{
|
{
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
#ifdef MOCK_HDR_MUTEX
|
#ifdef MOCK_HDR_MUTEX
|
||||||
typedef std::recursive_mutex mutex;
|
typedef std::recursive_mutex mutex;
|
||||||
typedef std::lock_guard< mutex > scoped_lock;
|
typedef std::lock_guard< mutex > scoped_lock;
|
||||||
#else
|
#else
|
||||||
typedef boost::recursive_mutex mutex;
|
typedef boost::recursive_mutex mutex;
|
||||||
typedef boost::lock_guard< mutex > scoped_lock;
|
typedef boost::lock_guard< mutex > scoped_lock;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct lock
|
struct lock
|
||||||
{
|
{
|
||||||
lock( const boost::shared_ptr< mutex >& m )
|
lock( const boost::shared_ptr< mutex >& m )
|
||||||
: m_( m )
|
: m_( m )
|
||||||
{
|
{
|
||||||
m_->lock();
|
m_->lock();
|
||||||
}
|
}
|
||||||
lock( const lock& rhs )
|
lock( const lock& rhs )
|
||||||
{
|
{
|
||||||
m_.swap( rhs.m_ );
|
m_.swap( rhs.m_ );
|
||||||
}
|
}
|
||||||
~lock()
|
~lock()
|
||||||
{
|
{
|
||||||
if( m_ )
|
if( m_ )
|
||||||
m_->unlock();
|
m_->unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
lock& operator=( const lock& rhs );
|
lock& operator=( const lock& rhs );
|
||||||
|
|
||||||
mutable boost::shared_ptr< mutex > m_;
|
mutable boost::shared_ptr< mutex > m_;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
} // mock
|
} // mock
|
||||||
|
|
||||||
#else // MOCK_THREAD_SAFE
|
#else // MOCK_THREAD_SAFE
|
||||||
|
|
||||||
namespace mock
|
namespace mock
|
||||||
{
|
{
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
struct mutex
|
struct mutex
|
||||||
{
|
{
|
||||||
mutex()
|
mutex()
|
||||||
{}
|
{}
|
||||||
void lock()
|
void lock()
|
||||||
{}
|
{}
|
||||||
void unlock()
|
void unlock()
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
struct scoped_lock
|
struct scoped_lock
|
||||||
{
|
{
|
||||||
scoped_lock( mutex& )
|
scoped_lock( mutex& )
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
struct lock
|
struct lock
|
||||||
{
|
{
|
||||||
lock( const boost::shared_ptr< mutex >& )
|
lock( const boost::shared_ptr< mutex >& )
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
} // mock
|
} // mock
|
||||||
|
|
||||||
#endif // MOCK_THREAD_SAFE
|
#endif // MOCK_THREAD_SAFE
|
||||||
|
|
||||||
namespace mock
|
namespace mock
|
||||||
{
|
{
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
class error_mutex_t : public boost::unit_test::singleton< error_mutex_t >,
|
class error_mutex_t : public boost::unit_test::singleton< error_mutex_t >,
|
||||||
public mutex
|
public mutex
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
BOOST_TEST_SINGLETON_CONS( error_mutex_t );
|
BOOST_TEST_SINGLETON_CONS( error_mutex_t );
|
||||||
};
|
};
|
||||||
BOOST_TEST_SINGLETON_INST( error_mutex )
|
BOOST_TEST_SINGLETON_INST( error_mutex )
|
||||||
|
|
||||||
#ifdef BOOST_MSVC
|
#ifdef BOOST_MSVC
|
||||||
# pragma warning( push )
|
# pragma warning( push )
|
||||||
# pragma warning( disable: 4702 )
|
# pragma warning( disable: 4702 )
|
||||||
#endif
|
#endif
|
||||||
template< typename Result, typename Error >
|
template< typename Result, typename Error >
|
||||||
struct safe_error
|
struct safe_error
|
||||||
{
|
{
|
||||||
static Result abort()
|
static Result abort()
|
||||||
{
|
{
|
||||||
scoped_lock _( error_mutex );
|
scoped_lock _( error_mutex );
|
||||||
return Error::abort();
|
return Error::abort();
|
||||||
}
|
}
|
||||||
template< typename Context >
|
template< typename Context >
|
||||||
static void fail( const char* message, const Context& context,
|
static void fail( const char* message, const Context& context,
|
||||||
const char* file = "unknown location", int line = 0 )
|
const char* file = "unknown location", int line = 0 )
|
||||||
{
|
{
|
||||||
scoped_lock _( error_mutex );
|
scoped_lock _( error_mutex );
|
||||||
Error::fail( message, context, file, line );
|
Error::fail( message, context, file, line );
|
||||||
}
|
}
|
||||||
template< typename Context >
|
template< typename Context >
|
||||||
static void call( const Context& context, const char* file, int line )
|
static void call( const Context& context, const char* file, int line )
|
||||||
{
|
{
|
||||||
scoped_lock _( error_mutex );
|
scoped_lock _( error_mutex );
|
||||||
Error::call( context, file, line );
|
Error::call( context, file, line );
|
||||||
}
|
}
|
||||||
static void pass( const char* file, int line )
|
static void pass( const char* file, int line )
|
||||||
{
|
{
|
||||||
scoped_lock _( error_mutex );
|
scoped_lock _( error_mutex );
|
||||||
Error::pass( file, line );
|
Error::pass( file, line );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
#ifdef BOOST_MSVC
|
#ifdef BOOST_MSVC
|
||||||
# pragma warning( pop )
|
# pragma warning( pop )
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
} // mock
|
} // mock
|
||||||
|
|
||||||
#endif // MOCK_MUTEX_HPP_INCLUDED
|
#endif // MOCK_MUTEX_HPP_INCLUDED
|
||||||
|
|
@ -1,94 +1,94 @@
|
||||||
// http://turtle.sourceforge.net
|
// http://turtle.sourceforge.net
|
||||||
//
|
//
|
||||||
// Copyright Mathieu Champlon 2012
|
// Copyright Mathieu Champlon 2012
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#ifndef MOCK_OBJECT_IMPL_HPP_INCLUDED
|
#ifndef MOCK_OBJECT_IMPL_HPP_INCLUDED
|
||||||
#define MOCK_OBJECT_IMPL_HPP_INCLUDED
|
#define MOCK_OBJECT_IMPL_HPP_INCLUDED
|
||||||
|
|
||||||
#include "../config.hpp"
|
#include "../config.hpp"
|
||||||
#include "root.hpp"
|
#include "root.hpp"
|
||||||
#include "parent.hpp"
|
#include "parent.hpp"
|
||||||
#include "type_name.hpp"
|
#include "type_name.hpp"
|
||||||
#include "context.hpp"
|
#include "context.hpp"
|
||||||
#include "child.hpp"
|
#include "child.hpp"
|
||||||
#include "mutex.hpp"
|
#include "mutex.hpp"
|
||||||
#include <boost/test/utils/basic_cstring/basic_cstring.hpp>
|
#include <boost/test/utils/basic_cstring/basic_cstring.hpp>
|
||||||
#include <boost/enable_shared_from_this.hpp>
|
#include <boost/enable_shared_from_this.hpp>
|
||||||
#include <boost/make_shared.hpp>
|
#include <boost/make_shared.hpp>
|
||||||
#include <boost/optional.hpp>
|
#include <boost/optional.hpp>
|
||||||
|
|
||||||
namespace mock
|
namespace mock
|
||||||
{
|
{
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
class object_impl : public context, public verifiable,
|
class object_impl : public context, public verifiable,
|
||||||
public boost::enable_shared_from_this< object_impl >
|
public boost::enable_shared_from_this< object_impl >
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
object_impl()
|
object_impl()
|
||||||
: mutex_( boost::make_shared< mutex >() )
|
: mutex_( boost::make_shared< mutex >() )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
virtual void add( const void* /*p*/, verifiable& v,
|
virtual void add( const void* /*p*/, verifiable& v,
|
||||||
boost::unit_test::const_string instance,
|
boost::unit_test::const_string instance,
|
||||||
boost::optional< type_name > type,
|
boost::optional< type_name > type,
|
||||||
boost::unit_test::const_string name )
|
boost::unit_test::const_string name )
|
||||||
{
|
{
|
||||||
lock _( mutex_ );
|
lock _( mutex_ );
|
||||||
if( children_.empty() )
|
if( children_.empty() )
|
||||||
detail::root.add( *this );
|
detail::root.add( *this );
|
||||||
children_[ &v ].update( parent_, instance, type, name );
|
children_[ &v ].update( parent_, instance, type, name );
|
||||||
}
|
}
|
||||||
virtual void add( verifiable& v )
|
virtual void add( verifiable& v )
|
||||||
{
|
{
|
||||||
lock _( mutex_ );
|
lock _( mutex_ );
|
||||||
group_.add( v );
|
group_.add( v );
|
||||||
}
|
}
|
||||||
virtual void remove( verifiable& v )
|
virtual void remove( verifiable& v )
|
||||||
{
|
{
|
||||||
lock _( mutex_ );
|
lock _( mutex_ );
|
||||||
group_.remove( v );
|
group_.remove( v );
|
||||||
children_.erase( &v );
|
children_.erase( &v );
|
||||||
if( children_.empty() )
|
if( children_.empty() )
|
||||||
detail::root.remove( *this );
|
detail::root.remove( *this );
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void serialize( std::ostream& s, const verifiable& v ) const
|
virtual void serialize( std::ostream& s, const verifiable& v ) const
|
||||||
{
|
{
|
||||||
lock _( mutex_ );
|
lock _( mutex_ );
|
||||||
children_cit it = children_.find( &v );
|
children_cit it = children_.find( &v );
|
||||||
if( it != children_.end() )
|
if( it != children_.end() )
|
||||||
s << it->second;
|
s << it->second;
|
||||||
else
|
else
|
||||||
s << "?";
|
s << "?";
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool verify() const
|
virtual bool verify() const
|
||||||
{
|
{
|
||||||
lock _( mutex_ );
|
lock _( mutex_ );
|
||||||
return group_.verify();
|
return group_.verify();
|
||||||
}
|
}
|
||||||
virtual void reset()
|
virtual void reset()
|
||||||
{
|
{
|
||||||
lock _( mutex_ );
|
lock _( mutex_ );
|
||||||
boost::shared_ptr< object_impl > guard = shared_from_this();
|
boost::shared_ptr< object_impl > guard = shared_from_this();
|
||||||
group_.reset();
|
group_.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef std::map< const verifiable*, child > children_t;
|
typedef std::map< const verifiable*, child > children_t;
|
||||||
typedef children_t::const_iterator children_cit;
|
typedef children_t::const_iterator children_cit;
|
||||||
|
|
||||||
group group_;
|
group group_;
|
||||||
parent parent_;
|
parent parent_;
|
||||||
children_t children_;
|
children_t children_;
|
||||||
const boost::shared_ptr< mutex > mutex_;
|
const boost::shared_ptr< mutex > mutex_;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
} // mock
|
} // mock
|
||||||
|
|
||||||
#endif // MOCK_OBJECT_IMPL_HPP_INCLUDED
|
#endif // MOCK_OBJECT_IMPL_HPP_INCLUDED
|
||||||
|
|
@ -1,34 +1,34 @@
|
||||||
// http://turtle.sourceforge.net
|
// http://turtle.sourceforge.net
|
||||||
//
|
//
|
||||||
// Copyright Mathieu Champlon 2012
|
// Copyright Mathieu Champlon 2012
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#ifndef MOCK_PARAMETER_HPP_INCLUDED
|
#ifndef MOCK_PARAMETER_HPP_INCLUDED
|
||||||
#define MOCK_PARAMETER_HPP_INCLUDED
|
#define MOCK_PARAMETER_HPP_INCLUDED
|
||||||
|
|
||||||
#include "../config.hpp"
|
#include "../config.hpp"
|
||||||
#include <boost/function_types/parameter_types.hpp>
|
#include <boost/function_types/parameter_types.hpp>
|
||||||
#include <boost/function_types/function_arity.hpp>
|
#include <boost/function_types/function_arity.hpp>
|
||||||
#include <boost/mpl/at.hpp>
|
#include <boost/mpl/at.hpp>
|
||||||
|
|
||||||
namespace mock
|
namespace mock
|
||||||
{
|
{
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
template< typename Signature, int n >
|
template< typename Signature, int n >
|
||||||
struct parameter
|
struct parameter
|
||||||
{
|
{
|
||||||
typedef typename
|
typedef typename
|
||||||
boost::mpl::at_c<
|
boost::mpl::at_c<
|
||||||
typename
|
typename
|
||||||
boost::function_types::parameter_types< Signature >,
|
boost::function_types::parameter_types< Signature >,
|
||||||
n
|
n
|
||||||
>::type type;
|
>::type type;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
} // mock
|
} // mock
|
||||||
|
|
||||||
#endif // MOCK_PARAMETER_HPP_INCLUDED
|
#endif // MOCK_PARAMETER_HPP_INCLUDED
|
||||||
|
|
@ -1,46 +1,46 @@
|
||||||
// http://turtle.sourceforge.net
|
// http://turtle.sourceforge.net
|
||||||
//
|
//
|
||||||
// Copyright Mathieu Champlon 2011
|
// Copyright Mathieu Champlon 2011
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#ifndef MOCK_PARENT_HPP_INCLUDED
|
#ifndef MOCK_PARENT_HPP_INCLUDED
|
||||||
#define MOCK_PARENT_HPP_INCLUDED
|
#define MOCK_PARENT_HPP_INCLUDED
|
||||||
|
|
||||||
#include "../config.hpp"
|
#include "../config.hpp"
|
||||||
#include "type_name.hpp"
|
#include "type_name.hpp"
|
||||||
#include <boost/test/utils/basic_cstring/io.hpp>
|
#include <boost/test/utils/basic_cstring/io.hpp>
|
||||||
#include <boost/optional.hpp>
|
#include <boost/optional.hpp>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
|
|
||||||
namespace mock
|
namespace mock
|
||||||
{
|
{
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
class parent
|
class parent
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
parent()
|
parent()
|
||||||
{}
|
{}
|
||||||
parent( boost::unit_test::const_string instance,
|
parent( boost::unit_test::const_string instance,
|
||||||
boost::optional< type_name > type )
|
boost::optional< type_name > type )
|
||||||
: instance_( instance )
|
: instance_( instance )
|
||||||
, type_( type )
|
, type_( type )
|
||||||
{}
|
{}
|
||||||
friend std::ostream& operator<<( std::ostream& s, const parent& p )
|
friend std::ostream& operator<<( std::ostream& s, const parent& p )
|
||||||
{
|
{
|
||||||
s << p.instance_;
|
s << p.instance_;
|
||||||
if( p.type_ )
|
if( p.type_ )
|
||||||
s << *p.type_ << "::";
|
s << *p.type_ << "::";
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
boost::unit_test::const_string instance_;
|
boost::unit_test::const_string instance_;
|
||||||
boost::optional< type_name > type_;
|
boost::optional< type_name > type_;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
} // mock
|
} // mock
|
||||||
|
|
||||||
#endif // MOCK_PARENT_HPP_INCLUDED
|
#endif // MOCK_PARENT_HPP_INCLUDED
|
||||||
|
|
@ -1,138 +1,138 @@
|
||||||
// http://turtle.sourceforge.net
|
// http://turtle.sourceforge.net
|
||||||
//
|
//
|
||||||
// Copyright Mathieu Champlon 2008
|
// Copyright Mathieu Champlon 2008
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#ifndef MOCK_ROOT_HPP_INCLUDED
|
#ifndef MOCK_ROOT_HPP_INCLUDED
|
||||||
#define MOCK_ROOT_HPP_INCLUDED
|
#define MOCK_ROOT_HPP_INCLUDED
|
||||||
|
|
||||||
#include "../config.hpp"
|
#include "../config.hpp"
|
||||||
#include "parent.hpp"
|
#include "parent.hpp"
|
||||||
#include "group.hpp"
|
#include "group.hpp"
|
||||||
#include "context.hpp"
|
#include "context.hpp"
|
||||||
#include "child.hpp"
|
#include "child.hpp"
|
||||||
#include "mutex.hpp"
|
#include "mutex.hpp"
|
||||||
#include <boost/test/utils/trivial_singleton.hpp>
|
#include <boost/test/utils/trivial_singleton.hpp>
|
||||||
#include <boost/optional.hpp>
|
#include <boost/optional.hpp>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
namespace mock
|
namespace mock
|
||||||
{
|
{
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
class root_t : public boost::unit_test::singleton< root_t >, public context
|
class root_t : public boost::unit_test::singleton< root_t >, public context
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual void add( const void* p, verifiable& v,
|
virtual void add( const void* p, verifiable& v,
|
||||||
boost::unit_test::const_string instance,
|
boost::unit_test::const_string instance,
|
||||||
boost::optional< type_name > type,
|
boost::optional< type_name > type,
|
||||||
boost::unit_test::const_string name )
|
boost::unit_test::const_string name )
|
||||||
{
|
{
|
||||||
scoped_lock _( mutex_ );
|
scoped_lock _( mutex_ );
|
||||||
children_t::iterator it = children_.lower_bound( &v );
|
children_t::iterator it = children_.lower_bound( &v );
|
||||||
if( it == children_.end() ||
|
if( it == children_.end() ||
|
||||||
children_.key_comp()( &v, it->first ) )
|
children_.key_comp()( &v, it->first ) )
|
||||||
it = children_.insert( it,
|
it = children_.insert( it,
|
||||||
std::make_pair( &v, counter_child( parents_, p ) ) );
|
std::make_pair( &v, counter_child( parents_, p ) ) );
|
||||||
it->second.update( instance, type, name );
|
it->second.update( instance, type, name );
|
||||||
}
|
}
|
||||||
virtual void add( verifiable& v )
|
virtual void add( verifiable& v )
|
||||||
{
|
{
|
||||||
scoped_lock _( mutex_ );
|
scoped_lock _( mutex_ );
|
||||||
group_.add( v );
|
group_.add( v );
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void remove( verifiable& v )
|
virtual void remove( verifiable& v )
|
||||||
{
|
{
|
||||||
scoped_lock _( mutex_ );
|
scoped_lock _( mutex_ );
|
||||||
group_.remove( v );
|
group_.remove( v );
|
||||||
children_.erase( &v );
|
children_.erase( &v );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool verify() const
|
bool verify() const
|
||||||
{
|
{
|
||||||
scoped_lock _( mutex_ );
|
scoped_lock _( mutex_ );
|
||||||
return group_.verify();
|
return group_.verify();
|
||||||
}
|
}
|
||||||
void reset()
|
void reset()
|
||||||
{
|
{
|
||||||
scoped_lock _( mutex_ );
|
scoped_lock _( mutex_ );
|
||||||
group_.reset();
|
group_.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void serialize( std::ostream& s, const verifiable& v ) const
|
virtual void serialize( std::ostream& s, const verifiable& v ) const
|
||||||
{
|
{
|
||||||
scoped_lock _( mutex_ );
|
scoped_lock _( mutex_ );
|
||||||
children_cit it = children_.find( &v );
|
children_cit it = children_.find( &v );
|
||||||
if( it != children_.end() )
|
if( it != children_.end() )
|
||||||
s << it->second;
|
s << it->second;
|
||||||
else
|
else
|
||||||
s << "?";
|
s << "?";
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef std::map< const void*,
|
typedef std::map< const void*,
|
||||||
std::pair< parent, std::size_t > > parents_t;
|
std::pair< parent, std::size_t > > parents_t;
|
||||||
|
|
||||||
class counter_child
|
class counter_child
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
counter_child( parents_t& parents, const void* p )
|
counter_child( parents_t& parents, const void* p )
|
||||||
: parents_( &parents )
|
: parents_( &parents )
|
||||||
, it_( parents.insert(
|
, it_( parents.insert(
|
||||||
std::make_pair( p, parents_t::mapped_type() ) ).first )
|
std::make_pair( p, parents_t::mapped_type() ) ).first )
|
||||||
{
|
{
|
||||||
++it_->second.second;
|
++it_->second.second;
|
||||||
}
|
}
|
||||||
counter_child( const counter_child& rhs )
|
counter_child( const counter_child& rhs )
|
||||||
: parents_( rhs.parents_ )
|
: parents_( rhs.parents_ )
|
||||||
, it_( rhs.it_ )
|
, it_( rhs.it_ )
|
||||||
, child_( rhs.child_ )
|
, child_( rhs.child_ )
|
||||||
{
|
{
|
||||||
++it_->second.second;
|
++it_->second.second;
|
||||||
}
|
}
|
||||||
~counter_child()
|
~counter_child()
|
||||||
{
|
{
|
||||||
if( --it_->second.second == 0 )
|
if( --it_->second.second == 0 )
|
||||||
parents_->erase( it_ );
|
parents_->erase( it_ );
|
||||||
}
|
}
|
||||||
void update( boost::unit_test::const_string instance,
|
void update( boost::unit_test::const_string instance,
|
||||||
boost::optional< type_name > type,
|
boost::optional< type_name > type,
|
||||||
boost::unit_test::const_string name )
|
boost::unit_test::const_string name )
|
||||||
{
|
{
|
||||||
child_.update( it_->second.first, instance, type, name );
|
child_.update( it_->second.first, instance, type, name );
|
||||||
}
|
}
|
||||||
friend std::ostream& operator<<( std::ostream& s,
|
friend std::ostream& operator<<( std::ostream& s,
|
||||||
const counter_child& c )
|
const counter_child& c )
|
||||||
{
|
{
|
||||||
return s << c.child_;
|
return s << c.child_;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
counter_child& operator=( const counter_child& );
|
counter_child& operator=( const counter_child& );
|
||||||
|
|
||||||
parents_t* parents_;
|
parents_t* parents_;
|
||||||
parents_t::iterator it_;
|
parents_t::iterator it_;
|
||||||
child child_;
|
child child_;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::map< const verifiable*, counter_child > children_t;
|
typedef std::map< const verifiable*, counter_child > children_t;
|
||||||
typedef children_t::const_iterator children_cit;
|
typedef children_t::const_iterator children_cit;
|
||||||
|
|
||||||
parents_t parents_;
|
parents_t parents_;
|
||||||
children_t children_;
|
children_t children_;
|
||||||
group group_;
|
group group_;
|
||||||
mutable mutex mutex_;
|
mutable mutex mutex_;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BOOST_TEST_SINGLETON_CONS( root_t );
|
BOOST_TEST_SINGLETON_CONS( root_t );
|
||||||
};
|
};
|
||||||
BOOST_TEST_SINGLETON_INST( root )
|
BOOST_TEST_SINGLETON_INST( root )
|
||||||
}
|
}
|
||||||
} // mock
|
} // mock
|
||||||
|
|
||||||
#endif // MOCK_ROOT_HPP_INCLUDED
|
#endif // MOCK_ROOT_HPP_INCLUDED
|
||||||
|
|
@ -1,57 +1,57 @@
|
||||||
// http://turtle.sourceforge.net
|
// http://turtle.sourceforge.net
|
||||||
//
|
//
|
||||||
// Copyright Mathieu Champlon 2012
|
// Copyright Mathieu Champlon 2012
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#ifndef MOCK_SEQUENCE_IMPL_HPP_INCLUDED
|
#ifndef MOCK_SEQUENCE_IMPL_HPP_INCLUDED
|
||||||
#define MOCK_SEQUENCE_IMPL_HPP_INCLUDED
|
#define MOCK_SEQUENCE_IMPL_HPP_INCLUDED
|
||||||
|
|
||||||
#include "../config.hpp"
|
#include "../config.hpp"
|
||||||
#include <boost/noncopyable.hpp>
|
#include <boost/noncopyable.hpp>
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace mock
|
namespace mock
|
||||||
{
|
{
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
class sequence_impl : private boost::noncopyable
|
class sequence_impl : private boost::noncopyable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void add( void* e )
|
void add( void* e )
|
||||||
{
|
{
|
||||||
elements_.push_back( e );
|
elements_.push_back( e );
|
||||||
}
|
}
|
||||||
void remove( void* e )
|
void remove( void* e )
|
||||||
{
|
{
|
||||||
elements_.erase( std::remove( elements_.begin(),
|
elements_.erase( std::remove( elements_.begin(),
|
||||||
elements_.end(), e ), elements_.end() );
|
elements_.end(), e ), elements_.end() );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_valid( const void* e ) const
|
bool is_valid( const void* e ) const
|
||||||
{
|
{
|
||||||
return std::find( elements_.begin(), elements_.end(), e )
|
return std::find( elements_.begin(), elements_.end(), e )
|
||||||
!= elements_.end();
|
!= elements_.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
void invalidate( const void* e )
|
void invalidate( const void* e )
|
||||||
{
|
{
|
||||||
elements_type::iterator it =
|
elements_type::iterator it =
|
||||||
std::find( elements_.begin(), elements_.end(), e );
|
std::find( elements_.begin(), elements_.end(), e );
|
||||||
if( it != elements_.end() )
|
if( it != elements_.end() )
|
||||||
elements_.erase( elements_.begin(), it );
|
elements_.erase( elements_.begin(), it );
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef std::vector< void* > elements_type;
|
typedef std::vector< void* > elements_type;
|
||||||
|
|
||||||
elements_type elements_;
|
elements_type elements_;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
} // mock
|
} // mock
|
||||||
|
|
||||||
#endif // MOCK_SEQUENCE_IMPL_HPP_INCLUDED
|
#endif // MOCK_SEQUENCE_IMPL_HPP_INCLUDED
|
||||||
|
|
@ -1,63 +1,63 @@
|
||||||
// http://turtle.sourceforge.net
|
// http://turtle.sourceforge.net
|
||||||
//
|
//
|
||||||
// Copyright Mathieu Champlon 2012
|
// Copyright Mathieu Champlon 2012
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#ifndef MOCK_SIGNATURE_HPP_INCLUDED
|
#ifndef MOCK_SIGNATURE_HPP_INCLUDED
|
||||||
#define MOCK_SIGNATURE_HPP_INCLUDED
|
#define MOCK_SIGNATURE_HPP_INCLUDED
|
||||||
|
|
||||||
#include "../config.hpp"
|
#include "../config.hpp"
|
||||||
#include <boost/function_types/parameter_types.hpp>
|
#include <boost/function_types/parameter_types.hpp>
|
||||||
#include <boost/function_types/function_type.hpp>
|
#include <boost/function_types/function_type.hpp>
|
||||||
#include <boost/function_types/result_type.hpp>
|
#include <boost/function_types/result_type.hpp>
|
||||||
#include <boost/mpl/single_view.hpp>
|
#include <boost/mpl/single_view.hpp>
|
||||||
#include <boost/mpl/joint_view.hpp>
|
#include <boost/mpl/joint_view.hpp>
|
||||||
#include <boost/mpl/pop_front.hpp>
|
#include <boost/mpl/pop_front.hpp>
|
||||||
#define BOOST_TYPEOF_SILENT
|
#define BOOST_TYPEOF_SILENT
|
||||||
#include <boost/typeof/typeof.hpp>
|
#include <boost/typeof/typeof.hpp>
|
||||||
|
|
||||||
namespace mock
|
namespace mock
|
||||||
{
|
{
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
template< typename M >
|
template< typename M >
|
||||||
struct signature :
|
struct signature :
|
||||||
boost::function_types::function_type<
|
boost::function_types::function_type<
|
||||||
boost::mpl::joint_view<
|
boost::mpl::joint_view<
|
||||||
boost::mpl::single_view<
|
boost::mpl::single_view<
|
||||||
typename
|
typename
|
||||||
boost::function_types::result_type< M >::type
|
boost::function_types::result_type< M >::type
|
||||||
>,
|
>,
|
||||||
typename boost::mpl::pop_front<
|
typename boost::mpl::pop_front<
|
||||||
typename
|
typename
|
||||||
boost::function_types::parameter_types< M >
|
boost::function_types::parameter_types< M >
|
||||||
>::type
|
>::type
|
||||||
>
|
>
|
||||||
>
|
>
|
||||||
{};
|
{};
|
||||||
|
|
||||||
template< typename T >
|
template< typename T >
|
||||||
struct base
|
struct base
|
||||||
{
|
{
|
||||||
typedef T base_type;
|
typedef T base_type;
|
||||||
};
|
};
|
||||||
|
|
||||||
// if an error is generated by the line below it means
|
// if an error is generated by the line below it means
|
||||||
// the method is ambiguous : specify its signature to
|
// the method is ambiguous : specify its signature to
|
||||||
// disambiguate
|
// disambiguate
|
||||||
template< typename T >
|
template< typename T >
|
||||||
T& ambiguous_method_requires_to_specify_signature( const T& );
|
T& ambiguous_method_requires_to_specify_signature( const T& );
|
||||||
}
|
}
|
||||||
} // mock
|
} // mock
|
||||||
|
|
||||||
#define MOCK_SIGNATURE(M) \
|
#define MOCK_SIGNATURE(M) \
|
||||||
mock::detail::signature< \
|
mock::detail::signature< \
|
||||||
BOOST_TYPEOF( \
|
BOOST_TYPEOF( \
|
||||||
mock::detail::ambiguous_method_requires_to_specify_signature( \
|
mock::detail::ambiguous_method_requires_to_specify_signature( \
|
||||||
&base_type::M ) ) \
|
&base_type::M ) ) \
|
||||||
>::type
|
>::type
|
||||||
|
|
||||||
#endif // MOCK_SIGNATURE_HPP_INCLUDED
|
#endif // MOCK_SIGNATURE_HPP_INCLUDED
|
||||||
|
|
@ -1,116 +1,116 @@
|
||||||
// http://turtle.sourceforge.net
|
// http://turtle.sourceforge.net
|
||||||
//
|
//
|
||||||
// Copyright Mathieu Champlon 2009
|
// Copyright Mathieu Champlon 2009
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#ifndef MOCK_TYPE_NAME_HPP_INCLUDED
|
#ifndef MOCK_TYPE_NAME_HPP_INCLUDED
|
||||||
#define MOCK_TYPE_NAME_HPP_INCLUDED
|
#define MOCK_TYPE_NAME_HPP_INCLUDED
|
||||||
|
|
||||||
#include "../config.hpp"
|
#include "../config.hpp"
|
||||||
#include <boost/test/utils/basic_cstring/io.hpp>
|
#include <boost/test/utils/basic_cstring/io.hpp>
|
||||||
#include <boost/algorithm/string/replace.hpp>
|
#include <boost/algorithm/string/replace.hpp>
|
||||||
#include <boost/algorithm/string/erase.hpp>
|
#include <boost/algorithm/string/erase.hpp>
|
||||||
#include <boost/algorithm/string/trim.hpp>
|
#include <boost/algorithm/string/trim.hpp>
|
||||||
#include <boost/detail/sp_typeinfo.hpp>
|
#include <boost/detail/sp_typeinfo.hpp>
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <typeinfo>
|
#include <typeinfo>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
#include <cxxabi.h>
|
#include <cxxabi.h>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define MOCK_TYPE_NAME( T ) mock::detail::type_name( BOOST_SP_TYPEID(T) )
|
#define MOCK_TYPE_NAME( T ) mock::detail::type_name( BOOST_SP_TYPEID(T) )
|
||||||
|
|
||||||
namespace mock
|
namespace mock
|
||||||
{
|
{
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
class type_name
|
class type_name
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit type_name( const boost::detail::sp_typeinfo& info )
|
explicit type_name( const boost::detail::sp_typeinfo& info )
|
||||||
: info_( &info )
|
: info_( &info )
|
||||||
{}
|
{}
|
||||||
friend std::ostream& operator<<( std::ostream& s, const type_name& t )
|
friend std::ostream& operator<<( std::ostream& s, const type_name& t )
|
||||||
{
|
{
|
||||||
t.serialize( s, *t.info_ );
|
t.serialize( s, *t.info_ );
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
void serialize( std::ostream& s,
|
void serialize( std::ostream& s,
|
||||||
const boost::detail::sp_typeinfo& info ) const
|
const boost::detail::sp_typeinfo& info ) const
|
||||||
{
|
{
|
||||||
const char* name = info.name();
|
const char* name = info.name();
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
int status = 0;
|
int status = 0;
|
||||||
boost::shared_ptr< char > demangled(
|
boost::shared_ptr< char > demangled(
|
||||||
abi::__cxa_demangle( name, 0, 0, &status ),
|
abi::__cxa_demangle( name, 0, 0, &status ),
|
||||||
&std::free );
|
&std::free );
|
||||||
if( ! status && demangled )
|
if( ! status && demangled )
|
||||||
serialize( s, demangled.get() );
|
serialize( s, demangled.get() );
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
serialize( s, name );
|
serialize( s, name );
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef std::string::size_type size_type;
|
typedef std::string::size_type size_type;
|
||||||
|
|
||||||
void serialize( std::ostream& s, std::string name ) const
|
void serialize( std::ostream& s, std::string name ) const
|
||||||
{
|
{
|
||||||
const size_type nm = rfind( name, ':' ) + 1;
|
const size_type nm = rfind( name, ':' ) + 1;
|
||||||
const size_type tpl = name.find( '<', nm );
|
const size_type tpl = name.find( '<', nm );
|
||||||
s << clean( name.substr( nm, tpl - nm ) );
|
s << clean( name.substr( nm, tpl - nm ) );
|
||||||
if( tpl == std::string::npos )
|
if( tpl == std::string::npos )
|
||||||
return;
|
return;
|
||||||
s << '<';
|
s << '<';
|
||||||
list( s, name.substr( tpl + 1, name.rfind( '>' ) - tpl - 1 ) );
|
list( s, name.substr( tpl + 1, name.rfind( '>' ) - tpl - 1 ) );
|
||||||
s << '>';
|
s << '>';
|
||||||
}
|
}
|
||||||
void list( std::ostream& s, const std::string& name ) const
|
void list( std::ostream& s, const std::string& name ) const
|
||||||
{
|
{
|
||||||
const size_type comma = rfind( name, ',' );
|
const size_type comma = rfind( name, ',' );
|
||||||
if( comma != std::string::npos )
|
if( comma != std::string::npos )
|
||||||
{
|
{
|
||||||
list( s, name.substr( 0, comma ) );
|
list( s, name.substr( 0, comma ) );
|
||||||
s << ", ";
|
s << ", ";
|
||||||
}
|
}
|
||||||
serialize( s, name.substr( comma + 1 ) );
|
serialize( s, name.substr( comma + 1 ) );
|
||||||
}
|
}
|
||||||
std::string clean( std::string name ) const
|
std::string clean( std::string name ) const
|
||||||
{
|
{
|
||||||
boost::algorithm::trim( name );
|
boost::algorithm::trim( name );
|
||||||
boost::algorithm::erase_all( name, "class " );
|
boost::algorithm::erase_all( name, "class " );
|
||||||
boost::algorithm::erase_all( name, "struct " );
|
boost::algorithm::erase_all( name, "struct " );
|
||||||
boost::algorithm::erase_all( name, "__ptr64" );
|
boost::algorithm::erase_all( name, "__ptr64" );
|
||||||
boost::algorithm::replace_all( name, " &", "&" );
|
boost::algorithm::replace_all( name, " &", "&" );
|
||||||
boost::algorithm::replace_all( name, "& ", "&" );
|
boost::algorithm::replace_all( name, "& ", "&" );
|
||||||
boost::algorithm::replace_all( name, " *", "*" );
|
boost::algorithm::replace_all( name, " *", "*" );
|
||||||
boost::algorithm::replace_all( name, "* ", "*" );
|
boost::algorithm::replace_all( name, "* ", "*" );
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
size_type rfind( const std::string& name, char c ) const
|
size_type rfind( const std::string& name, char c ) const
|
||||||
{
|
{
|
||||||
size_type count = 0;
|
size_type count = 0;
|
||||||
for( size_type i = name.size() - 1; i > 0; --i )
|
for( size_type i = name.size() - 1; i > 0; --i )
|
||||||
{
|
{
|
||||||
if( name[ i ] == '>' )
|
if( name[ i ] == '>' )
|
||||||
++count;
|
++count;
|
||||||
else if( name[ i ] == '<' )
|
else if( name[ i ] == '<' )
|
||||||
--count;
|
--count;
|
||||||
if( name[ i ] == c && count == 0 )
|
if( name[ i ] == c && count == 0 )
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
return std::string::npos;
|
return std::string::npos;
|
||||||
}
|
}
|
||||||
|
|
||||||
const boost::detail::sp_typeinfo* info_;
|
const boost::detail::sp_typeinfo* info_;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
} // mock
|
} // mock
|
||||||
|
|
||||||
#endif // MOCK_TYPE_NAME_HPP_INCLUDED
|
#endif // MOCK_TYPE_NAME_HPP_INCLUDED
|
||||||
|
|
@ -1,32 +1,32 @@
|
||||||
// http://turtle.sourceforge.net
|
// http://turtle.sourceforge.net
|
||||||
//
|
//
|
||||||
// Copyright Mathieu Champlon 2008
|
// Copyright Mathieu Champlon 2008
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#ifndef MOCK_VERIFIABLE_HPP_INCLUDED
|
#ifndef MOCK_VERIFIABLE_HPP_INCLUDED
|
||||||
#define MOCK_VERIFIABLE_HPP_INCLUDED
|
#define MOCK_VERIFIABLE_HPP_INCLUDED
|
||||||
|
|
||||||
#include "../config.hpp"
|
#include "../config.hpp"
|
||||||
#include <boost/noncopyable.hpp>
|
#include <boost/noncopyable.hpp>
|
||||||
|
|
||||||
namespace mock
|
namespace mock
|
||||||
{
|
{
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
class verifiable : private boost::noncopyable
|
class verifiable : private boost::noncopyable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
verifiable() {}
|
verifiable() {}
|
||||||
virtual ~verifiable() {}
|
virtual ~verifiable() {}
|
||||||
|
|
||||||
virtual bool verify() const = 0;
|
virtual bool verify() const = 0;
|
||||||
|
|
||||||
virtual void reset() = 0;
|
virtual void reset() = 0;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
} // mock
|
} // mock
|
||||||
|
|
||||||
#endif // MOCK_VERIFIABLE_HPP_INCLUDED
|
#endif // MOCK_VERIFIABLE_HPP_INCLUDED
|
||||||
|
|
@ -1,67 +1,67 @@
|
||||||
// http://turtle.sourceforge.net
|
// http://turtle.sourceforge.net
|
||||||
//
|
//
|
||||||
// Copyright Mathieu Champlon 2008
|
// Copyright Mathieu Champlon 2008
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#ifndef MOCK_ERROR_HPP_INCLUDED
|
#ifndef MOCK_ERROR_HPP_INCLUDED
|
||||||
#define MOCK_ERROR_HPP_INCLUDED
|
#define MOCK_ERROR_HPP_INCLUDED
|
||||||
|
|
||||||
#include "config.hpp"
|
#include "config.hpp"
|
||||||
#ifdef MOCK_USE_BOOST_TEST
|
#ifdef MOCK_USE_BOOST_TEST
|
||||||
#include "exception.hpp"
|
#include "exception.hpp"
|
||||||
#include <boost/test/framework.hpp>
|
#include <boost/test/framework.hpp>
|
||||||
#include <boost/test/test_tools.hpp>
|
#include <boost/test/test_tools.hpp>
|
||||||
#include <boost/test/unit_test_suite.hpp>
|
#include <boost/test/unit_test_suite.hpp>
|
||||||
#include <boost/exception/enable_current_exception.hpp>
|
#include <boost/exception/enable_current_exception.hpp>
|
||||||
|
|
||||||
namespace mock
|
namespace mock
|
||||||
{
|
{
|
||||||
template< typename Result >
|
template< typename Result >
|
||||||
struct error
|
struct error
|
||||||
{
|
{
|
||||||
static Result abort()
|
static Result abort()
|
||||||
{
|
{
|
||||||
boost::unit_test::framework::test_unit_aborted(
|
boost::unit_test::framework::test_unit_aborted(
|
||||||
boost::unit_test::framework::current_test_case() );
|
boost::unit_test::framework::current_test_case() );
|
||||||
throw boost::enable_current_exception( exception() );
|
throw boost::enable_current_exception( exception() );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pass( const char* file, int line )
|
static void pass( const char* file, int line )
|
||||||
{
|
{
|
||||||
boost::unit_test::unit_test_log.set_checkpoint( file,
|
boost::unit_test::unit_test_log.set_checkpoint( file,
|
||||||
static_cast< std::size_t >( line ) );
|
static_cast< std::size_t >( line ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
template< typename Context >
|
template< typename Context >
|
||||||
static void fail( const char* message, const Context& context,
|
static void fail( const char* message, const Context& context,
|
||||||
const char* file = "unknown location", int line = 0 )
|
const char* file = "unknown location", int line = 0 )
|
||||||
{
|
{
|
||||||
boost::unit_test::framework::assertion_result( false );
|
boost::unit_test::framework::assertion_result( false );
|
||||||
boost::unit_test::unit_test_log
|
boost::unit_test::unit_test_log
|
||||||
<< boost::unit_test::log::begin( file,
|
<< boost::unit_test::log::begin( file,
|
||||||
static_cast< std::size_t >( line ) )
|
static_cast< std::size_t >( line ) )
|
||||||
<< boost::unit_test::log_all_errors
|
<< boost::unit_test::log_all_errors
|
||||||
<< message << ": " << context
|
<< message << ": " << context
|
||||||
<< boost::unit_test::log::end();
|
<< boost::unit_test::log::end();
|
||||||
}
|
}
|
||||||
|
|
||||||
template< typename Context >
|
template< typename Context >
|
||||||
static void call( const Context& context, const char* file, int line )
|
static void call( const Context& context, const char* file, int line )
|
||||||
{
|
{
|
||||||
boost::unit_test::framework::assertion_result( true );
|
boost::unit_test::framework::assertion_result( true );
|
||||||
boost::unit_test::unit_test_log
|
boost::unit_test::unit_test_log
|
||||||
<< boost::unit_test::log::begin( file,
|
<< boost::unit_test::log::begin( file,
|
||||||
static_cast< std::size_t >( line ) )
|
static_cast< std::size_t >( line ) )
|
||||||
<< boost::unit_test::log_successful_tests
|
<< boost::unit_test::log_successful_tests
|
||||||
<< "mock expectation fulfilled: " << context
|
<< "mock expectation fulfilled: " << context
|
||||||
<< boost::unit_test::log::end();
|
<< boost::unit_test::log::end();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} // mock
|
} // mock
|
||||||
|
|
||||||
#endif // MOCK_USE_BOOST_TEST
|
#endif // MOCK_USE_BOOST_TEST
|
||||||
|
|
||||||
#endif // MOCK_ERROR_HPP_INCLUDED
|
#endif // MOCK_ERROR_HPP_INCLUDED
|
||||||
|
|
@ -1,24 +1,24 @@
|
||||||
// http://turtle.sourceforge.net
|
// http://turtle.sourceforge.net
|
||||||
//
|
//
|
||||||
// Copyright Mathieu Champlon 2012
|
// Copyright Mathieu Champlon 2012
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#ifndef MOCK_EXCEPTION_HPP_INCLUDED
|
#ifndef MOCK_EXCEPTION_HPP_INCLUDED
|
||||||
#define MOCK_EXCEPTION_HPP_INCLUDED
|
#define MOCK_EXCEPTION_HPP_INCLUDED
|
||||||
|
|
||||||
#include "config.hpp"
|
#include "config.hpp"
|
||||||
#ifdef MOCK_USE_BOOST_TEST
|
#ifdef MOCK_USE_BOOST_TEST
|
||||||
#include <boost/test/execution_monitor.hpp>
|
#include <boost/test/execution_monitor.hpp>
|
||||||
|
|
||||||
namespace mock
|
namespace mock
|
||||||
{
|
{
|
||||||
struct exception : virtual boost::execution_aborted
|
struct exception : virtual boost::execution_aborted
|
||||||
{};
|
{};
|
||||||
} // mock
|
} // mock
|
||||||
|
|
||||||
#endif // MOCK_USE_BOOST_TEST
|
#endif // MOCK_USE_BOOST_TEST
|
||||||
|
|
||||||
#endif // MOCK_EXCEPTION_HPP_INCLUDED
|
#endif // MOCK_EXCEPTION_HPP_INCLUDED
|
||||||
|
|
@ -1,25 +1,25 @@
|
||||||
// http://turtle.sourceforge.net
|
// http://turtle.sourceforge.net
|
||||||
//
|
//
|
||||||
// Copyright Mathieu Champlon 2011
|
// Copyright Mathieu Champlon 2011
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#ifndef MOCK_FORMAT_HPP_INCLUDED
|
#ifndef MOCK_FORMAT_HPP_INCLUDED
|
||||||
#define MOCK_FORMAT_HPP_INCLUDED
|
#define MOCK_FORMAT_HPP_INCLUDED
|
||||||
|
|
||||||
#include "config.hpp"
|
#include "config.hpp"
|
||||||
#include "detail/formatter.hpp"
|
#include "detail/formatter.hpp"
|
||||||
|
|
||||||
namespace mock
|
namespace mock
|
||||||
{
|
{
|
||||||
template< typename T >
|
template< typename T >
|
||||||
detail::formatter< T > format( const T& t )
|
detail::formatter< T > format( const T& t )
|
||||||
{
|
{
|
||||||
return detail::formatter< T >( t );
|
return detail::formatter< T >( t );
|
||||||
}
|
}
|
||||||
|
|
||||||
} // mock
|
} // mock
|
||||||
|
|
||||||
#endif // MOCK_FORMAT_HPP_INCLUDED
|
#endif // MOCK_FORMAT_HPP_INCLUDED
|
||||||
|
|
@ -1,188 +1,188 @@
|
||||||
// http://turtle.sourceforge.net
|
// http://turtle.sourceforge.net
|
||||||
//
|
//
|
||||||
// Copyright Mathieu Champlon 2011
|
// Copyright Mathieu Champlon 2011
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#ifndef MOCK_LOG_HPP_INCLUDED
|
#ifndef MOCK_LOG_HPP_INCLUDED
|
||||||
#define MOCK_LOG_HPP_INCLUDED
|
#define MOCK_LOG_HPP_INCLUDED
|
||||||
|
|
||||||
#include "config.hpp"
|
#include "config.hpp"
|
||||||
#include "stream.hpp"
|
#include "stream.hpp"
|
||||||
#include "format.hpp"
|
#include "format.hpp"
|
||||||
#include <boost/utility/enable_if.hpp>
|
#include <boost/utility/enable_if.hpp>
|
||||||
#include <boost/detail/container_fwd.hpp>
|
#include <boost/detail/container_fwd.hpp>
|
||||||
#include <boost/function_types/is_callable_builtin.hpp>
|
#include <boost/function_types/is_callable_builtin.hpp>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
namespace boost
|
namespace boost
|
||||||
{
|
{
|
||||||
template< typename T > class shared_ptr;
|
template< typename T > class shared_ptr;
|
||||||
template< typename T > class weak_ptr;
|
template< typename T > class weak_ptr;
|
||||||
template< typename T > class reference_wrapper;
|
template< typename T > class reference_wrapper;
|
||||||
|
|
||||||
namespace phoenix
|
namespace phoenix
|
||||||
{
|
{
|
||||||
template< typename T > struct actor;
|
template< typename T > struct actor;
|
||||||
}
|
}
|
||||||
namespace lambda
|
namespace lambda
|
||||||
{
|
{
|
||||||
template< typename T > class lambda_functor;
|
template< typename T > class lambda_functor;
|
||||||
}
|
}
|
||||||
namespace assign_detail
|
namespace assign_detail
|
||||||
{
|
{
|
||||||
template< typename T > class generic_list;
|
template< typename T > class generic_list;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace mock
|
namespace mock
|
||||||
{
|
{
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
template< typename T >
|
template< typename T >
|
||||||
void serialize( stream& s, const T& begin, const T& end )
|
void serialize( stream& s, const T& begin, const T& end )
|
||||||
{
|
{
|
||||||
s << '(';
|
s << '(';
|
||||||
for( T it = begin; it != end; ++it )
|
for( T it = begin; it != end; ++it )
|
||||||
s << (it == begin ? "" : ",") << mock::format( *it );
|
s << (it == begin ? "" : ",") << mock::format( *it );
|
||||||
s << ')';
|
s << ')';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template< typename T >
|
template< typename T >
|
||||||
stream& operator<<( stream& s, const std::auto_ptr< T >& t )
|
stream& operator<<( stream& s, const std::auto_ptr< T >& t )
|
||||||
{
|
{
|
||||||
return s << mock::format( t.get() );
|
return s << mock::format( t.get() );
|
||||||
}
|
}
|
||||||
template< typename T1, typename T2 >
|
template< typename T1, typename T2 >
|
||||||
stream& operator<<( stream& s, const std::pair< T1, T2 >& p )
|
stream& operator<<( stream& s, const std::pair< T1, T2 >& p )
|
||||||
{
|
{
|
||||||
return s << '(' << mock::format( p.first )
|
return s << '(' << mock::format( p.first )
|
||||||
<< ',' << mock::format( p.second ) << ')';
|
<< ',' << mock::format( p.second ) << ')';
|
||||||
}
|
}
|
||||||
|
|
||||||
template< typename T, typename A >
|
template< typename T, typename A >
|
||||||
stream& operator<<( stream& s, const std::deque< T, A >& t )
|
stream& operator<<( stream& s, const std::deque< T, A >& t )
|
||||||
{
|
{
|
||||||
detail::serialize( s, t.begin(), t.end() );
|
detail::serialize( s, t.begin(), t.end() );
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
template< typename T, typename A >
|
template< typename T, typename A >
|
||||||
stream& operator<<( stream& s, const std::list< T, A >& t )
|
stream& operator<<( stream& s, const std::list< T, A >& t )
|
||||||
{
|
{
|
||||||
detail::serialize( s, t.begin(), t.end() );
|
detail::serialize( s, t.begin(), t.end() );
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
template< typename T, typename A >
|
template< typename T, typename A >
|
||||||
stream& operator<<( stream& s, const std::vector< T, A >& t )
|
stream& operator<<( stream& s, const std::vector< T, A >& t )
|
||||||
{
|
{
|
||||||
detail::serialize( s, t.begin(), t.end() );
|
detail::serialize( s, t.begin(), t.end() );
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
template< typename K, typename T, typename C, typename A >
|
template< typename K, typename T, typename C, typename A >
|
||||||
stream& operator<<( stream& s, const std::map< K, T, C, A >& t )
|
stream& operator<<( stream& s, const std::map< K, T, C, A >& t )
|
||||||
{
|
{
|
||||||
detail::serialize( s, t.begin(), t.end() );
|
detail::serialize( s, t.begin(), t.end() );
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
template< typename K, typename T, typename C, typename A >
|
template< typename K, typename T, typename C, typename A >
|
||||||
stream& operator<<( stream& s, const std::multimap< K, T, C, A >& t )
|
stream& operator<<( stream& s, const std::multimap< K, T, C, A >& t )
|
||||||
{
|
{
|
||||||
detail::serialize( s, t.begin(), t.end() );
|
detail::serialize( s, t.begin(), t.end() );
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
template< typename T, typename C, typename A >
|
template< typename T, typename C, typename A >
|
||||||
stream& operator<<( stream& s, const std::set< T, C, A >& t )
|
stream& operator<<( stream& s, const std::set< T, C, A >& t )
|
||||||
{
|
{
|
||||||
detail::serialize( s, t.begin(), t.end() );
|
detail::serialize( s, t.begin(), t.end() );
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
template< typename T, typename C, typename A >
|
template< typename T, typename C, typename A >
|
||||||
stream& operator<<( stream& s, const std::multiset< T, C, A >& t )
|
stream& operator<<( stream& s, const std::multiset< T, C, A >& t )
|
||||||
{
|
{
|
||||||
detail::serialize( s, t.begin(), t.end() );
|
detail::serialize( s, t.begin(), t.end() );
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
template< typename T >
|
template< typename T >
|
||||||
stream& operator<<( stream& s,
|
stream& operator<<( stream& s,
|
||||||
const boost::assign_detail::generic_list< T >& t )
|
const boost::assign_detail::generic_list< T >& t )
|
||||||
{
|
{
|
||||||
detail::serialize( s, t.begin(), t.end() );
|
detail::serialize( s, t.begin(), t.end() );
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
template< typename T >
|
template< typename T >
|
||||||
stream& operator<<( stream& s, const boost::reference_wrapper< T >& t )
|
stream& operator<<( stream& s, const boost::reference_wrapper< T >& t )
|
||||||
{
|
{
|
||||||
return s << mock::format( t.get() );
|
return s << mock::format( t.get() );
|
||||||
}
|
}
|
||||||
template< typename T >
|
template< typename T >
|
||||||
stream& operator<<( stream& s, const boost::shared_ptr< T >& t )
|
stream& operator<<( stream& s, const boost::shared_ptr< T >& t )
|
||||||
{
|
{
|
||||||
return s << mock::format( t.get() );
|
return s << mock::format( t.get() );
|
||||||
}
|
}
|
||||||
template< typename T >
|
template< typename T >
|
||||||
stream& operator<<( stream& s, const boost::weak_ptr< T >& t )
|
stream& operator<<( stream& s, const boost::weak_ptr< T >& t )
|
||||||
{
|
{
|
||||||
return s << mock::format( t.lock() );
|
return s << mock::format( t.lock() );
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MOCK_SMART_PTR
|
#ifdef MOCK_SMART_PTR
|
||||||
template< typename T >
|
template< typename T >
|
||||||
stream& operator<<( stream& s, const std::shared_ptr< T >& t )
|
stream& operator<<( stream& s, const std::shared_ptr< T >& t )
|
||||||
{
|
{
|
||||||
return s << mock::format( t.get() );
|
return s << mock::format( t.get() );
|
||||||
}
|
}
|
||||||
template< typename T >
|
template< typename T >
|
||||||
stream& operator<<( stream& s, const std::weak_ptr< T >& t )
|
stream& operator<<( stream& s, const std::weak_ptr< T >& t )
|
||||||
{
|
{
|
||||||
return s << mock::format( t.lock() );
|
return s << mock::format( t.lock() );
|
||||||
}
|
}
|
||||||
template< typename T, typename D >
|
template< typename T, typename D >
|
||||||
inline stream& operator<<( stream& s, const std::unique_ptr< T, D >& p )
|
inline stream& operator<<( stream& s, const std::unique_ptr< T, D >& p )
|
||||||
{
|
{
|
||||||
return s << mock::format( p.get() );
|
return s << mock::format( p.get() );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
template< typename T >
|
template< typename T >
|
||||||
stream& operator<<( stream& s, const boost::lambda::lambda_functor< T >& )
|
stream& operator<<( stream& s, const boost::lambda::lambda_functor< T >& )
|
||||||
{
|
{
|
||||||
return s << '?';
|
return s << '?';
|
||||||
}
|
}
|
||||||
template< typename T >
|
template< typename T >
|
||||||
stream& operator<<( stream& s, const boost::phoenix::actor< T >& )
|
stream& operator<<( stream& s, const boost::phoenix::actor< T >& )
|
||||||
{
|
{
|
||||||
return s << '?';
|
return s << '?';
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MOCK_NULLPTR
|
#ifdef MOCK_NULLPTR
|
||||||
inline stream& operator<<( stream& s, std::nullptr_t )
|
inline stream& operator<<( stream& s, std::nullptr_t )
|
||||||
{
|
{
|
||||||
return s << "nullptr";
|
return s << "nullptr";
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
template< typename T >
|
template< typename T >
|
||||||
typename boost::enable_if<
|
typename boost::enable_if<
|
||||||
boost::function_types::is_callable_builtin< T >,
|
boost::function_types::is_callable_builtin< T >,
|
||||||
stream&
|
stream&
|
||||||
>::type
|
>::type
|
||||||
operator<<( stream& s, T* )
|
operator<<( stream& s, T* )
|
||||||
{
|
{
|
||||||
return s << '?';
|
return s << '?';
|
||||||
}
|
}
|
||||||
template< typename T >
|
template< typename T >
|
||||||
typename boost::disable_if<
|
typename boost::disable_if<
|
||||||
boost::function_types::is_callable_builtin< T >,
|
boost::function_types::is_callable_builtin< T >,
|
||||||
stream&
|
stream&
|
||||||
>::type
|
>::type
|
||||||
operator<<( stream& s, T* t )
|
operator<<( stream& s, T* t )
|
||||||
{
|
{
|
||||||
*s.s_ << t;
|
*s.s_ << t;
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
} // mock
|
} // mock
|
||||||
|
|
||||||
#endif // MOCK_LOG_HPP_INCLUDED
|
#endif // MOCK_LOG_HPP_INCLUDED
|
||||||
|
|
@ -1,107 +1,107 @@
|
||||||
// http://turtle.sourceforge.net
|
// http://turtle.sourceforge.net
|
||||||
//
|
//
|
||||||
// Copyright Mathieu Champlon 2008
|
// Copyright Mathieu Champlon 2008
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#ifndef MOCK_MATCHER_HPP_INCLUDED
|
#ifndef MOCK_MATCHER_HPP_INCLUDED
|
||||||
#define MOCK_MATCHER_HPP_INCLUDED
|
#define MOCK_MATCHER_HPP_INCLUDED
|
||||||
|
|
||||||
#include "config.hpp"
|
#include "config.hpp"
|
||||||
#include "log.hpp"
|
#include "log.hpp"
|
||||||
#include "constraint.hpp"
|
#include "constraint.hpp"
|
||||||
#include "detail/is_functor.hpp"
|
#include "detail/is_functor.hpp"
|
||||||
#include <boost/utility/enable_if.hpp>
|
#include <boost/utility/enable_if.hpp>
|
||||||
#include <boost/ref.hpp>
|
#include <boost/ref.hpp>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
namespace mock
|
namespace mock
|
||||||
{
|
{
|
||||||
template< typename Actual, typename Expected, typename Enable = void >
|
template< typename Actual, typename Expected, typename Enable = void >
|
||||||
class matcher
|
class matcher
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit matcher( Expected expected )
|
explicit matcher( Expected expected )
|
||||||
: expected_( expected )
|
: expected_( expected )
|
||||||
{}
|
{}
|
||||||
bool operator()( Actual actual )
|
bool operator()( Actual actual )
|
||||||
{
|
{
|
||||||
return actual == boost::unwrap_ref( expected_ );
|
return actual == boost::unwrap_ref( expected_ );
|
||||||
}
|
}
|
||||||
friend std::ostream& operator<<(
|
friend std::ostream& operator<<(
|
||||||
std::ostream& s, const matcher& m )
|
std::ostream& s, const matcher& m )
|
||||||
{
|
{
|
||||||
return s << mock::format( m.expected_ );
|
return s << mock::format( m.expected_ );
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
Expected expected_;
|
Expected expected_;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
class matcher< const char*, const char* >
|
class matcher< const char*, const char* >
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit matcher( const char* expected )
|
explicit matcher( const char* expected )
|
||||||
: expected_( expected )
|
: expected_( expected )
|
||||||
{}
|
{}
|
||||||
bool operator()( const char* actual )
|
bool operator()( const char* actual )
|
||||||
{
|
{
|
||||||
return std::strcmp( actual, expected_ ) == 0;
|
return std::strcmp( actual, expected_ ) == 0;
|
||||||
}
|
}
|
||||||
friend std::ostream& operator<<(
|
friend std::ostream& operator<<(
|
||||||
std::ostream& s, const matcher& m )
|
std::ostream& s, const matcher& m )
|
||||||
{
|
{
|
||||||
return s << mock::format( m.expected_ );
|
return s << mock::format( m.expected_ );
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
const char* expected_;
|
const char* expected_;
|
||||||
};
|
};
|
||||||
|
|
||||||
template< typename Actual, typename Constraint >
|
template< typename Actual, typename Constraint >
|
||||||
class matcher< Actual, mock::constraint< Constraint > >
|
class matcher< Actual, mock::constraint< Constraint > >
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit matcher( const constraint< Constraint >& c )
|
explicit matcher( const constraint< Constraint >& c )
|
||||||
: c_( c.c_ )
|
: c_( c.c_ )
|
||||||
{}
|
{}
|
||||||
bool operator()( Actual actual )
|
bool operator()( Actual actual )
|
||||||
{
|
{
|
||||||
return c_( actual );
|
return c_( actual );
|
||||||
}
|
}
|
||||||
friend std::ostream& operator<<(
|
friend std::ostream& operator<<(
|
||||||
std::ostream& s, const matcher& m )
|
std::ostream& s, const matcher& m )
|
||||||
{
|
{
|
||||||
return s << mock::format( m.c_ );
|
return s << mock::format( m.c_ );
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
Constraint c_;
|
Constraint c_;
|
||||||
};
|
};
|
||||||
|
|
||||||
template< typename Actual, typename Functor >
|
template< typename Actual, typename Functor >
|
||||||
class matcher< Actual, Functor,
|
class matcher< Actual, Functor,
|
||||||
typename boost::enable_if<
|
typename boost::enable_if<
|
||||||
detail::is_functor< Functor, Actual >
|
detail::is_functor< Functor, Actual >
|
||||||
>::type
|
>::type
|
||||||
>
|
>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit matcher( const Functor& f )
|
explicit matcher( const Functor& f )
|
||||||
: c_( f )
|
: c_( f )
|
||||||
{}
|
{}
|
||||||
bool operator()( Actual actual )
|
bool operator()( Actual actual )
|
||||||
{
|
{
|
||||||
return c_( actual );
|
return c_( actual );
|
||||||
}
|
}
|
||||||
friend std::ostream& operator<<(
|
friend std::ostream& operator<<(
|
||||||
std::ostream& s, const matcher& m )
|
std::ostream& s, const matcher& m )
|
||||||
{
|
{
|
||||||
return s << mock::format( m.c_ );
|
return s << mock::format( m.c_ );
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
Functor c_;
|
Functor c_;
|
||||||
};
|
};
|
||||||
} // mock
|
} // mock
|
||||||
|
|
||||||
#endif // MOCK_MATCHER_HPP_INCLUDED
|
#endif // MOCK_MATCHER_HPP_INCLUDED
|
||||||
|
|
@ -1,242 +1,242 @@
|
||||||
// http://turtle.sourceforge.net
|
// http://turtle.sourceforge.net
|
||||||
//
|
//
|
||||||
// Copyright Mathieu Champlon 2008
|
// Copyright Mathieu Champlon 2008
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#ifndef MOCK_MOCK_HPP_INCLUDED
|
#ifndef MOCK_MOCK_HPP_INCLUDED
|
||||||
#define MOCK_MOCK_HPP_INCLUDED
|
#define MOCK_MOCK_HPP_INCLUDED
|
||||||
|
|
||||||
#include "config.hpp"
|
#include "config.hpp"
|
||||||
#include "object.hpp"
|
#include "object.hpp"
|
||||||
#include "reset.hpp"
|
#include "reset.hpp"
|
||||||
#include "verify.hpp"
|
#include "verify.hpp"
|
||||||
#include "detail/functor.hpp"
|
#include "detail/functor.hpp"
|
||||||
#include "detail/function.hpp"
|
#include "detail/function.hpp"
|
||||||
#include "detail/type_name.hpp"
|
#include "detail/type_name.hpp"
|
||||||
#include "detail/signature.hpp"
|
#include "detail/signature.hpp"
|
||||||
#include "detail/parameter.hpp"
|
#include "detail/parameter.hpp"
|
||||||
#include "detail/cleanup.hpp"
|
#include "detail/cleanup.hpp"
|
||||||
#include <boost/preprocessor/repetition/repeat.hpp>
|
#include <boost/preprocessor/repetition/repeat.hpp>
|
||||||
#include <boost/preprocessor/stringize.hpp>
|
#include <boost/preprocessor/stringize.hpp>
|
||||||
#include <boost/utility/identity_type.hpp>
|
#include <boost/utility/identity_type.hpp>
|
||||||
#include <boost/mpl/assert.hpp>
|
#include <boost/mpl/assert.hpp>
|
||||||
|
|
||||||
#define MOCK_CLASS(T) \
|
#define MOCK_CLASS(T) \
|
||||||
struct T : mock::object
|
struct T : mock::object
|
||||||
|
|
||||||
#define MOCK_FUNCTION_TYPE(S, tpn) \
|
#define MOCK_FUNCTION_TYPE(S, tpn) \
|
||||||
tpn boost::remove_pointer< tpn BOOST_IDENTITY_TYPE((S)) >::type
|
tpn boost::remove_pointer< tpn BOOST_IDENTITY_TYPE((S)) >::type
|
||||||
|
|
||||||
#ifdef MOCK_VARIADIC_MACROS
|
#ifdef MOCK_VARIADIC_MACROS
|
||||||
|
|
||||||
#define MOCK_BASE_CLASS(T, ...) \
|
#define MOCK_BASE_CLASS(T, ...) \
|
||||||
struct T : __VA_ARGS__, mock::object, mock::detail::base< __VA_ARGS__ >
|
struct T : __VA_ARGS__, mock::object, mock::detail::base< __VA_ARGS__ >
|
||||||
|
|
||||||
#define MOCK_FUNCTOR(f, ...) \
|
#define MOCK_FUNCTOR(f, ...) \
|
||||||
mock::detail::functor< MOCK_FUNCTION_TYPE((__VA_ARGS__),) > f, f##_mock
|
mock::detail::functor< MOCK_FUNCTION_TYPE((__VA_ARGS__),) > f, f##_mock
|
||||||
#define MOCK_FUNCTOR_TPL(f, ...) \
|
#define MOCK_FUNCTOR_TPL(f, ...) \
|
||||||
mock::detail::functor< \
|
mock::detail::functor< \
|
||||||
MOCK_FUNCTION_TYPE((__VA_ARGS__), typename) > f, f##_mock
|
MOCK_FUNCTION_TYPE((__VA_ARGS__), typename) > f, f##_mock
|
||||||
|
|
||||||
#else // MOCK_VARIADIC_MACROS
|
#else // MOCK_VARIADIC_MACROS
|
||||||
|
|
||||||
#define MOCK_BASE_CLASS(T, I) \
|
#define MOCK_BASE_CLASS(T, I) \
|
||||||
struct T : I, mock::object, mock::detail::base< I >
|
struct T : I, mock::object, mock::detail::base< I >
|
||||||
|
|
||||||
#define MOCK_FUNCTOR(f, S) \
|
#define MOCK_FUNCTOR(f, S) \
|
||||||
mock::detail::functor< MOCK_FUNCTION_TYPE(S,) > f, f##_mock
|
mock::detail::functor< MOCK_FUNCTION_TYPE(S,) > f, f##_mock
|
||||||
#define MOCK_FUNCTOR_TPL(f, S) \
|
#define MOCK_FUNCTOR_TPL(f, S) \
|
||||||
mock::detail::functor< \
|
mock::detail::functor< \
|
||||||
MOCK_FUNCTION_TYPE(S, typename) > f, f##_mock
|
MOCK_FUNCTION_TYPE(S, typename) > f, f##_mock
|
||||||
|
|
||||||
#endif // MOCK_VARIADIC_MACROS
|
#endif // MOCK_VARIADIC_MACROS
|
||||||
|
|
||||||
#define MOCK_HELPER(t) \
|
#define MOCK_HELPER(t) \
|
||||||
t##_mock( mock::detail::root, BOOST_PP_STRINGIZE(t) )
|
t##_mock( mock::detail::root, BOOST_PP_STRINGIZE(t) )
|
||||||
#define MOCK_ANONYMOUS_HELPER(t) \
|
#define MOCK_ANONYMOUS_HELPER(t) \
|
||||||
t##_mock( mock::detail::root, "?." )
|
t##_mock( mock::detail::root, "?." )
|
||||||
|
|
||||||
#define MOCK_METHOD_HELPER(S, t, tpn) \
|
#define MOCK_METHOD_HELPER(S, t, tpn) \
|
||||||
mutable mock::detail::function< MOCK_FUNCTION_TYPE(S, tpn) > t##_mock_; \
|
mutable mock::detail::function< MOCK_FUNCTION_TYPE(S, tpn) > t##_mock_; \
|
||||||
mock::detail::function< MOCK_FUNCTION_TYPE(S, tpn) >& t##_mock( \
|
mock::detail::function< MOCK_FUNCTION_TYPE(S, tpn) >& t##_mock( \
|
||||||
const mock::detail::context&, \
|
const mock::detail::context&, \
|
||||||
boost::unit_test::const_string instance ) const \
|
boost::unit_test::const_string instance ) const \
|
||||||
{ \
|
{ \
|
||||||
mock::detail::configure( *this, t##_mock_, \
|
mock::detail::configure( *this, t##_mock_, \
|
||||||
instance.substr( 0, instance.rfind( BOOST_PP_STRINGIZE(t) ) ), \
|
instance.substr( 0, instance.rfind( BOOST_PP_STRINGIZE(t) ) ), \
|
||||||
MOCK_TYPE_NAME(*this), \
|
MOCK_TYPE_NAME(*this), \
|
||||||
BOOST_PP_STRINGIZE(t) ); \
|
BOOST_PP_STRINGIZE(t) ); \
|
||||||
return t##_mock_; \
|
return t##_mock_; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define MOCK_PARAM(z, n, d) \
|
#define MOCK_PARAM(z, n, d) \
|
||||||
BOOST_PP_COMMA_IF(n) d, n >::type p##n
|
BOOST_PP_COMMA_IF(n) d, n >::type p##n
|
||||||
#define MOCK_PARAMS(n, S, tpn) \
|
#define MOCK_PARAMS(n, S, tpn) \
|
||||||
BOOST_PP_REPEAT(n, MOCK_PARAM, \
|
BOOST_PP_REPEAT(n, MOCK_PARAM, \
|
||||||
tpn mock::detail::parameter< MOCK_FUNCTION_TYPE(S, tpn))
|
tpn mock::detail::parameter< MOCK_FUNCTION_TYPE(S, tpn))
|
||||||
#define MOCK_DECL(M, n, S, c, tpn) \
|
#define MOCK_DECL(M, n, S, c, tpn) \
|
||||||
tpn boost::function_types::result_type< \
|
tpn boost::function_types::result_type< \
|
||||||
MOCK_FUNCTION_TYPE(S, tpn) >::type M( \
|
MOCK_FUNCTION_TYPE(S, tpn) >::type M( \
|
||||||
MOCK_PARAMS(n, S, tpn) ) c
|
MOCK_PARAMS(n, S, tpn) ) c
|
||||||
|
|
||||||
#define MOCK_METHOD_AUX(M, n, S, t, c, tpn) \
|
#define MOCK_METHOD_AUX(M, n, S, t, c, tpn) \
|
||||||
MOCK_DECL(M, n, S, c, tpn) \
|
MOCK_DECL(M, n, S, c, tpn) \
|
||||||
{ \
|
{ \
|
||||||
BOOST_MPL_ASSERT_RELATION( n, ==, \
|
BOOST_MPL_ASSERT_RELATION( n, ==, \
|
||||||
boost::function_types::function_arity< \
|
boost::function_types::function_arity< \
|
||||||
MOCK_FUNCTION_TYPE(S, tpn) >::value ); \
|
MOCK_FUNCTION_TYPE(S, tpn) >::value ); \
|
||||||
return MOCK_ANONYMOUS_HELPER(t)( \
|
return MOCK_ANONYMOUS_HELPER(t)( \
|
||||||
BOOST_PP_ENUM_PARAMS(n, p) ); \
|
BOOST_PP_ENUM_PARAMS(n, p) ); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define MOCK_METHOD_EXT(M, n, S, t) \
|
#define MOCK_METHOD_EXT(M, n, S, t) \
|
||||||
MOCK_METHOD_AUX(M, n, S, t,,) \
|
MOCK_METHOD_AUX(M, n, S, t,,) \
|
||||||
MOCK_METHOD_AUX(M, n, S, t, const,) \
|
MOCK_METHOD_AUX(M, n, S, t, const,) \
|
||||||
MOCK_METHOD_HELPER(S, t,)
|
MOCK_METHOD_HELPER(S, t,)
|
||||||
#define MOCK_CONST_METHOD_EXT(M, n, S, t) \
|
#define MOCK_CONST_METHOD_EXT(M, n, S, t) \
|
||||||
MOCK_METHOD_AUX(M, n, S, t, const,) \
|
MOCK_METHOD_AUX(M, n, S, t, const,) \
|
||||||
MOCK_METHOD_HELPER(S, t,)
|
MOCK_METHOD_HELPER(S, t,)
|
||||||
#define MOCK_NON_CONST_METHOD_EXT(M, n, S, t) \
|
#define MOCK_NON_CONST_METHOD_EXT(M, n, S, t) \
|
||||||
MOCK_METHOD_AUX(M, n, S, t,,) \
|
MOCK_METHOD_AUX(M, n, S, t,,) \
|
||||||
MOCK_METHOD_HELPER(S, t,)
|
MOCK_METHOD_HELPER(S, t,)
|
||||||
|
|
||||||
#define MOCK_METHOD_EXT_TPL(M, n, S, t) \
|
#define MOCK_METHOD_EXT_TPL(M, n, S, t) \
|
||||||
MOCK_METHOD_AUX(M, n, S, t,, typename) \
|
MOCK_METHOD_AUX(M, n, S, t,, typename) \
|
||||||
MOCK_METHOD_AUX(M, n, S, t, const, typename) \
|
MOCK_METHOD_AUX(M, n, S, t, const, typename) \
|
||||||
MOCK_METHOD_HELPER(S, t, typename)
|
MOCK_METHOD_HELPER(S, t, typename)
|
||||||
#define MOCK_CONST_METHOD_EXT_TPL(M, n, S, t) \
|
#define MOCK_CONST_METHOD_EXT_TPL(M, n, S, t) \
|
||||||
MOCK_METHOD_AUX(M, n, S, t, const, typename) \
|
MOCK_METHOD_AUX(M, n, S, t, const, typename) \
|
||||||
MOCK_METHOD_HELPER(S, t, typename)
|
MOCK_METHOD_HELPER(S, t, typename)
|
||||||
#define MOCK_NON_CONST_METHOD_EXT_TPL(M, n, S, t) \
|
#define MOCK_NON_CONST_METHOD_EXT_TPL(M, n, S, t) \
|
||||||
MOCK_METHOD_AUX(M, n, S, t,, typename) \
|
MOCK_METHOD_AUX(M, n, S, t,, typename) \
|
||||||
MOCK_METHOD_HELPER(S, t, typename)
|
MOCK_METHOD_HELPER(S, t, typename)
|
||||||
|
|
||||||
#define MOCK_CONVERSION_OPERATOR(M, T, t) \
|
#define MOCK_CONVERSION_OPERATOR(M, T, t) \
|
||||||
M T() const { return MOCK_ANONYMOUS_HELPER(t)(); } \
|
M T() const { return MOCK_ANONYMOUS_HELPER(t)(); } \
|
||||||
M T() { return MOCK_ANONYMOUS_HELPER(t)(); } \
|
M T() { return MOCK_ANONYMOUS_HELPER(t)(); } \
|
||||||
MOCK_METHOD_HELPER(T(), t,)
|
MOCK_METHOD_HELPER(T(), t,)
|
||||||
#define MOCK_CONST_CONVERSION_OPERATOR(M, T, t) \
|
#define MOCK_CONST_CONVERSION_OPERATOR(M, T, t) \
|
||||||
M T() const { return MOCK_ANONYMOUS_HELPER(t)(); } \
|
M T() const { return MOCK_ANONYMOUS_HELPER(t)(); } \
|
||||||
MOCK_METHOD_HELPER(T(), t,)
|
MOCK_METHOD_HELPER(T(), t,)
|
||||||
#define MOCK_NON_CONST_CONVERSION_OPERATOR(M, T, t) \
|
#define MOCK_NON_CONST_CONVERSION_OPERATOR(M, T, t) \
|
||||||
M T() { return MOCK_ANONYMOUS_HELPER(t)(); } \
|
M T() { return MOCK_ANONYMOUS_HELPER(t)(); } \
|
||||||
MOCK_METHOD_HELPER(T(), t,)
|
MOCK_METHOD_HELPER(T(), t,)
|
||||||
|
|
||||||
#define MOCK_CONVERSION_OPERATOR_TPL(M, T, t) \
|
#define MOCK_CONVERSION_OPERATOR_TPL(M, T, t) \
|
||||||
M T() const { return MOCK_ANONYMOUS_HELPER(t)(); } \
|
M T() const { return MOCK_ANONYMOUS_HELPER(t)(); } \
|
||||||
M T() { return MOCK_ANONYMOUS_HELPER(t)(); } \
|
M T() { return MOCK_ANONYMOUS_HELPER(t)(); } \
|
||||||
MOCK_METHOD_HELPER(T(), t, typename)
|
MOCK_METHOD_HELPER(T(), t, typename)
|
||||||
#define MOCK_CONST_CONVERSION_OPERATOR_TPL(M, T, t) \
|
#define MOCK_CONST_CONVERSION_OPERATOR_TPL(M, T, t) \
|
||||||
M T() const { return MOCK_ANONYMOUS_HELPER(t)(); } \
|
M T() const { return MOCK_ANONYMOUS_HELPER(t)(); } \
|
||||||
MOCK_METHOD_HELPER(T(), t, typename)
|
MOCK_METHOD_HELPER(T(), t, typename)
|
||||||
#define MOCK_NON_CONST_CONVERSION_OPERATOR_TPL(M, T, t) \
|
#define MOCK_NON_CONST_CONVERSION_OPERATOR_TPL(M, T, t) \
|
||||||
M T() { return MOCK_ANONYMOUS_HELPER(t)(); } \
|
M T() { return MOCK_ANONYMOUS_HELPER(t)(); } \
|
||||||
MOCK_METHOD_HELPER(T(), t, typename)
|
MOCK_METHOD_HELPER(T(), t, typename)
|
||||||
|
|
||||||
#define MOCK_FUNCTION_HELPER(S, t, s, tpn) \
|
#define MOCK_FUNCTION_HELPER(S, t, s, tpn) \
|
||||||
s mock::detail::function< MOCK_FUNCTION_TYPE(S, tpn) >& t##_mock( \
|
s mock::detail::function< MOCK_FUNCTION_TYPE(S, tpn) >& t##_mock( \
|
||||||
mock::detail::context& context, \
|
mock::detail::context& context, \
|
||||||
boost::unit_test::const_string instance ) \
|
boost::unit_test::const_string instance ) \
|
||||||
{ \
|
{ \
|
||||||
static mock::detail::function< MOCK_FUNCTION_TYPE(S, tpn) > f; \
|
static mock::detail::function< MOCK_FUNCTION_TYPE(S, tpn) > f; \
|
||||||
return f( context, instance ); \
|
return f( context, instance ); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define MOCK_CONSTRUCTOR_AUX(T, n, A, t, tpn) \
|
#define MOCK_CONSTRUCTOR_AUX(T, n, A, t, tpn) \
|
||||||
T( MOCK_PARAMS(n, void A, tpn) ) \
|
T( MOCK_PARAMS(n, void A, tpn) ) \
|
||||||
{ \
|
{ \
|
||||||
MOCK_HELPER(t)( BOOST_PP_ENUM_PARAMS(n, p) ); \
|
MOCK_HELPER(t)( BOOST_PP_ENUM_PARAMS(n, p) ); \
|
||||||
} \
|
} \
|
||||||
MOCK_FUNCTION_HELPER(void A, t, static, tpn)
|
MOCK_FUNCTION_HELPER(void A, t, static, tpn)
|
||||||
|
|
||||||
#define MOCK_CONSTRUCTOR(T, n, A, t) \
|
#define MOCK_CONSTRUCTOR(T, n, A, t) \
|
||||||
MOCK_CONSTRUCTOR_AUX(T, n, A, t,)
|
MOCK_CONSTRUCTOR_AUX(T, n, A, t,)
|
||||||
#define MOCK_CONSTRUCTOR_TPL(T, n, A, t) \
|
#define MOCK_CONSTRUCTOR_TPL(T, n, A, t) \
|
||||||
MOCK_CONSTRUCTOR_AUX(T, n, A, t, typename)
|
MOCK_CONSTRUCTOR_AUX(T, n, A, t, typename)
|
||||||
|
|
||||||
#define MOCK_DESTRUCTOR(T, t) \
|
#define MOCK_DESTRUCTOR(T, t) \
|
||||||
T() { try { MOCK_ANONYMOUS_HELPER(t)(); } catch( ... ) {} } \
|
T() { try { MOCK_ANONYMOUS_HELPER(t)(); } catch( ... ) {} } \
|
||||||
MOCK_METHOD_HELPER(void(), t,)
|
MOCK_METHOD_HELPER(void(), t,)
|
||||||
|
|
||||||
#define MOCK_FUNCTION_AUX(F, n, S, t, s, tpn) \
|
#define MOCK_FUNCTION_AUX(F, n, S, t, s, tpn) \
|
||||||
MOCK_FUNCTION_HELPER(S, t, s, tpn) \
|
MOCK_FUNCTION_HELPER(S, t, s, tpn) \
|
||||||
s MOCK_DECL(F, n, S,,tpn) \
|
s MOCK_DECL(F, n, S,,tpn) \
|
||||||
{ \
|
{ \
|
||||||
BOOST_MPL_ASSERT_RELATION( n, ==, \
|
BOOST_MPL_ASSERT_RELATION( n, ==, \
|
||||||
boost::function_types::function_arity< \
|
boost::function_types::function_arity< \
|
||||||
MOCK_FUNCTION_TYPE(S, tpn) >::value ); \
|
MOCK_FUNCTION_TYPE(S, tpn) >::value ); \
|
||||||
return MOCK_HELPER(t)( BOOST_PP_ENUM_PARAMS(n, p) ); \
|
return MOCK_HELPER(t)( BOOST_PP_ENUM_PARAMS(n, p) ); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MOCK_VARIADIC_MACROS
|
#ifdef MOCK_VARIADIC_MACROS
|
||||||
|
|
||||||
#define MOCK_VARIADIC_ELEM_0(e0, ...) e0
|
#define MOCK_VARIADIC_ELEM_0(e0, ...) e0
|
||||||
#define MOCK_VARIADIC_ELEM_1(e0, e1, ...) e1
|
#define MOCK_VARIADIC_ELEM_1(e0, e1, ...) e1
|
||||||
#define MOCK_VARIADIC_ELEM_2(e0, e1, e2, ...) e2
|
#define MOCK_VARIADIC_ELEM_2(e0, e1, e2, ...) e2
|
||||||
|
|
||||||
#define MOCK_METHOD(M, ... ) \
|
#define MOCK_METHOD(M, ... ) \
|
||||||
MOCK_METHOD_EXT(M, \
|
MOCK_METHOD_EXT(M, \
|
||||||
MOCK_VARIADIC_ELEM_0(__VA_ARGS__ ), \
|
MOCK_VARIADIC_ELEM_0(__VA_ARGS__ ), \
|
||||||
MOCK_VARIADIC_ELEM_1(__VA_ARGS__, MOCK_SIGNATURE(M)), \
|
MOCK_VARIADIC_ELEM_1(__VA_ARGS__, MOCK_SIGNATURE(M)), \
|
||||||
MOCK_VARIADIC_ELEM_2(__VA_ARGS__, M, M))
|
MOCK_VARIADIC_ELEM_2(__VA_ARGS__, M, M))
|
||||||
#define MOCK_CONST_METHOD(M, n, ... ) \
|
#define MOCK_CONST_METHOD(M, n, ... ) \
|
||||||
MOCK_CONST_METHOD_EXT(M, n, \
|
MOCK_CONST_METHOD_EXT(M, n, \
|
||||||
MOCK_VARIADIC_ELEM_0(__VA_ARGS__), \
|
MOCK_VARIADIC_ELEM_0(__VA_ARGS__), \
|
||||||
MOCK_VARIADIC_ELEM_1(__VA_ARGS__, M))
|
MOCK_VARIADIC_ELEM_1(__VA_ARGS__, M))
|
||||||
#define MOCK_NON_CONST_METHOD(M, n, ... ) \
|
#define MOCK_NON_CONST_METHOD(M, n, ... ) \
|
||||||
MOCK_NON_CONST_METHOD_EXT(M, n, \
|
MOCK_NON_CONST_METHOD_EXT(M, n, \
|
||||||
MOCK_VARIADIC_ELEM_0(__VA_ARGS__), \
|
MOCK_VARIADIC_ELEM_0(__VA_ARGS__), \
|
||||||
MOCK_VARIADIC_ELEM_1(__VA_ARGS__, M))
|
MOCK_VARIADIC_ELEM_1(__VA_ARGS__, M))
|
||||||
|
|
||||||
#define MOCK_METHOD_TPL(M, n, ... ) \
|
#define MOCK_METHOD_TPL(M, n, ... ) \
|
||||||
MOCK_METHOD_EXT_TPL(M, n, \
|
MOCK_METHOD_EXT_TPL(M, n, \
|
||||||
MOCK_VARIADIC_ELEM_0(__VA_ARGS__), \
|
MOCK_VARIADIC_ELEM_0(__VA_ARGS__), \
|
||||||
MOCK_VARIADIC_ELEM_1(__VA_ARGS__, M))
|
MOCK_VARIADIC_ELEM_1(__VA_ARGS__, M))
|
||||||
#define MOCK_CONST_METHOD_TPL(M, n, ... ) \
|
#define MOCK_CONST_METHOD_TPL(M, n, ... ) \
|
||||||
MOCK_CONST_METHOD_EXT_TPL(M, n, \
|
MOCK_CONST_METHOD_EXT_TPL(M, n, \
|
||||||
MOCK_VARIADIC_ELEM_0(__VA_ARGS__), \
|
MOCK_VARIADIC_ELEM_0(__VA_ARGS__), \
|
||||||
MOCK_VARIADIC_ELEM_1(__VA_ARGS__, M))
|
MOCK_VARIADIC_ELEM_1(__VA_ARGS__, M))
|
||||||
#define MOCK_NON_CONST_METHOD_TPL(M, n, ... ) \
|
#define MOCK_NON_CONST_METHOD_TPL(M, n, ... ) \
|
||||||
MOCK_NON_CONST_METHOD_EXT_TPL(M, n, \
|
MOCK_NON_CONST_METHOD_EXT_TPL(M, n, \
|
||||||
MOCK_VARIADIC_ELEM_0(__VA_ARGS__), \
|
MOCK_VARIADIC_ELEM_0(__VA_ARGS__), \
|
||||||
MOCK_VARIADIC_ELEM_1(__VA_ARGS__, M))
|
MOCK_VARIADIC_ELEM_1(__VA_ARGS__, M))
|
||||||
|
|
||||||
#define MOCK_FUNCTION(F, n, ...) \
|
#define MOCK_FUNCTION(F, n, ...) \
|
||||||
MOCK_FUNCTION_AUX(F, n, \
|
MOCK_FUNCTION_AUX(F, n, \
|
||||||
MOCK_VARIADIC_ELEM_0(__VA_ARGS__), \
|
MOCK_VARIADIC_ELEM_0(__VA_ARGS__), \
|
||||||
MOCK_VARIADIC_ELEM_1(__VA_ARGS__, F),,)
|
MOCK_VARIADIC_ELEM_1(__VA_ARGS__, F),,)
|
||||||
|
|
||||||
#define MOCK_STATIC_METHOD(F, n, ...) \
|
#define MOCK_STATIC_METHOD(F, n, ...) \
|
||||||
MOCK_FUNCTION_AUX(F, n, \
|
MOCK_FUNCTION_AUX(F, n, \
|
||||||
MOCK_VARIADIC_ELEM_0(__VA_ARGS__), \
|
MOCK_VARIADIC_ELEM_0(__VA_ARGS__), \
|
||||||
MOCK_VARIADIC_ELEM_1(__VA_ARGS__, F), static,)
|
MOCK_VARIADIC_ELEM_1(__VA_ARGS__, F), static,)
|
||||||
|
|
||||||
#define MOCK_STATIC_METHOD_TPL(F, n, ...) \
|
#define MOCK_STATIC_METHOD_TPL(F, n, ...) \
|
||||||
MOCK_FUNCTION_AUX(F, n, \
|
MOCK_FUNCTION_AUX(F, n, \
|
||||||
MOCK_VARIADIC_ELEM_0(__VA_ARGS__), \
|
MOCK_VARIADIC_ELEM_0(__VA_ARGS__), \
|
||||||
MOCK_VARIADIC_ELEM_1(__VA_ARGS__, F), \
|
MOCK_VARIADIC_ELEM_1(__VA_ARGS__, F), \
|
||||||
static, typename)
|
static, typename)
|
||||||
|
|
||||||
#else // MOCK_VARIADIC_MACROS
|
#else // MOCK_VARIADIC_MACROS
|
||||||
|
|
||||||
#define MOCK_METHOD(M, n) \
|
#define MOCK_METHOD(M, n) \
|
||||||
MOCK_METHOD_EXT(M, n, MOCK_SIGNATURE(M), M)
|
MOCK_METHOD_EXT(M, n, MOCK_SIGNATURE(M), M)
|
||||||
|
|
||||||
#define MOCK_FUNCTION(F, n, S, t) \
|
#define MOCK_FUNCTION(F, n, S, t) \
|
||||||
MOCK_FUNCTION_AUX(F, n, S, t,,)
|
MOCK_FUNCTION_AUX(F, n, S, t,,)
|
||||||
|
|
||||||
#define MOCK_STATIC_METHOD(F, n, S, t) \
|
#define MOCK_STATIC_METHOD(F, n, S, t) \
|
||||||
MOCK_FUNCTION_AUX(F, n, S, t, static,)
|
MOCK_FUNCTION_AUX(F, n, S, t, static,)
|
||||||
#define MOCK_STATIC_METHOD_TPL(F, n, S, t) \
|
#define MOCK_STATIC_METHOD_TPL(F, n, S, t) \
|
||||||
MOCK_FUNCTION_AUX(F, n, S, t, static, typename)
|
MOCK_FUNCTION_AUX(F, n, S, t, static, typename)
|
||||||
|
|
||||||
#endif // MOCK_VARIADIC_MACROS
|
#endif // MOCK_VARIADIC_MACROS
|
||||||
|
|
||||||
#define MOCK_EXPECT(t) MOCK_HELPER(t).expect( __FILE__, __LINE__ )
|
#define MOCK_EXPECT(t) MOCK_HELPER(t).expect( __FILE__, __LINE__ )
|
||||||
#define MOCK_RESET(t) MOCK_HELPER(t).reset( __FILE__, __LINE__ )
|
#define MOCK_RESET(t) MOCK_HELPER(t).reset( __FILE__, __LINE__ )
|
||||||
#define MOCK_VERIFY(t) MOCK_HELPER(t).verify( __FILE__, __LINE__ )
|
#define MOCK_VERIFY(t) MOCK_HELPER(t).verify( __FILE__, __LINE__ )
|
||||||
|
|
||||||
#endif // MOCK_MOCK_HPP_INCLUDED
|
#endif // MOCK_MOCK_HPP_INCLUDED
|
||||||
|
|
@ -1,74 +1,74 @@
|
||||||
// http://turtle.sourceforge.net
|
// http://turtle.sourceforge.net
|
||||||
//
|
//
|
||||||
// Copyright Mathieu Champlon 2008
|
// Copyright Mathieu Champlon 2008
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#ifndef MOCK_OBJECT_HPP_INCLUDED
|
#ifndef MOCK_OBJECT_HPP_INCLUDED
|
||||||
#define MOCK_OBJECT_HPP_INCLUDED
|
#define MOCK_OBJECT_HPP_INCLUDED
|
||||||
|
|
||||||
#include "config.hpp"
|
#include "config.hpp"
|
||||||
#include "detail/root.hpp"
|
#include "detail/root.hpp"
|
||||||
#include "detail/type_name.hpp"
|
#include "detail/type_name.hpp"
|
||||||
#include "detail/object_impl.hpp"
|
#include "detail/object_impl.hpp"
|
||||||
#include <boost/test/utils/basic_cstring/basic_cstring.hpp>
|
#include <boost/test/utils/basic_cstring/basic_cstring.hpp>
|
||||||
#include <boost/type_traits/is_base_of.hpp>
|
#include <boost/type_traits/is_base_of.hpp>
|
||||||
#include <boost/utility/enable_if.hpp>
|
#include <boost/utility/enable_if.hpp>
|
||||||
#include <boost/make_shared.hpp>
|
#include <boost/make_shared.hpp>
|
||||||
#include <boost/optional.hpp>
|
#include <boost/optional.hpp>
|
||||||
|
|
||||||
namespace mock
|
namespace mock
|
||||||
{
|
{
|
||||||
class object;
|
class object;
|
||||||
|
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
template< typename E >
|
template< typename E >
|
||||||
E& configure( const object& o, E& e,
|
E& configure( const object& o, E& e,
|
||||||
boost::unit_test::const_string instance,
|
boost::unit_test::const_string instance,
|
||||||
boost::optional< type_name > type,
|
boost::optional< type_name > type,
|
||||||
boost::unit_test::const_string name );
|
boost::unit_test::const_string name );
|
||||||
|
|
||||||
template< typename T, typename E >
|
template< typename T, typename E >
|
||||||
E& configure( const T& t, E& e,
|
E& configure( const T& t, E& e,
|
||||||
boost::unit_test::const_string instance,
|
boost::unit_test::const_string instance,
|
||||||
boost::optional< type_name > type,
|
boost::optional< type_name > type,
|
||||||
boost::unit_test::const_string name,
|
boost::unit_test::const_string name,
|
||||||
typename boost::disable_if<
|
typename boost::disable_if<
|
||||||
typename boost::is_base_of< object, T >
|
typename boost::is_base_of< object, T >
|
||||||
>::type* = 0 )
|
>::type* = 0 )
|
||||||
{
|
{
|
||||||
e.configure( detail::root, &t, instance, type, name );
|
e.configure( detail::root, &t, instance, type, name );
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
class object
|
class object
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
object()
|
object()
|
||||||
: impl_( boost::make_shared< detail::object_impl >() )
|
: impl_( boost::make_shared< detail::object_impl >() )
|
||||||
{}
|
{}
|
||||||
protected:
|
protected:
|
||||||
~object()
|
~object()
|
||||||
{}
|
{}
|
||||||
public:
|
public:
|
||||||
boost::shared_ptr< detail::object_impl > impl_;
|
boost::shared_ptr< detail::object_impl > impl_;
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
template< typename E >
|
template< typename E >
|
||||||
E& configure( const object& o, E& e,
|
E& configure( const object& o, E& e,
|
||||||
boost::unit_test::const_string instance,
|
boost::unit_test::const_string instance,
|
||||||
boost::optional< type_name > type,
|
boost::optional< type_name > type,
|
||||||
boost::unit_test::const_string name )
|
boost::unit_test::const_string name )
|
||||||
{
|
{
|
||||||
e.configure( *o.impl_, o.impl_.get(), instance, type, name );
|
e.configure( *o.impl_, o.impl_.get(), instance, type, name );
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // mock
|
} // mock
|
||||||
|
|
||||||
#endif // MOCK_OBJECT_HPP_INCLUDED
|
#endif // MOCK_OBJECT_HPP_INCLUDED
|
||||||
|
|
@ -1,34 +1,34 @@
|
||||||
// http://turtle.sourceforge.net
|
// http://turtle.sourceforge.net
|
||||||
//
|
//
|
||||||
// Copyright Mathieu Champlon 2012
|
// Copyright Mathieu Champlon 2012
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#ifndef MOCK_RESET_HPP_INCLUDED
|
#ifndef MOCK_RESET_HPP_INCLUDED
|
||||||
#define MOCK_RESET_HPP_INCLUDED
|
#define MOCK_RESET_HPP_INCLUDED
|
||||||
|
|
||||||
#include "config.hpp"
|
#include "config.hpp"
|
||||||
#include "object.hpp"
|
#include "object.hpp"
|
||||||
#include "detail/root.hpp"
|
#include "detail/root.hpp"
|
||||||
#include "detail/functor.hpp"
|
#include "detail/functor.hpp"
|
||||||
|
|
||||||
namespace mock
|
namespace mock
|
||||||
{
|
{
|
||||||
inline void reset()
|
inline void reset()
|
||||||
{
|
{
|
||||||
detail::root.reset();
|
detail::root.reset();
|
||||||
}
|
}
|
||||||
inline void reset( const object& o )
|
inline void reset( const object& o )
|
||||||
{
|
{
|
||||||
o.impl_->reset();
|
o.impl_->reset();
|
||||||
}
|
}
|
||||||
template< typename Signature >
|
template< typename Signature >
|
||||||
void reset( detail::functor< Signature >& f )
|
void reset( detail::functor< Signature >& f )
|
||||||
{
|
{
|
||||||
f.reset();
|
f.reset();
|
||||||
}
|
}
|
||||||
} // mock
|
} // mock
|
||||||
|
|
||||||
#endif // MOCK_RESET_HPP_INCLUDED
|
#endif // MOCK_RESET_HPP_INCLUDED
|
||||||
|
|
@ -1,29 +1,29 @@
|
||||||
// http://turtle.sourceforge.net
|
// http://turtle.sourceforge.net
|
||||||
//
|
//
|
||||||
// Copyright Mathieu Champlon 2008
|
// Copyright Mathieu Champlon 2008
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#ifndef MOCK_SEQUENCE_HPP_INCLUDED
|
#ifndef MOCK_SEQUENCE_HPP_INCLUDED
|
||||||
#define MOCK_SEQUENCE_HPP_INCLUDED
|
#define MOCK_SEQUENCE_HPP_INCLUDED
|
||||||
|
|
||||||
#include "config.hpp"
|
#include "config.hpp"
|
||||||
#include "detail/sequence_impl.hpp"
|
#include "detail/sequence_impl.hpp"
|
||||||
#include <boost/make_shared.hpp>
|
#include <boost/make_shared.hpp>
|
||||||
|
|
||||||
namespace mock
|
namespace mock
|
||||||
{
|
{
|
||||||
class sequence
|
class sequence
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
sequence()
|
sequence()
|
||||||
: impl_( boost::make_shared< detail::sequence_impl >() )
|
: impl_( boost::make_shared< detail::sequence_impl >() )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
boost::shared_ptr< detail::sequence_impl > impl_;
|
boost::shared_ptr< detail::sequence_impl > impl_;
|
||||||
};
|
};
|
||||||
} // mock
|
} // mock
|
||||||
|
|
||||||
#endif // MOCK_SEQUENCE_HPP_INCLUDED
|
#endif // MOCK_SEQUENCE_HPP_INCLUDED
|
||||||
|
|
@ -1,142 +1,142 @@
|
||||||
// http://turtle.sourceforge.net
|
// http://turtle.sourceforge.net
|
||||||
//
|
//
|
||||||
// Copyright Mathieu Champlon 2011
|
// Copyright Mathieu Champlon 2011
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#ifndef MOCK_STREAM_HPP_INCLUDED
|
#ifndef MOCK_STREAM_HPP_INCLUDED
|
||||||
#define MOCK_STREAM_HPP_INCLUDED
|
#define MOCK_STREAM_HPP_INCLUDED
|
||||||
|
|
||||||
#include "config.hpp"
|
#include "config.hpp"
|
||||||
#include <boost/noncopyable.hpp>
|
#include <boost/noncopyable.hpp>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
|
|
||||||
namespace mock
|
namespace mock
|
||||||
{
|
{
|
||||||
struct stream
|
struct stream
|
||||||
{
|
{
|
||||||
explicit stream( std::ostream& s )
|
explicit stream( std::ostream& s )
|
||||||
: s_( &s )
|
: s_( &s )
|
||||||
{}
|
{}
|
||||||
std::ostream* s_;
|
std::ostream* s_;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef MOCK_USE_CONVERSIONS
|
#ifdef MOCK_USE_CONVERSIONS
|
||||||
|
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
namespace conversion
|
namespace conversion
|
||||||
{
|
{
|
||||||
struct sink
|
struct sink
|
||||||
{
|
{
|
||||||
template< typename T >
|
template< typename T >
|
||||||
sink( const T& )
|
sink( const T& )
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
inline std::ostream& operator<<( std::ostream& s, const sink& )
|
inline std::ostream& operator<<( std::ostream& s, const sink& )
|
||||||
{
|
{
|
||||||
return s << '?';
|
return s << '?';
|
||||||
}
|
}
|
||||||
|
|
||||||
struct holder : boost::noncopyable
|
struct holder : boost::noncopyable
|
||||||
{
|
{
|
||||||
virtual ~holder()
|
virtual ~holder()
|
||||||
{}
|
{}
|
||||||
virtual void serialize( std::ostream& s ) const = 0;
|
virtual void serialize( std::ostream& s ) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
template< typename T >
|
template< typename T >
|
||||||
struct holder_imp : holder
|
struct holder_imp : holder
|
||||||
{
|
{
|
||||||
explicit holder_imp( const T& t )
|
explicit holder_imp( const T& t )
|
||||||
: t_( t )
|
: t_( t )
|
||||||
{}
|
{}
|
||||||
virtual void serialize( std::ostream& s ) const
|
virtual void serialize( std::ostream& s ) const
|
||||||
{
|
{
|
||||||
// if an error about an ambiguous conversion is generated by the
|
// if an error about an ambiguous conversion is generated by the
|
||||||
// line below the solution is to add a serialization operator to a
|
// line below the solution is to add a serialization operator to a
|
||||||
// mock::stream for T
|
// mock::stream for T
|
||||||
s << t_;
|
s << t_;
|
||||||
}
|
}
|
||||||
const T& t_;
|
const T& t_;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct any : boost::noncopyable
|
struct any : boost::noncopyable
|
||||||
{
|
{
|
||||||
template< typename T >
|
template< typename T >
|
||||||
any( const T& t )
|
any( const T& t )
|
||||||
: h_( new holder_imp< T >( t ) )
|
: h_( new holder_imp< T >( t ) )
|
||||||
{}
|
{}
|
||||||
~any()
|
~any()
|
||||||
{
|
{
|
||||||
delete h_;
|
delete h_;
|
||||||
}
|
}
|
||||||
holder* h_;
|
holder* h_;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline stream& operator<<( stream& s, const detail::conversion::any& d )
|
inline stream& operator<<( stream& s, const detail::conversion::any& d )
|
||||||
{
|
{
|
||||||
d.h_->serialize( *s.s_ );
|
d.h_->serialize( *s.s_ );
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else // MOCK_USE_CONVERSIONS
|
#else // MOCK_USE_CONVERSIONS
|
||||||
|
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
namespace conversion
|
namespace conversion
|
||||||
{
|
{
|
||||||
template< typename S, typename T >
|
template< typename S, typename T >
|
||||||
S& operator<<( S &s, const T& )
|
S& operator<<( S &s, const T& )
|
||||||
{
|
{
|
||||||
return s << '?';
|
return s << '?';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template< typename T >
|
template< typename T >
|
||||||
stream& operator<<( stream& s, const T& t )
|
stream& operator<<( stream& s, const T& t )
|
||||||
{
|
{
|
||||||
using namespace detail::conversion;
|
using namespace detail::conversion;
|
||||||
*s.s_ << t;
|
*s.s_ << t;
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // MOCK_USE_CONVERSIONS
|
#endif // MOCK_USE_CONVERSIONS
|
||||||
|
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
template< typename T >
|
template< typename T >
|
||||||
void serialize( stream& s, const T& t )
|
void serialize( stream& s, const T& t )
|
||||||
{
|
{
|
||||||
// if an error about an ambiguous conversion is generated by the
|
// if an error about an ambiguous conversion is generated by the
|
||||||
// line below the solution is to add a serialization operator to a
|
// line below the solution is to add a serialization operator to a
|
||||||
// mock::stream for T
|
// mock::stream for T
|
||||||
s << t;
|
s << t;
|
||||||
}
|
}
|
||||||
inline void serialize( stream& s, bool b )
|
inline void serialize( stream& s, bool b )
|
||||||
{
|
{
|
||||||
s << (b ? "true" : "false");
|
s << (b ? "true" : "false");
|
||||||
}
|
}
|
||||||
template< typename C, typename T, typename A >
|
template< typename C, typename T, typename A >
|
||||||
void serialize( stream& s, const std::basic_string< C, T, A >& str )
|
void serialize( stream& s, const std::basic_string< C, T, A >& str )
|
||||||
{
|
{
|
||||||
s << '"' << str << '"';
|
s << '"' << str << '"';
|
||||||
}
|
}
|
||||||
inline void serialize( stream& s, const char* const str )
|
inline void serialize( stream& s, const char* const str )
|
||||||
{
|
{
|
||||||
s << '"' << str << '"';
|
s << '"' << str << '"';
|
||||||
}
|
}
|
||||||
inline void serialize( stream& s, unsigned char c )
|
inline void serialize( stream& s, unsigned char c )
|
||||||
{
|
{
|
||||||
s << static_cast< int >( c );
|
s << static_cast< int >( c );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // mock
|
} // mock
|
||||||
|
|
||||||
#endif // MOCK_STREAM_HPP_INCLUDED
|
#endif // MOCK_STREAM_HPP_INCLUDED
|
||||||
|
|
@ -1,34 +1,34 @@
|
||||||
// http://turtle.sourceforge.net
|
// http://turtle.sourceforge.net
|
||||||
//
|
//
|
||||||
// Copyright Mathieu Champlon 2012
|
// Copyright Mathieu Champlon 2012
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#ifndef MOCK_VERIFY_HPP_INCLUDED
|
#ifndef MOCK_VERIFY_HPP_INCLUDED
|
||||||
#define MOCK_VERIFY_HPP_INCLUDED
|
#define MOCK_VERIFY_HPP_INCLUDED
|
||||||
|
|
||||||
#include "config.hpp"
|
#include "config.hpp"
|
||||||
#include "object.hpp"
|
#include "object.hpp"
|
||||||
#include "detail/root.hpp"
|
#include "detail/root.hpp"
|
||||||
#include "detail/functor.hpp"
|
#include "detail/functor.hpp"
|
||||||
|
|
||||||
namespace mock
|
namespace mock
|
||||||
{
|
{
|
||||||
inline bool verify()
|
inline bool verify()
|
||||||
{
|
{
|
||||||
return detail::root.verify();
|
return detail::root.verify();
|
||||||
}
|
}
|
||||||
inline bool verify( const object& o )
|
inline bool verify( const object& o )
|
||||||
{
|
{
|
||||||
return o.impl_->verify();
|
return o.impl_->verify();
|
||||||
}
|
}
|
||||||
template< typename Signature >
|
template< typename Signature >
|
||||||
bool verify( const detail::functor< Signature >& f )
|
bool verify( const detail::functor< Signature >& f )
|
||||||
{
|
{
|
||||||
return f.verify();
|
return f.verify();
|
||||||
}
|
}
|
||||||
} // mock
|
} // mock
|
||||||
|
|
||||||
#endif // MOCK_VERIFY_HPP_INCLUDED
|
#endif // MOCK_VERIFY_HPP_INCLUDED
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
<!-- boost-no-inspect -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="refresh" content="0; URL=doc/html/index.html">
|
<meta http-equiv="refresh" content="0; URL=doc/html/index.html">
|
||||||
|
|
@ -30,7 +30,7 @@ rule run-test ( name )
|
||||||
run $(name) undefined.cpp /boost//unit_test_framework : : : <define>MOCK_USE_CONVERSIONS : $(name)_use_conversions ;
|
run $(name) undefined.cpp /boost//unit_test_framework : : : <define>MOCK_USE_CONVERSIONS : $(name)_use_conversions ;
|
||||||
run $(name) undefined.cpp /boost//unit_test_framework : : : <define>MOCK_NO_DECLTYPE : $(name)_no_decltype ;
|
run $(name) undefined.cpp /boost//unit_test_framework : : : <define>MOCK_NO_DECLTYPE : $(name)_no_decltype ;
|
||||||
run $(name) undefined.cpp /boost//unit_test_framework : : : <define>MOCK_NO_VARIADIC_MACROS : $(name)_no_variadic_macros ;
|
run $(name) undefined.cpp /boost//unit_test_framework : : : <define>MOCK_NO_VARIADIC_MACROS : $(name)_no_variadic_macros ;
|
||||||
run $(name) undefined.cpp /boost//unit_test_framework : : : <define>MOCK_THREAD_SAFE : $(name)_thread_safe ;
|
run $(name) undefined.cpp /boost//unit_test_framework /boost//thread : : : <define>MOCK_THREAD_SAFE <define>BOOST_THREAD_USES_MOVE : $(name)_thread_safe ;
|
||||||
}
|
}
|
||||||
|
|
||||||
rule run-tests
|
rule run-tests
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
// http://turtle.sourceforge.net
|
// http://turtle.sourceforge.net
|
||||||
//
|
//
|
||||||
// Copyright Mathieu Champlon 2011
|
// Copyright Mathieu Champlon 2011
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#include <turtle/mock.hpp>
|
#include <turtle/mock.hpp>
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
// http://turtle.sourceforge.net
|
// http://turtle.sourceforge.net
|
||||||
//
|
//
|
||||||
// Copyright Mathieu Champlon 2011
|
// Copyright Mathieu Champlon 2011
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#define MOCK_MAX_ARGS 10
|
#define MOCK_MAX_ARGS 10
|
||||||
#include <turtle/mock.hpp>
|
#include <turtle/mock.hpp>
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
// http://turtle.sourceforge.net
|
// http://turtle.sourceforge.net
|
||||||
//
|
//
|
||||||
// Copyright Mathieu Champlon 2011
|
// Copyright Mathieu Champlon 2011
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#define MOCK_MAX_ARGS 20
|
#define MOCK_MAX_ARGS 20
|
||||||
#include <turtle/mock.hpp>
|
#include <turtle/mock.hpp>
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
// http://turtle.sourceforge.net
|
// http://turtle.sourceforge.net
|
||||||
//
|
//
|
||||||
// Copyright Mathieu Champlon 2011
|
// Copyright Mathieu Champlon 2011
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#define MOCK_MAX_ARGS 30
|
#define MOCK_MAX_ARGS 30
|
||||||
#include <turtle/mock.hpp>
|
#include <turtle/mock.hpp>
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -1,76 +1,76 @@
|
||||||
// http://turtle.sourceforge.net
|
// http://turtle.sourceforge.net
|
||||||
//
|
//
|
||||||
// Copyright Mathieu Champlon 2008
|
// Copyright Mathieu Champlon 2008
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#include <turtle/detail/invocation.hpp>
|
#include <turtle/detail/invocation.hpp>
|
||||||
#include <boost/test/auto_unit_test.hpp>
|
#include <boost/test/auto_unit_test.hpp>
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE( unlimited )
|
BOOST_AUTO_TEST_CASE( unlimited )
|
||||||
{
|
{
|
||||||
mock::detail::unlimited invocation;
|
mock::detail::unlimited invocation;
|
||||||
BOOST_CHECK( invocation.verify() );
|
BOOST_CHECK( invocation.verify() );
|
||||||
BOOST_CHECK( ! invocation.exhausted() );
|
BOOST_CHECK( ! invocation.exhausted() );
|
||||||
BOOST_CHECK( invocation.invoke() );
|
BOOST_CHECK( invocation.invoke() );
|
||||||
BOOST_CHECK( invocation.verify() );
|
BOOST_CHECK( invocation.verify() );
|
||||||
BOOST_CHECK( ! invocation.exhausted() );
|
BOOST_CHECK( ! invocation.exhausted() );
|
||||||
BOOST_CHECK( invocation.invoke() );
|
BOOST_CHECK( invocation.invoke() );
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE( once )
|
BOOST_AUTO_TEST_CASE( once )
|
||||||
{
|
{
|
||||||
mock::detail::once invocation;
|
mock::detail::once invocation;
|
||||||
BOOST_CHECK( ! invocation.verify() );
|
BOOST_CHECK( ! invocation.verify() );
|
||||||
BOOST_CHECK( ! invocation.exhausted() );
|
BOOST_CHECK( ! invocation.exhausted() );
|
||||||
BOOST_CHECK( invocation.invoke() );
|
BOOST_CHECK( invocation.invoke() );
|
||||||
BOOST_CHECK( invocation.verify() );
|
BOOST_CHECK( invocation.verify() );
|
||||||
BOOST_CHECK( invocation.exhausted() );
|
BOOST_CHECK( invocation.exhausted() );
|
||||||
BOOST_CHECK( ! invocation.invoke() );
|
BOOST_CHECK( ! invocation.invoke() );
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE( never )
|
BOOST_AUTO_TEST_CASE( never )
|
||||||
{
|
{
|
||||||
mock::detail::never invocation;
|
mock::detail::never invocation;
|
||||||
BOOST_CHECK( invocation.verify() );
|
BOOST_CHECK( invocation.verify() );
|
||||||
BOOST_CHECK( invocation.exhausted() );
|
BOOST_CHECK( invocation.exhausted() );
|
||||||
BOOST_CHECK( ! invocation.invoke() );
|
BOOST_CHECK( ! invocation.invoke() );
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE( at_most )
|
BOOST_AUTO_TEST_CASE( at_most )
|
||||||
{
|
{
|
||||||
mock::detail::at_most invocation( 1 );
|
mock::detail::at_most invocation( 1 );
|
||||||
BOOST_CHECK( invocation.verify() );
|
BOOST_CHECK( invocation.verify() );
|
||||||
BOOST_CHECK( ! invocation.exhausted() );
|
BOOST_CHECK( ! invocation.exhausted() );
|
||||||
BOOST_CHECK( invocation.invoke() );
|
BOOST_CHECK( invocation.invoke() );
|
||||||
BOOST_CHECK( invocation.verify() );
|
BOOST_CHECK( invocation.verify() );
|
||||||
BOOST_CHECK( invocation.exhausted() );
|
BOOST_CHECK( invocation.exhausted() );
|
||||||
BOOST_CHECK( ! invocation.invoke() );
|
BOOST_CHECK( ! invocation.invoke() );
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE( at_least )
|
BOOST_AUTO_TEST_CASE( at_least )
|
||||||
{
|
{
|
||||||
mock::detail::at_least invocation( 1 );
|
mock::detail::at_least invocation( 1 );
|
||||||
BOOST_CHECK( ! invocation.verify() );
|
BOOST_CHECK( ! invocation.verify() );
|
||||||
BOOST_CHECK( ! invocation.exhausted() );
|
BOOST_CHECK( ! invocation.exhausted() );
|
||||||
BOOST_CHECK( invocation.invoke() );
|
BOOST_CHECK( invocation.invoke() );
|
||||||
BOOST_CHECK( invocation.verify() );
|
BOOST_CHECK( invocation.verify() );
|
||||||
BOOST_CHECK( ! invocation.exhausted() );
|
BOOST_CHECK( ! invocation.exhausted() );
|
||||||
BOOST_CHECK( invocation.invoke() );
|
BOOST_CHECK( invocation.invoke() );
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE( between )
|
BOOST_AUTO_TEST_CASE( between )
|
||||||
{
|
{
|
||||||
mock::detail::between invocation( 1, 2 );
|
mock::detail::between invocation( 1, 2 );
|
||||||
BOOST_CHECK( ! invocation.verify() );
|
BOOST_CHECK( ! invocation.verify() );
|
||||||
BOOST_CHECK( ! invocation.exhausted() );
|
BOOST_CHECK( ! invocation.exhausted() );
|
||||||
BOOST_CHECK( invocation.invoke() );
|
BOOST_CHECK( invocation.invoke() );
|
||||||
BOOST_CHECK( invocation.verify() );
|
BOOST_CHECK( invocation.verify() );
|
||||||
BOOST_CHECK( ! invocation.exhausted() );
|
BOOST_CHECK( ! invocation.exhausted() );
|
||||||
BOOST_CHECK( invocation.invoke() );
|
BOOST_CHECK( invocation.invoke() );
|
||||||
BOOST_CHECK( invocation.verify() );
|
BOOST_CHECK( invocation.verify() );
|
||||||
BOOST_CHECK( invocation.exhausted() );
|
BOOST_CHECK( invocation.exhausted() );
|
||||||
BOOST_CHECK( ! invocation.invoke() );
|
BOOST_CHECK( ! invocation.invoke() );
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,155 +1,155 @@
|
||||||
// http://turtle.sourceforge.net
|
// http://turtle.sourceforge.net
|
||||||
//
|
//
|
||||||
// Copyright Mathieu Champlon 2009
|
// Copyright Mathieu Champlon 2009
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#include <turtle/detail/is_functor.hpp>
|
#include <turtle/detail/is_functor.hpp>
|
||||||
#include <boost/test/auto_unit_test.hpp>
|
#include <boost/test/auto_unit_test.hpp>
|
||||||
#ifdef BOOST_MSVC
|
#ifdef BOOST_MSVC
|
||||||
#pragma warning( push, 0 )
|
#pragma warning( push, 0 )
|
||||||
#endif
|
#endif
|
||||||
#include <boost/lambda/lambda.hpp>
|
#include <boost/lambda/lambda.hpp>
|
||||||
#include <boost/phoenix/phoenix.hpp>
|
#include <boost/phoenix/phoenix.hpp>
|
||||||
#ifdef BOOST_MSVC
|
#ifdef BOOST_MSVC
|
||||||
#pragma warning( pop )
|
#pragma warning( pop )
|
||||||
#endif
|
#endif
|
||||||
#include <boost/function.hpp>
|
#include <boost/function.hpp>
|
||||||
#include <boost/bind.hpp>
|
#include <boost/bind.hpp>
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
struct declared_but_not_defined;
|
struct declared_but_not_defined;
|
||||||
BOOST_MPL_ASSERT_NOT((
|
BOOST_MPL_ASSERT_NOT((
|
||||||
mock::detail::is_functor< declared_but_not_defined, int > ));
|
mock::detail::is_functor< declared_but_not_defined, int > ));
|
||||||
|
|
||||||
template< typename T >
|
template< typename T >
|
||||||
void is_functor( T )
|
void is_functor( T )
|
||||||
{
|
{
|
||||||
BOOST_MPL_ASSERT(( mock::detail::is_functor< T, int > ));
|
BOOST_MPL_ASSERT(( mock::detail::is_functor< T, int > ));
|
||||||
}
|
}
|
||||||
template< typename T >
|
template< typename T >
|
||||||
void is_not_functor( T )
|
void is_not_functor( T )
|
||||||
{
|
{
|
||||||
BOOST_MPL_ASSERT_NOT(( mock::detail::is_functor< T, int > ));
|
BOOST_MPL_ASSERT_NOT(( mock::detail::is_functor< T, int > ));
|
||||||
}
|
}
|
||||||
|
|
||||||
void f0() {}
|
void f0() {}
|
||||||
bool f1( int ) { return false; }
|
bool f1( int ) { return false; }
|
||||||
bool f2( std::string, int ) { return false; }
|
bool f2( std::string, int ) { return false; }
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE( data_is_not_functor )
|
BOOST_AUTO_TEST_CASE( data_is_not_functor )
|
||||||
{
|
{
|
||||||
is_not_functor( 42 );
|
is_not_functor( 42 );
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE( function_is_functor )
|
BOOST_AUTO_TEST_CASE( function_is_functor )
|
||||||
{
|
{
|
||||||
is_functor( f0 );
|
is_functor( f0 );
|
||||||
is_functor( f1 );
|
is_functor( f1 );
|
||||||
is_functor( f2 );
|
is_functor( f2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE( function_pointer_is_functor )
|
BOOST_AUTO_TEST_CASE( function_pointer_is_functor )
|
||||||
{
|
{
|
||||||
is_functor( &f0 );
|
is_functor( &f0 );
|
||||||
is_functor( &f1 );
|
is_functor( &f1 );
|
||||||
is_functor( &f2 );
|
is_functor( &f2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE( std_ptr_fun_is_functor )
|
BOOST_AUTO_TEST_CASE( std_ptr_fun_is_functor )
|
||||||
{
|
{
|
||||||
is_functor( std::ptr_fun( &f1 ) );
|
is_functor( std::ptr_fun( &f1 ) );
|
||||||
is_functor( std::ptr_fun( &f2 ) );
|
is_functor( std::ptr_fun( &f2 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE( std_bind_first_is_functor )
|
BOOST_AUTO_TEST_CASE( std_bind_first_is_functor )
|
||||||
{
|
{
|
||||||
is_functor( std::bind1st( std::ptr_fun( &f2 ), "" ) );
|
is_functor( std::bind1st( std::ptr_fun( &f2 ), "" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
struct unary_functor0 : public std::unary_function< void, void >
|
struct unary_functor0 : public std::unary_function< void, void >
|
||||||
{};
|
{};
|
||||||
struct unary_functor1 : public std::unary_function< int, void >
|
struct unary_functor1 : public std::unary_function< int, void >
|
||||||
{};
|
{};
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE( std_unary_functor_is_functor )
|
BOOST_AUTO_TEST_CASE( std_unary_functor_is_functor )
|
||||||
{
|
{
|
||||||
is_functor( unary_functor0() );
|
is_functor( unary_functor0() );
|
||||||
is_functor( unary_functor1() );
|
is_functor( unary_functor1() );
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE( boost_bind_is_functor )
|
BOOST_AUTO_TEST_CASE( boost_bind_is_functor )
|
||||||
{
|
{
|
||||||
is_functor( boost::bind( &f0 ) );
|
is_functor( boost::bind( &f0 ) );
|
||||||
is_functor( boost::bind( &f1, _1 ) );
|
is_functor( boost::bind( &f1, _1 ) );
|
||||||
is_functor( boost::bind( &f2, "", _1 ) );
|
is_functor( boost::bind( &f2, "", _1 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE( boost_lambda_is_functor )
|
BOOST_AUTO_TEST_CASE( boost_lambda_is_functor )
|
||||||
{
|
{
|
||||||
is_functor( boost::lambda::_1 < 42 );
|
is_functor( boost::lambda::_1 < 42 );
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE( boost_phoenix_is_functor )
|
BOOST_AUTO_TEST_CASE( boost_phoenix_is_functor )
|
||||||
{
|
{
|
||||||
is_functor( boost::phoenix::arg_names::arg1 < 42 );
|
is_functor( boost::phoenix::arg_names::arg1 < 42 );
|
||||||
is_functor( boost::phoenix::arg_names::_1 < 42 );
|
is_functor( boost::phoenix::arg_names::_1 < 42 );
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE( boost_function_is_functor )
|
BOOST_AUTO_TEST_CASE( boost_function_is_functor )
|
||||||
{
|
{
|
||||||
is_functor( boost::function< void() >() );
|
is_functor( boost::function< void() >() );
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
struct result_type_functor
|
struct result_type_functor
|
||||||
{
|
{
|
||||||
typedef void result_type;
|
typedef void result_type;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE( class_with_result_type_is_functor )
|
BOOST_AUTO_TEST_CASE( class_with_result_type_is_functor )
|
||||||
{
|
{
|
||||||
is_functor( result_type_functor() );
|
is_functor( result_type_functor() );
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
struct sig_functor
|
struct sig_functor
|
||||||
{
|
{
|
||||||
template< typename Args >
|
template< typename Args >
|
||||||
struct sig
|
struct sig
|
||||||
{
|
{
|
||||||
typedef void type;
|
typedef void type;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE( class_with_sig_is_functor )
|
BOOST_AUTO_TEST_CASE( class_with_sig_is_functor )
|
||||||
{
|
{
|
||||||
is_functor( sig_functor() );
|
is_functor( sig_functor() );
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MOCK_LAMBDAS
|
#ifdef MOCK_LAMBDAS
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE( cxx11_lambda_is_functor )
|
BOOST_AUTO_TEST_CASE( cxx11_lambda_is_functor )
|
||||||
{
|
{
|
||||||
is_not_functor( []() {} );
|
is_not_functor( []() {} );
|
||||||
#ifdef MOCK_DECLTYPE
|
#ifdef MOCK_DECLTYPE
|
||||||
is_functor( []( int ) {} );
|
is_functor( []( int ) {} );
|
||||||
#else
|
#else
|
||||||
is_not_functor( []( int ) {} );
|
is_not_functor( []( int ) {} );
|
||||||
#endif
|
#endif
|
||||||
is_not_functor( []( const std::string&, int ) {} );
|
is_not_functor( []( const std::string&, int ) {} );
|
||||||
is_not_functor( []( int, const std::string& ) {} );
|
is_not_functor( []( int, const std::string& ) {} );
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,29 +1,29 @@
|
||||||
// http://turtle.sourceforge.net
|
// http://turtle.sourceforge.net
|
||||||
//
|
//
|
||||||
// Copyright Mathieu Champlon 2012
|
// Copyright Mathieu Champlon 2012
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#include <turtle/detail/signature.hpp>
|
#include <turtle/detail/signature.hpp>
|
||||||
#include <boost/test/auto_unit_test.hpp>
|
#include <boost/test/auto_unit_test.hpp>
|
||||||
#include <boost/mpl/assert.hpp>
|
#include <boost/mpl/assert.hpp>
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
struct base
|
struct base
|
||||||
{
|
{
|
||||||
void method_1();
|
void method_1();
|
||||||
float method_2( int ) const;
|
float method_2( int ) const;
|
||||||
};
|
};
|
||||||
typedef base base_type;
|
typedef base base_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE( mock_signature_generates_signature )
|
BOOST_AUTO_TEST_CASE( mock_signature_generates_signature )
|
||||||
{
|
{
|
||||||
BOOST_MPL_ASSERT((
|
BOOST_MPL_ASSERT((
|
||||||
boost::is_same< void(), MOCK_SIGNATURE( method_1 ) > ));
|
boost::is_same< void(), MOCK_SIGNATURE( method_1 ) > ));
|
||||||
BOOST_MPL_ASSERT((
|
BOOST_MPL_ASSERT((
|
||||||
boost::is_same< float( int ), MOCK_SIGNATURE( method_2 ) > ));
|
boost::is_same< float( int ), MOCK_SIGNATURE( method_2 ) > ));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue