From f678f4d91f8be524e035e8db8e9d29041db6d47c Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Thu, 9 Jul 2020 18:41:40 +0200 Subject: [PATCH] Assume nullptr existance --- doc/example/limitations_literal_zero.cpp | 2 -- include/turtle/config.hpp | 6 ---- include/turtle/constraints.hpp | 10 +++---- include/turtle/detail/addressof.hpp | 36 ------------------------ include/turtle/detail/formatter.hpp | 4 +-- include/turtle/log.hpp | 2 -- test/detail/test_function.cpp | 4 --- test/test_constraints.cpp | 4 --- test/test_log.cpp | 4 --- 9 files changed, 7 insertions(+), 65 deletions(-) delete mode 100644 include/turtle/detail/addressof.hpp diff --git a/doc/example/limitations_literal_zero.cpp b/doc/example/limitations_literal_zero.cpp index 463f4ea..895f4f5 100644 --- a/doc/example/limitations_literal_zero.cpp +++ b/doc/example/limitations_literal_zero.cpp @@ -35,9 +35,7 @@ BOOST_AUTO_TEST_CASE( literal_zero ) //[ limitations_literal_zero_solution_2 MOCK_EXPECT( m.method ).with( mock::negate ); //] -#ifdef MOCK_NULLPTR //[ limitations_literal_zero_solution_3 MOCK_EXPECT( m.method ).with( nullptr ); //] -#endif } diff --git a/include/turtle/config.hpp b/include/turtle/config.hpp index 6f4104e..f1daeb0 100644 --- a/include/turtle/config.hpp +++ b/include/turtle/config.hpp @@ -40,12 +40,6 @@ # error BOOST_FT_MAX_ARITY must be set to MOCK_MAX_ARGS + 1 or higher #endif -#if !defined(BOOST_NO_CXX11_NULLPTR) && !defined(BOOST_NO_NULLPTR) -# ifndef MOCK_NO_NULLPTR -# define MOCK_NULLPTR -# endif -#endif - #if !defined(BOOST_NO_CXX11_VARIADIC_MACROS) && !defined(BOOST_NO_VARIADIC_MACROS) # ifndef MOCK_NO_VARIADIC_MACROS # define MOCK_VARIADIC_MACROS diff --git a/include/turtle/constraints.hpp b/include/turtle/constraints.hpp index 3d7af0c..d37e433 100644 --- a/include/turtle/constraints.hpp +++ b/include/turtle/constraints.hpp @@ -11,7 +11,6 @@ #include "config.hpp" #include "constraint.hpp" -#include "detail/addressof.hpp" #include "detail/move_helper.hpp" #include #include @@ -21,6 +20,7 @@ #else #include #endif +#include #include namespace mock @@ -161,12 +161,12 @@ namespace detail struct same { explicit same( const Expected& expected ) - : expected_( detail::addressof( boost::unwrap_ref( expected ) ) ) + : expected_( std::addressof( boost::unwrap_ref( expected ) ) ) {} template< typename Actual > 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 ) { @@ -180,7 +180,7 @@ namespace detail struct retrieve { explicit retrieve( Expected& expected ) - : expected_( detail::addressof( boost::unwrap_ref( expected ) ) ) + : expected_( std::addressof( boost::unwrap_ref( expected ) ) ) {} template< typename Actual > bool operator()( const Actual& actual, @@ -217,7 +217,7 @@ namespace detail >::value >* = 0 ) const { - *expected_ = detail::addressof( actual ); + *expected_ = std::addressof( actual ); return true; } friend std::ostream& operator<<( std::ostream& s, const retrieve& r ) diff --git a/include/turtle/detail/addressof.hpp b/include/turtle/detail/addressof.hpp deleted file mode 100644 index 4e48a8d..0000000 --- a/include/turtle/detail/addressof.hpp +++ /dev/null @@ -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 - -namespace mock -{ -namespace detail -{ - using boost::addressof; - -#ifdef MOCK_NULLPTR - - inline const std::nullptr_t* addressof( const std::nullptr_t& p ) - { - return &p; - } - inline std::nullptr_t* addressof( std::nullptr_t& p ) - { - return &p; - } - -#endif -} -} // mock - -#endif // MOCK_ADDRESSOF_HPP_INCLUDED diff --git a/include/turtle/detail/formatter.hpp b/include/turtle/detail/formatter.hpp index 18ccd73..a89204a 100644 --- a/include/turtle/detail/formatter.hpp +++ b/include/turtle/detail/formatter.hpp @@ -11,7 +11,7 @@ #include "../config.hpp" #include "../stream.hpp" -#include "addressof.hpp" +#include namespace mock { @@ -21,7 +21,7 @@ namespace detail struct formatter { explicit formatter( const T& t ) - : t_( detail::addressof( t ) ) + : t_( std::addressof( t ) ) {} void serialize( stream& s ) const { diff --git a/include/turtle/log.hpp b/include/turtle/log.hpp index b196ec0..e30ea55 100644 --- a/include/turtle/log.hpp +++ b/include/turtle/log.hpp @@ -173,12 +173,10 @@ namespace detail return s << '?'; } -#ifdef MOCK_NULLPTR inline stream& operator<<( stream& s, std::nullptr_t ) { return s << "nullptr"; } -#endif template< typename T > std::enable_if_t< diff --git a/test/detail/test_function.cpp b/test/detail/test_function.cpp index 69566da..ad38a25 100644 --- a/test/detail/test_function.cpp +++ b/test/detail/test_function.cpp @@ -350,8 +350,6 @@ BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_with_failing_custom_constrain // CHECK_CALLS( 1 ); //} -#ifdef MOCK_NULLPTR - BOOST_FIXTURE_TEST_CASE( nullptr_can_be_used_in_place_of_null_pointers_in_constraints, mock_error_fixture ) { 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 ); } -#endif - #ifdef MOCK_SMART_PTR BOOST_FIXTURE_TEST_CASE( unique_ptr_is_supported_as_parameter, mock_error_fixture ) diff --git a/test/test_constraints.cpp b/test/test_constraints.cpp index 26087ea..1d89740 100644 --- a/test/test_constraints.cpp +++ b/test/test_constraints.cpp @@ -106,12 +106,10 @@ BOOST_AUTO_TEST_CASE( same_constraint ) BOOST_CHECK( ! c.c_( j ) ); BOOST_CHECK( c.c_( i ) ); } -#ifdef MOCK_NULLPTR { std::nullptr_t p; BOOST_CHECK( mock::same( p ).c_( p ) ); } -#endif } 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_EQUAL( i, &j ); } -#ifdef MOCK_NULLPTR { std::nullptr_t* i = 0; std::nullptr_t j; BOOST_CHECK( mock::retrieve( i ).c_( j ) ); BOOST_CHECK_EQUAL( i, &j ); } -#endif #ifdef MOCK_SMART_PTR { std::unique_ptr< int > i; diff --git a/test/test_log.cpp b/test/test_log.cpp index 728eb20..59d5b4c 100644 --- a/test/test_log.cpp +++ b/test/test_log.cpp @@ -665,15 +665,11 @@ BOOST_AUTO_TEST_CASE( boost_lambda_functor_yields_question_mark_when_serialized #endif -#ifdef MOCK_NULLPTR - BOOST_AUTO_TEST_CASE( nullptr_is_serialized ) { BOOST_CHECK_EQUAL( "nullptr", to_string( nullptr ) ); } -#endif - BOOST_AUTO_TEST_CASE( mock_boost_optional_yields_its_value_when_serialized ) { BOOST_CHECK_EQUAL( "7", to_string( boost::optional< int >( 7 ) ) );