Include examples in CI tests

Also fix and update examples and documentation where required
This allows to make sure examples are actually runnable avoiding them to
become outdated
This commit is contained in:
Alexander Grund 2020-07-11 14:01:18 +02:00
parent a6aa140148
commit 5ef17d0e33
No known key found for this signature in database
GPG key ID: AA48A0760367A42B
42 changed files with 400 additions and 285 deletions

View file

@ -11,7 +11,7 @@
#include "config.hpp"
#include "log.hpp"
#include "detail/unwrap_reference.hpp"
#include "unwrap_reference.hpp"
#include <boost/preprocessor/stringize.hpp>
#include <boost/preprocessor/control/if.hpp>
#include <boost/preprocessor/variadic/to_array.hpp>
@ -135,7 +135,7 @@ namespace detail
template< typename Actual > \
bool operator()( const Actual& actual ) const \
{ \
return Expr; \
(void) actual; return Expr; \
} \
friend std::ostream& operator<<( std::ostream& s, const Name& ) \
{ \
@ -149,7 +149,7 @@ namespace detail
expected##n( std::forward< T##n >(e##n) )
#define MOCK_CONSTRAINT_UNWRAP_REF(z, n, d) \
mock::detail::unwrap_ref( expected##n )
mock::unwrap_ref( expected##n )
#define MOCK_CONSTRAINT_FORMAT(z, n, d) \
BOOST_PP_IF(n, << ", " <<,) mock::format( c.expected##n )
@ -161,7 +161,7 @@ namespace detail
std::decay_t< const T##n >
#define MOCK_CONSTRAINT_CREF_PARAM(z, n, Args) \
const mock::detail::unwrap_reference_t< Expected_##n >& \
const mock::unwrap_reference_t< Expected_##n >& \
BOOST_PP_ARRAY_ELEM(n, Args)
#define MOCK_CONSTRAINT_ARG(z, n, Args) \

View file

@ -12,7 +12,7 @@
#include "config.hpp"
#include "constraint.hpp"
#include "detail/move_helper.hpp"
#include "detail/unwrap_reference.hpp"
#include "unwrap_reference.hpp"
#include <boost/version.hpp>
#include <boost/type_traits/make_void.hpp>
#if BOOST_VERSION >= 107000

View file

@ -240,8 +240,7 @@ namespace detail
return line_;
}
friend std::ostream& operator<<(
std::ostream& s, const expectation& e )
friend std::ostream& operator<<( std::ostream& s, const expectation& e )
{
return s << ( e.invocation_->exhausted() ? 'v' : '.' )
<< ' ' << *e.invocation_

View file

@ -129,26 +129,22 @@ namespace detail
}
wrapper& exactly( std::size_t count )
{
this->e_->invoke(
std::make_shared< detail::exactly >( count ) );
this->e_->invoke( std::make_shared< detail::exactly >( count ) );
return *this;
}
wrapper& at_least( std::size_t min )
{
this->e_->invoke(
std::make_shared< detail::at_least >( min ) );
this->e_->invoke( std::make_shared< detail::at_least >( min ) );
return *this;
}
wrapper& at_most( std::size_t max )
{
this->e_->invoke(
std::make_shared< detail::at_most >( max ) );
this->e_->invoke( std::make_shared< detail::at_most >( max ) );
return *this;
}
wrapper& between( std::size_t min, std::size_t max )
{
this->e_->invoke(
std::make_shared< detail::between >( min, max ) );
this->e_->invoke( std::make_shared< detail::between >( min, max ) );
return *this;
}
@ -250,8 +246,7 @@ namespace detail
return error_type::abort();
}
valid_ = true;
error_type::call(
MOCK_FUNCTION_CONTEXT, it->file(), it->line() );
error_type::call( MOCK_FUNCTION_CONTEXT, it->file(), it->line() );
if( it->functor() )
return it->functor()(
BOOST_PP_ENUM(MOCK_NUM_ARGS, MOCK_MOVE, _) );
@ -273,8 +268,7 @@ namespace detail
context_ = &c;
}
friend std::ostream& operator<<(
std::ostream& s, const function_impl& impl )
friend std::ostream& operator<<( std::ostream& s, const function_impl& impl )
{
lock _( impl.mutex_ );
return s << lazy_context( &impl ) << lazy_expectations( &impl );
@ -285,8 +279,7 @@ namespace detail
lazy_context( const function_impl* impl )
: impl_( impl )
{}
friend std::ostream& operator<<(
std::ostream& s, const lazy_context& c )
friend std::ostream& operator<<( std::ostream& s, const lazy_context& c )
{
if( c.impl_->context_ )
c.impl_->context_->serialize( s, *c.impl_ );
@ -302,8 +295,7 @@ namespace detail
lazy_expectations( const function_impl* impl )
: impl_( impl )
{}
friend std::ostream& operator<<(
std::ostream& s, const lazy_expectations& e )
friend std::ostream& operator<<( std::ostream& s, const lazy_expectations& e )
{
for( expectations_cit it = e.impl_->expectations_.begin();
it != e.impl_->expectations_.end(); ++it )

View file

@ -28,8 +28,7 @@ namespace detail
virtual bool operator()(
BOOST_PP_ENUM(MOCK_NUM_ARGS, MOCK_REF_ARG, _) ) = 0;
friend std::ostream& operator<<(
std::ostream& s, const matcher_base& m )
friend std::ostream& operator<<( std::ostream& s, const matcher_base& m )
{
m.serialize( s );
return s;

View file

@ -59,7 +59,11 @@ namespace detail
};
template< typename Signature, int n >
using parameter = tuple_element< n, typename parameter_types<Signature>::type >;
struct parameter
{
static_assert(n < function_arity<Signature>::value, "Function signature has not that many parameters");
using type = typename tuple_element< n, typename parameter_types<Signature>::type >::type;
};
template<typename T>
struct parameter_type;

View file

@ -29,11 +29,9 @@ namespace mock
{}
bool operator()( std::add_lvalue_reference_t< const Actual > actual )
{
return mock::equal(
mock::detail::unwrap_ref( expected_ ) ).c_( actual );
return mock::equal( mock::unwrap_ref( expected_ ) ).c_( actual );
}
friend std::ostream& operator<<(
std::ostream& s, const matcher& m )
friend std::ostream& operator<<( std::ostream& s, const matcher& m )
{
return s << mock::format( m.expected_ );
}
@ -52,8 +50,7 @@ namespace mock
{
return std::strcmp( actual, expected_ ) == 0;
}
friend std::ostream& operator<<(
std::ostream& s, const matcher& m )
friend std::ostream& operator<<( std::ostream& s, const matcher& m )
{
return s << mock::format( m.expected_ );
}
@ -72,8 +69,7 @@ namespace mock
{
return c_( std::forward< typename detail::ref_arg< Actual >::type >( actual ) );
}
friend std::ostream& operator<<(
std::ostream& s, const matcher& m )
friend std::ostream& operator<<( std::ostream& s, const matcher& m )
{
return s << mock::format( m.c_ );
}
@ -96,8 +92,7 @@ namespace mock
{
return c_( std::forward< typename detail::ref_arg< Actual >::type >( actual ) );
}
friend std::ostream& operator<<(
std::ostream& s, const matcher& m )
friend std::ostream& operator<<( std::ostream& s, const matcher& m )
{
return s << mock::format( m.c_ );
}

View file

@ -48,7 +48,7 @@
mock::detail::functor< MOCK_FUNCTION_TYPE(__VA_ARGS__) > f, f##_mock
/// MOCK_FUNCTOR_TPL( name, signature )
/// Deprecated. Same as MOCK_FUNCTOR
#define MOCK_FUNCTOR_TPL(f, ...) MOCK_FUNCTOR(F, __VA_ARGS__)
#define MOCK_FUNCTOR_TPL(f, ...) MOCK_FUNCTOR(f, __VA_ARGS__)
#define MOCK_HELPER(t) \
t##_mock( mock::detail::root, BOOST_PP_STRINGIZE(t) )

View file

@ -13,8 +13,6 @@
#include <type_traits>
namespace mock
{
namespace detail
{
template<class T>
struct unwrap_reference
@ -40,6 +38,5 @@ namespace detail
return t;
}
}
}
#endif // MOCK_UNWRAP_REFERENCE_HPP_INCLUDED