mirror of
https://github.com/mat007/turtle.git
synced 2026-06-22 12:13:43 +00:00
Assume nullptr existance
This commit is contained in:
parent
cf330e8c86
commit
f678f4d91f
9 changed files with 7 additions and 65 deletions
|
|
@ -35,9 +35,7 @@ BOOST_AUTO_TEST_CASE( literal_zero )
|
||||||
//[ 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
|
|
||||||
//[ limitations_literal_zero_solution_3
|
//[ limitations_literal_zero_solution_3
|
||||||
MOCK_EXPECT( m.method ).with( nullptr );
|
MOCK_EXPECT( m.method ).with( nullptr );
|
||||||
//]
|
//]
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,12 +40,6 @@
|
||||||
# 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)
|
|
||||||
# ifndef MOCK_NO_NULLPTR
|
|
||||||
# define MOCK_NULLPTR
|
|
||||||
# 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
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@
|
||||||
|
|
||||||
#include "config.hpp"
|
#include "config.hpp"
|
||||||
#include "constraint.hpp"
|
#include "constraint.hpp"
|
||||||
#include "detail/addressof.hpp"
|
|
||||||
#include "detail/move_helper.hpp"
|
#include "detail/move_helper.hpp"
|
||||||
#include <boost/ref.hpp>
|
#include <boost/ref.hpp>
|
||||||
#include <boost/version.hpp>
|
#include <boost/version.hpp>
|
||||||
|
|
@ -21,6 +20,7 @@
|
||||||
#else
|
#else
|
||||||
#include <boost/test/floating_point_comparison.hpp>
|
#include <boost/test/floating_point_comparison.hpp>
|
||||||
#endif
|
#endif
|
||||||
|
#include <memory>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
namespace mock
|
namespace mock
|
||||||
|
|
@ -161,12 +161,12 @@ namespace detail
|
||||||
struct same
|
struct same
|
||||||
{
|
{
|
||||||
explicit same( const Expected& expected )
|
explicit same( const Expected& expected )
|
||||||
: expected_( detail::addressof( boost::unwrap_ref( expected ) ) )
|
: expected_( std::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 std::addressof( actual ) == expected_;
|
||||||
}
|
}
|
||||||
friend std::ostream& operator<<( std::ostream& os, const same& s )
|
friend std::ostream& operator<<( std::ostream& os, const same& s )
|
||||||
{
|
{
|
||||||
|
|
@ -180,7 +180,7 @@ namespace detail
|
||||||
struct retrieve
|
struct retrieve
|
||||||
{
|
{
|
||||||
explicit retrieve( Expected& expected )
|
explicit retrieve( Expected& expected )
|
||||||
: expected_( detail::addressof( boost::unwrap_ref( expected ) ) )
|
: expected_( std::addressof( boost::unwrap_ref( expected ) ) )
|
||||||
{}
|
{}
|
||||||
template< typename Actual >
|
template< typename Actual >
|
||||||
bool operator()( const Actual& actual,
|
bool operator()( const Actual& actual,
|
||||||
|
|
@ -217,7 +217,7 @@ namespace detail
|
||||||
>::value
|
>::value
|
||||||
>* = 0 ) const
|
>* = 0 ) const
|
||||||
{
|
{
|
||||||
*expected_ = detail::addressof( actual );
|
*expected_ = std::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 )
|
||||||
|
|
|
||||||
|
|
@ -1,36 +0,0 @@
|
||||||
// http://turtle.sourceforge.net
|
|
||||||
//
|
|
||||||
// Copyright Mathieu Champlon 2013
|
|
||||||
//
|
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
|
||||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
|
||||||
|
|
||||||
#ifndef MOCK_ADDRESSOF_HPP_INCLUDED
|
|
||||||
#define MOCK_ADDRESSOF_HPP_INCLUDED
|
|
||||||
|
|
||||||
#include "../config.hpp"
|
|
||||||
#include <boost/utility/addressof.hpp>
|
|
||||||
|
|
||||||
namespace mock
|
|
||||||
{
|
|
||||||
namespace detail
|
|
||||||
{
|
|
||||||
using boost::addressof;
|
|
||||||
|
|
||||||
#ifdef MOCK_NULLPTR
|
|
||||||
|
|
||||||
inline const std::nullptr_t* addressof( const std::nullptr_t& p )
|
|
||||||
{
|
|
||||||
return &p;
|
|
||||||
}
|
|
||||||
inline std::nullptr_t* addressof( std::nullptr_t& p )
|
|
||||||
{
|
|
||||||
return &p;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
} // mock
|
|
||||||
|
|
||||||
#endif // MOCK_ADDRESSOF_HPP_INCLUDED
|
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
#include "../config.hpp"
|
#include "../config.hpp"
|
||||||
#include "../stream.hpp"
|
#include "../stream.hpp"
|
||||||
#include "addressof.hpp"
|
#include <memory.h>
|
||||||
|
|
||||||
namespace mock
|
namespace mock
|
||||||
{
|
{
|
||||||
|
|
@ -21,7 +21,7 @@ namespace detail
|
||||||
struct formatter
|
struct formatter
|
||||||
{
|
{
|
||||||
explicit formatter( const T& t )
|
explicit formatter( const T& t )
|
||||||
: t_( detail::addressof( t ) )
|
: t_( std::addressof( t ) )
|
||||||
{}
|
{}
|
||||||
void serialize( stream& s ) const
|
void serialize( stream& s ) const
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -173,12 +173,10 @@ namespace detail
|
||||||
return s << '?';
|
return s << '?';
|
||||||
}
|
}
|
||||||
|
|
||||||
#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
|
|
||||||
|
|
||||||
template< typename T >
|
template< typename T >
|
||||||
std::enable_if_t<
|
std::enable_if_t<
|
||||||
|
|
|
||||||
|
|
@ -350,8 +350,6 @@ BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_with_failing_custom_constrain
|
||||||
// CHECK_CALLS( 1 );
|
// CHECK_CALLS( 1 );
|
||||||
//}
|
//}
|
||||||
|
|
||||||
#ifdef MOCK_NULLPTR
|
|
||||||
|
|
||||||
BOOST_FIXTURE_TEST_CASE( nullptr_can_be_used_in_place_of_null_pointers_in_constraints, mock_error_fixture )
|
BOOST_FIXTURE_TEST_CASE( nullptr_can_be_used_in_place_of_null_pointers_in_constraints, mock_error_fixture )
|
||||||
{
|
{
|
||||||
mock::detail::function< void( int* ) > f;
|
mock::detail::function< void( int* ) > f;
|
||||||
|
|
@ -360,8 +358,6 @@ BOOST_FIXTURE_TEST_CASE( nullptr_can_be_used_in_place_of_null_pointers_in_constr
|
||||||
CHECK_CALLS( 1 );
|
CHECK_CALLS( 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef MOCK_SMART_PTR
|
#ifdef MOCK_SMART_PTR
|
||||||
|
|
||||||
BOOST_FIXTURE_TEST_CASE( unique_ptr_is_supported_as_parameter, mock_error_fixture )
|
BOOST_FIXTURE_TEST_CASE( unique_ptr_is_supported_as_parameter, mock_error_fixture )
|
||||||
|
|
|
||||||
|
|
@ -106,12 +106,10 @@ BOOST_AUTO_TEST_CASE( same_constraint )
|
||||||
BOOST_CHECK( ! c.c_( j ) );
|
BOOST_CHECK( ! c.c_( j ) );
|
||||||
BOOST_CHECK( c.c_( i ) );
|
BOOST_CHECK( c.c_( i ) );
|
||||||
}
|
}
|
||||||
#ifdef MOCK_NULLPTR
|
|
||||||
{
|
{
|
||||||
std::nullptr_t p;
|
std::nullptr_t p;
|
||||||
BOOST_CHECK( mock::same( p ).c_( p ) );
|
BOOST_CHECK( mock::same( p ).c_( p ) );
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE( assign_constraint )
|
BOOST_AUTO_TEST_CASE( assign_constraint )
|
||||||
|
|
@ -245,14 +243,12 @@ BOOST_AUTO_TEST_CASE( retrieve_constraint )
|
||||||
BOOST_CHECK( mock::retrieve( boost::ref( i ) ).c_( j ) );
|
BOOST_CHECK( mock::retrieve( boost::ref( i ) ).c_( j ) );
|
||||||
BOOST_CHECK_EQUAL( i, &j );
|
BOOST_CHECK_EQUAL( i, &j );
|
||||||
}
|
}
|
||||||
#ifdef MOCK_NULLPTR
|
|
||||||
{
|
{
|
||||||
std::nullptr_t* i = 0;
|
std::nullptr_t* i = 0;
|
||||||
std::nullptr_t j;
|
std::nullptr_t j;
|
||||||
BOOST_CHECK( mock::retrieve( i ).c_( j ) );
|
BOOST_CHECK( mock::retrieve( i ).c_( j ) );
|
||||||
BOOST_CHECK_EQUAL( i, &j );
|
BOOST_CHECK_EQUAL( i, &j );
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
#ifdef MOCK_SMART_PTR
|
#ifdef MOCK_SMART_PTR
|
||||||
{
|
{
|
||||||
std::unique_ptr< int > i;
|
std::unique_ptr< int > i;
|
||||||
|
|
|
||||||
|
|
@ -665,15 +665,11 @@ BOOST_AUTO_TEST_CASE( boost_lambda_functor_yields_question_mark_when_serialized
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MOCK_NULLPTR
|
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE( nullptr_is_serialized )
|
BOOST_AUTO_TEST_CASE( nullptr_is_serialized )
|
||||||
{
|
{
|
||||||
BOOST_CHECK_EQUAL( "nullptr", to_string( nullptr ) );
|
BOOST_CHECK_EQUAL( "nullptr", to_string( nullptr ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE( mock_boost_optional_yields_its_value_when_serialized )
|
BOOST_AUTO_TEST_CASE( mock_boost_optional_yields_its_value_when_serialized )
|
||||||
{
|
{
|
||||||
BOOST_CHECK_EQUAL( "7", to_string( boost::optional< int >( 7 ) ) );
|
BOOST_CHECK_EQUAL( "7", to_string( boost::optional< int >( 7 ) ) );
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue