diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..dfdb8b7
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1 @@
+*.sh text eol=lf
diff --git a/.travis.yml b/.travis.yml
index 71a096c..08cc19c 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -10,23 +10,32 @@
#
sudo: false
-
-os:
- - linux
+language: cpp
env:
- - CXX_STANDARD=c++98 BRANCH_TO_TEST=boost-1.58.0
- - CXX_STANDARD=c++11 BRANCH_TO_TEST=boost-1.58.0
- - CXX_STANDARD=c++98 BRANCH_TO_TEST=boost-1.59.0
- - CXX_STANDARD=c++11 BRANCH_TO_TEST=boost-1.59.0
- - CXX_STANDARD=c++98 BRANCH_TO_TEST=master
- - CXX_STANDARD=c++11 BRANCH_TO_TEST=master
- - CXX_STANDARD=c++14 BRANCH_TO_TEST=master
- CXX_STANDARD=c++17 BRANCH_TO_TEST=master
+ - CXX_STANDARD=c++14 BRANCH_TO_TEST=master
+ - CXX_STANDARD=c++11 BRANCH_TO_TEST=master
+ - CXX_STANDARD=c++98 BRANCH_TO_TEST=master
+ - CXX_STANDARD=c++11 BRANCH_TO_TEST=boost-1.58.0
+ - CXX_STANDARD=c++98 BRANCH_TO_TEST=boost-1.58.0
+ - CXX_STANDARD=c++11 BRANCH_TO_TEST=boost-1.59.0
+ - CXX_STANDARD=c++98 BRANCH_TO_TEST=boost-1.59.0
+
+compiler:
+ - clang
+ - gcc
addons:
apt:
+ sources:
+ - ubuntu-toolchain-r-test
+ - llvm-toolchain-precise
packages:
+ - gcc-5
+ - g++-5
+ - clang-5.0
+ - lld-5.0
- xsltproc
- docbook-xsl
- docbook-xml
@@ -35,6 +44,9 @@ before_install:
- DOCBOOK_XSL_DIR=/usr/share/xml/docbook/stylesheet/docbook-xsl
- DOCBOOK_DTD_DIR=/usr/share/xml/docbook/schema/dtd/4.2
+ - sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 60 --slave /usr/bin/g++ g++ /usr/bin/g++-5
+ - gcc --version
+
# 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))
@@ -57,7 +69,7 @@ script:
- cd $PROJECT_DIR/build
- export BOOST_ROOT=$BOOST
# `--coverage` flags required to generate coverage info for Coveralls
- - ./build.sh "cxxflags=-std=$CXX_STANDARD --coverage" "linkflags=--coverage"
+ - ./build.sh --toolset=$CC "cxxflags=-std=$CXX_STANDARD -Wno-unused-variable -Wno-unused-function -Wno-deprecated-declarations --coverage" "--coverage"
after_success:
- COVERALS_DIR=$PROJECT_DIR/coverals
diff --git a/build/build.bat b/build/build.bat
index f88b5a0..2ae058b 100644
--- a/build/build.bat
+++ b/build/build.bat
@@ -11,7 +11,7 @@ rem error if BOOST_ROOT not set
set BOOST=%BOOST_ROOT%
pushd ..\test
-%BOOST%\b2 -q %*
+%BOOST%\b2.exe -q %*
popd
if errorlevel 1 exit /b %ERRORLEVEL%
@@ -24,6 +24,6 @@ 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 exit /b %ERRORLEVEL%
pushd ..\doc
-%BOOST%\b2 -q %*
+%BOOST%\b2.exe -q %*
popd
if errorlevel 1 exit /b %ERRORLEVEL%
diff --git a/build/build.sh b/build/build.sh
index 7791769..a525c9e 100755
--- a/build/build.sh
+++ b/build/build.sh
@@ -12,7 +12,7 @@ copy()
cp $@
}
-set -x
+set -ex
export BOOST=$BOOST_ROOT
@@ -28,5 +28,5 @@ copy "$BOOST"/doc/src/boostbook.css ../doc/html
copy "$BOOST"/doc/src/images/*.png ../doc/html/images
copy "$BOOST"/doc/src/images/callouts/*.png ../doc/html/images/callouts
cd ../doc
-$BOOST/b2 -q "$C"
+$BOOST/b2 -q "$@"
cd ../build
diff --git a/build/build.xml b/build/build.xml
index f5fcdaa..b2201f8 100644
--- a/build/build.xml
+++ b/build/build.xml
@@ -18,17 +18,6 @@
-
-
-
-
-
-
-
-
-
-
-
diff --git a/build/clang/Dockerfile b/build/clang/Dockerfile
new file mode 100644
index 0000000..fd3a65b
--- /dev/null
+++ b/build/clang/Dockerfile
@@ -0,0 +1,17 @@
+# $ docker build --platform=linux -f clang/Dockerfile -t turtle-clang .
+FROM buildpack-deps:stretch
+RUN apt-get update && apt-get install -y xsltproc docbook-xsl docbook-xml && apt-get autoremove && apt-get clean
+ENV DOCBOOK_XSL_DIR=/usr/share/xml/docbook/stylesheet/docbook-xsl \
+ DOCBOOK_DTD_DIR=/usr/share/xml/docbook/schema/dtd/4.2 \
+ BOOST_ROOT=/home/dev/cpp/boost/
+# wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key|apt-key add - && \
+RUN echo "deb http://apt.llvm.org/stretch/ llvm-toolchain-stretch-5.0 main" >> /etc/apt/sources.list && \
+ apt-get update && \
+ apt-get install -y --allow-unauthenticated clang-5.0 lld-5.0 libc++1 && \
+ apt-get autoremove && \
+ apt-get clean && \
+ update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-5.0 100 && \
+ update-alternatives --install /usr/bin/clang clang /usr/bin/clang-5.0 100
+RUN echo 'cd /home/dev/cpp/turtle/build' >> ~/.bashrc
+# $ docker run --platform=linux --rm -v C:/dev:/home/dev -m 32g -it turtle-clang
+# ./build.sh --toolset=clang "cxxflags=-std=c++17 -stdlib=libc++ -Wno-unused-variable"
diff --git a/build/gcc/Dockerfile b/build/gcc/Dockerfile
new file mode 100644
index 0000000..5d1a4d8
--- /dev/null
+++ b/build/gcc/Dockerfile
@@ -0,0 +1,9 @@
+# $ docker build -f Dockerfile -t turtle-gcc .
+FROM gcc
+RUN apt-get update && apt-get install -y xsltproc docbook-xsl docbook-xml && apt-get autoremove && apt-get clean
+ENV DOCBOOK_XSL_DIR=/usr/share/xml/docbook/stylesheet/docbook-xsl \
+ DOCBOOK_DTD_DIR=/usr/share/xml/docbook/schema/dtd/4.2 \
+ BOOST_ROOT=/home/dev/cpp/boost/
+RUN echo 'cd /home/dev/cpp/turtle/build' >> ~/.bashrc
+# $ docker run --platform=linux --rm -v C:/dev:/home/dev -m 16g -it turtle-gcc
+# ./build.sh --toolset=gcc "cxxflags=-std=c++17 -Wno-noexcept-type -Wno-unused-variable -Wno-unused-function -Wno-deprecated-declarations"
diff --git a/doc/example/limitations_private_method.cpp b/doc/example/limitations_protected_private_method.cpp
similarity index 62%
rename from doc/example/limitations_private_method.cpp
rename to doc/example/limitations_protected_private_method.cpp
index b03c086..327cf2a 100644
--- a/doc/example/limitations_private_method.cpp
+++ b/doc/example/limitations_protected_private_method.cpp
@@ -12,18 +12,21 @@
namespace
{
-//[ limitations_private_method_problem
+//[ limitations_protected_private_method_problem
class base
{
private:
- virtual void method() = 0;
+ virtual void method_1() = 0;
+ private:
+ virtual void method_2() = 0;
};
//]
-//[ limitations_private_method_solution
+//[ limitations_protected_private_method_solution
MOCK_BASE_CLASS( mock_base, base )
{
- MOCK_METHOD( method, 0, void() )
+ MOCK_METHOD( method_1, 0, void() )
+ MOCK_METHOD( method_2, 0, void() )
};
//]
}
diff --git a/doc/example/patterns_invoke_functor.cpp b/doc/example/patterns_invoke_functor.cpp
index a7e0676..f4d281d 100644
--- a/doc/example/patterns_invoke_functor.cpp
+++ b/doc/example/patterns_invoke_functor.cpp
@@ -14,7 +14,7 @@ namespace
class base_class
{
public:
- virtual void method( boost::function< void( int ) > functor ) = 0;
+ virtual void method( const boost::function< void( int ) >& functor ) = 0;
};
void function( base_class& ); // the function will call 'method' with a functor to be applied
diff --git a/doc/example/reference.cpp b/doc/example/reference.cpp
index 9dbad31..bb2c4d6 100644
--- a/doc/example/reference.cpp
+++ b/doc/example/reference.cpp
@@ -249,16 +249,6 @@ MOCK_CLASS( mock_class )
};
//]
}
-#elif defined( BOOST_GCC )
-namespace member_function_example_10
-{
-//[ member_function_example_10
-MOCK_CLASS( mock_class )
-{
- MOCK_METHOD( __attribute((stdcall)) method, 0, void(), method ) // all parameters must be provided when specifying a different calling convention
-};
-//]
-}
#endif
namespace static_member_function_example_1
@@ -292,16 +282,6 @@ MOCK_CLASS( mock_class )
};
//]
}
-#elif defined( BOOST_GCC )
-namespace static_member_function_example_4
-{
-//[ static_member_function_example_4
-MOCK_CLASS( mock_class )
-{
- MOCK_STATIC_METHOD( __attribute((stdcall)) method, 0, void(), method ) // all parameters must be provided when specifying a different calling convention
-};
-//]
-}
#endif
namespace constructor_example_1
@@ -336,16 +316,6 @@ MOCK_CLASS( mock_class )
};
//]
}
-#elif defined( BOOST_GCC )
-namespace constructor_example_4
-{
-//[ constructor_example_4
-MOCK_CLASS( mock_class )
-{
- MOCK_CONSTRUCTOR( __attribute((stdcall)) mock_class, 0, (), constructor )
-};
-//]
-}
#endif
namespace destructor_example_1
@@ -368,16 +338,6 @@ MOCK_CLASS( mock_class )
};
//]
}
-#elif defined( BOOST_GCC )
-namespace destructor_example_3
-{
-//[ destructor_example_3
-MOCK_CLASS( mock_class )
-{
- MOCK_DESTRUCTOR( __attribute((stdcall)) ~mock_class, destructor )
-};
-//]
-}
#endif
namespace conversion_operator_example_1
@@ -414,16 +374,6 @@ MOCK_CLASS( mock_class )
};
//]
}
-#elif defined( BOOST_GCC )
-namespace conversion_operator_example_4
-{
-//[ conversion_operator_example_4
-MOCK_CLASS( mock_class )
-{
- MOCK_CONVERSION_OPERATOR( __attribute((stdcall)) operator, int, conversion_to_int )
-};
-//]
-}
#endif
namespace function_example_1
@@ -445,13 +395,6 @@ namespace function_example_2
MOCK_FUNCTION( __stdcall f, 0, void(), f ) // all parameters must be provided when specifying a different calling convention
//]
}
-#elif defined( BOOST_GCC )
-namespace function_example_3
-{
-//[ function_example_3
-MOCK_FUNCTION( __attribute((stdcall)) f, 0, void(), f ) // all parameters must be provided when specifying a different calling convention
-//]
-}
#endif
namespace functor_example_1
diff --git a/doc/limitations.qbk b/doc/limitations.qbk
index e128b74..ece78fd 100644
--- a/doc/limitations.qbk
+++ b/doc/limitations.qbk
@@ -11,7 +11,7 @@
[import example/limitations_non_virtual_method.cpp]
[import example/limitations_template_base_class_method.cpp]
[import example/limitations_template_method.cpp]
-[import example/limitations_private_method.cpp]
+[import example/limitations_protected_private_method.cpp]
[import example/limitations_comma_in_macro.cpp]
[import example/limitations_const_parameter_warning.cpp]
@@ -116,18 +116,19 @@ A workaround would be to add the signature to MOCK_METHOD :
Given :
-[limitations_private_method_problem]
+[limitations_protected_private_method_problem]
the following code does not compile :
MOCK_BASE_CLASS( mock_base, base )
{
- MOCK_METHOD( method, 0 ) // this fails because 'method' is not visible
+ MOCK_METHOD( method_1, 0 ) // this fails because a function pointer on 'base::method_1' is not allowed
+ MOCK_METHOD( method_2, 0 ) // this fails because 'method_2' is not visible
};
A workaround would be to add the signature to MOCK_METHOD :
-[limitations_private_method_solution]
+[limitations_protected_private_method_solution]
[endsect]
diff --git a/include/turtle/config.hpp b/include/turtle/config.hpp
index 96a11c8..16b0ed5 100644
--- a/include/turtle/config.hpp
+++ b/include/turtle/config.hpp
@@ -94,7 +94,7 @@
# endif
#endif
-#if defined(__cplusplus) && (__cplusplus >= 201703L) || \
+#if defined(__cpp_lib_uncaught_exceptions) || \
defined(_MSC_VER) && (_MSC_VER >= 1900)
# ifndef MOCK_NO_UNCAUGHT_EXCEPTIONS
# define MOCK_UNCAUGHT_EXCEPTIONS
diff --git a/include/turtle/constraints.hpp b/include/turtle/constraints.hpp
index 780f37f..5433874 100644
--- a/include/turtle/constraints.hpp
+++ b/include/turtle/constraints.hpp
@@ -22,7 +22,7 @@
namespace mock
{
- MOCK_UNARY_CONSTRAINT( any, 0,, true && &actual )
+ MOCK_UNARY_CONSTRAINT( any, 0,, ((void)actual, true) )
MOCK_UNARY_CONSTRAINT( affirm, 0,, !! actual )
MOCK_UNARY_CONSTRAINT( negate, 0,, ! actual )
MOCK_UNARY_CONSTRAINT( evaluate, 0,, actual() )
diff --git a/include/turtle/detail/action.hpp b/include/turtle/detail/action.hpp
index 8c49633..ed055d2 100644
--- a/include/turtle/detail/action.hpp
+++ b/include/turtle/detail/action.hpp
@@ -109,11 +109,17 @@ namespace detail
{
this->set(
boost::bind(
- &boost::move< BOOST_RV_REF(Value) >,
+ &move< Value >,
boost::ref( store( boost::move( v ) ) ) ) );
}
private:
+ template< typename T >
+ static T&& move( T& t )
+ {
+ return std::move( t );
+ }
+
struct value : boost::noncopyable
{
virtual ~value()
diff --git a/include/turtle/detail/function.hpp b/include/turtle/detail/function.hpp
index a631310..7432384 100644
--- a/include/turtle/detail/function.hpp
+++ b/include/turtle/detail/function.hpp
@@ -87,10 +87,11 @@ namespace detail
E* e_;
};
- inline int uncaught_exceptions()
+ inline int exceptions()
{
#ifdef MOCK_UNCAUGHT_EXCEPTIONS
- return std::uncaught_exceptions();
+ using namespace std;
+ return uncaught_exceptions();
#else
return std::uncaught_exception() ? 1 : 0;
#endif
diff --git a/include/turtle/detail/function_impl_template.hpp b/include/turtle/detail/function_impl_template.hpp
index 2a8d74a..4d47a82 100644
--- a/include/turtle/detail/function_impl_template.hpp
+++ b/include/turtle/detail/function_impl_template.hpp
@@ -43,12 +43,12 @@ namespace detail
function_impl()
: context_( 0 )
, valid_( true )
+ , exceptions_( exceptions() )
, mutex_( boost::make_shared< mutex >() )
- , exceptions_( uncaught_exceptions() )
{}
virtual ~function_impl()
{
- if( valid_ && exceptions_ >= uncaught_exceptions() )
+ if( valid_ && exceptions_ >= exceptions() )
for( expectations_cit it = expectations_.begin();
it != expectations_.end(); ++it )
if( ! it->verify() )
@@ -183,9 +183,9 @@ namespace detail
this->e_->throws( t );
}
template< typename TT >
- void moves( TT t )
+ void moves( BOOST_RV_REF(TT) t )
{
- this->e_->moves( t );
+ this->e_->moves( boost::move( t ) );
}
lock lock_;
diff --git a/include/turtle/mock.hpp b/include/turtle/mock.hpp
index 78fb185..e92f458 100644
--- a/include/turtle/mock.hpp
+++ b/include/turtle/mock.hpp
@@ -43,8 +43,8 @@
#else // MOCK_VARIADIC_MACROS
-#define MOCK_BASE_CLASS(T, B) \
- struct T : B, mock::object, mock::detail::base< B >
+#define MOCK_BASE_CLASS(T, I) \
+ struct T : I, mock::object, mock::detail::base< I >
#define MOCK_FUNCTOR(f, S) \
mock::detail::functor< MOCK_FUNCTION_TYPE((S),) > f, f##_mock
@@ -177,11 +177,8 @@
#define MOCK_VARIADIC_ELEM_1(e0, e1, ...) e1
#define MOCK_VARIADIC_ELEM_2(e0, e1, e2, ...) e2
-#define MOCK_METHOD_SIGNATURE(M, n, S, t) \
- typedef MOCK_FUNCTION_TYPE((S),) BOOST_PP_CAT(t,_sig_type); \
- MOCK_METHOD_EXT(M, n, BOOST_PP_CAT(t,_sig_type), t)
#define MOCK_METHOD(M, ...) \
- MOCK_METHOD_SIGNATURE(M, \
+ MOCK_METHOD_EXT(M, \
MOCK_VARIADIC_ELEM_0(__VA_ARGS__ ), \
MOCK_VARIADIC_ELEM_1(__VA_ARGS__, MOCK_SIGNATURE(M)), \
MOCK_VARIADIC_ELEM_2(__VA_ARGS__, M, M))
@@ -228,8 +225,7 @@
#else // MOCK_VARIADIC_MACROS
#define MOCK_METHOD(M, n) \
- typedef MOCK_SIGNATURE(M) M##_sig_type; \
- MOCK_METHOD_EXT(M, n, M##_sig_type, M)
+ MOCK_METHOD_EXT(M, n, MOCK_SIGNATURE(M), M)
#define MOCK_FUNCTION(F, n, S, t) \
MOCK_FUNCTION_AUX(F, n, S, t, inline,)
diff --git a/test/detail/test_signature.cpp b/test/detail/test_signature.cpp
index afe9ba4..27f4e91 100644
--- a/test/detail/test_signature.cpp
+++ b/test/detail/test_signature.cpp
@@ -23,7 +23,7 @@ namespace
BOOST_AUTO_TEST_CASE( mock_signature_generates_signature )
{
BOOST_MPL_ASSERT((
- boost::is_same< void(), MOCK_SIGNATURE( method_1 ) > ));
+ boost::is_same< void(), MOCK_SIGNATURE(method_1) > ));
BOOST_MPL_ASSERT((
- boost::is_same< float( int ), MOCK_SIGNATURE( method_2 ) > ));
+ boost::is_same< float( int ), MOCK_SIGNATURE(method_2) > ));
}
diff --git a/test/test_integration.cpp b/test/test_integration.cpp
index 7636e47..d1b7567 100644
--- a/test/test_integration.cpp
+++ b/test/test_integration.cpp
@@ -84,8 +84,8 @@ namespace
class my_ambiguited_interface : boost::noncopyable
{
public:
- virtual ~my_ambiguited_interface() {}
-
+ virtual ~my_ambiguited_interface()
+ {}
virtual void my_method() = 0;
virtual void my_method( int ) = 0;
};
@@ -110,8 +110,8 @@ namespace
class my_const_ambiguited_interface : boost::noncopyable
{
public:
- virtual ~my_const_ambiguited_interface() {}
-
+ virtual ~my_const_ambiguited_interface()
+ {}
virtual void my_method() = 0;
virtual void my_method() const = 0;
};
diff --git a/test/test_mock.cpp b/test/test_mock.cpp
index 98b148b..3aa7473 100644
--- a/test/test_mock.cpp
+++ b/test/test_mock.cpp
@@ -364,7 +364,7 @@ namespace
{
virtual ~base()
{}
- protected:
+
virtual void m1() = 0;
};
@@ -384,7 +384,7 @@ namespace
template< typename T >
MOCK_BASE_CLASS( variadic_tpl, base )
{
- MOCK_METHOD( m1, 0 )
+ MOCK_METHOD( m1, 0, void() )
MOCK_METHOD_TPL( m2, 0, T() )
MOCK_METHOD_TPL( m3, 0, T(), m3 )
MOCK_CONST_METHOD_TPL( m4, 0, T() )
@@ -413,7 +413,7 @@ namespace
{
virtual ~base()
{}
- protected:
+
virtual void m1() = 0;
};
@@ -425,7 +425,7 @@ namespace
template< typename T >
MOCK_BASE_CLASS( derived_tpl, base )
{
- MOCK_METHOD( m1, 0 )
+ MOCK_METHOD_EXT( m1, 0, void(), m1 )
};
}
@@ -433,11 +433,9 @@ namespace
#ifdef BOOST_MSVC
# define MOCK_STDCALL __stdcall
-#elif defined( BOOST_GCC )
-# define MOCK_STDCALL __attribute((stdcall))
#else
# define MOCK_STDCALL
-#endif // BOOST_GCC
+#endif
namespace stdcall
{
@@ -446,7 +444,6 @@ namespace stdcall
virtual ~base()
{}
- protected:
virtual void MOCK_STDCALL m1() = 0;
};