From 121c682d41a87711743c109d615801c2d4ec9645 Mon Sep 17 00:00:00 2001 From: Mathieu Champlon Date: Mon, 8 Feb 2016 05:18:43 +0100 Subject: [PATCH 1/3] Fixed typo in test case names --- test/test_log.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/test_log.cpp b/test/test_log.cpp index cee6ca8..e39c385 100644 --- a/test/test_log.cpp +++ b/test/test_log.cpp @@ -86,7 +86,7 @@ namespace {}; } -BOOST_AUTO_TEST_CASE( non_serializable_type_yields_an_question_mark_when_serialized ) +BOOST_AUTO_TEST_CASE( non_serializable_type_yields_a_question_mark_when_serialized ) { BOOST_CHECK_EQUAL( "?", to_string( non_serializable() ) ); } @@ -155,7 +155,7 @@ namespace {}; } -BOOST_AUTO_TEST_CASE( type_derived_from_serializable_yields_an_question_mark_when_serialized ) +BOOST_AUTO_TEST_CASE( type_derived_from_serializable_yields_a_question_mark_when_serialized ) { #ifdef MOCK_USE_CONVERSIONS BOOST_CHECK_EQUAL( "serializable", to_string( derived_from_serializable() ) ); @@ -170,7 +170,7 @@ namespace {}; } -BOOST_AUTO_TEST_CASE( type_derived_from_streamable_yields_an_question_mark_when_serialized ) +BOOST_AUTO_TEST_CASE( type_derived_from_streamable_yields_a_question_mark_when_serialized ) { #ifdef MOCK_USE_CONVERSIONS BOOST_CHECK_EQUAL( "streamable", to_string( derived_from_streamable() ) ); @@ -189,7 +189,7 @@ namespace }; } -BOOST_AUTO_TEST_CASE( type_convertible_to_base_yields_an_question_mark_when_serialized ) +BOOST_AUTO_TEST_CASE( type_convertible_to_base_yields_a_question_mark_when_serialized ) { BOOST_CHECK_EQUAL( "?", to_string( convertible_to_base() ) ); } @@ -202,7 +202,7 @@ namespace }; } -BOOST_AUTO_TEST_CASE( type_convertible_to_serializable_yields_an_question_mark_when_serialized ) +BOOST_AUTO_TEST_CASE( type_convertible_to_serializable_yields_a_question_mark_when_serialized ) { BOOST_CHECK_EQUAL( "?", to_string( convertible_to_serializable() ) ); } @@ -215,7 +215,7 @@ namespace }; } -BOOST_AUTO_TEST_CASE( type_convertible_to_streamable_yields_an_question_mark_when_serialized ) +BOOST_AUTO_TEST_CASE( type_convertible_to_streamable_yields_a_question_mark_when_serialized ) { BOOST_CHECK_EQUAL( "?", to_string( convertible_to_streamable() ) ); } @@ -232,7 +232,7 @@ namespace }; } -BOOST_AUTO_TEST_CASE( type_ambiguous_convertible_yields_an_question_mark_when_serialized ) +BOOST_AUTO_TEST_CASE( type_ambiguous_convertible_yields_a_question_mark_when_serialized ) { BOOST_CHECK_EQUAL( "?", to_string( ambiguous_convertible() ) ); } @@ -529,7 +529,7 @@ namespace {} } -BOOST_AUTO_TEST_CASE( callable_builtin_yields_an_question_mark_when_serialized ) +BOOST_AUTO_TEST_CASE( callable_builtin_yields_a_question_mark_when_serialized ) { BOOST_CHECK_EQUAL( "?", to_string( callable_builtin ) ); BOOST_CHECK_EQUAL( "?", to_string( &callable_builtin ) ); From c35b76c8f096351fa33d4d65921026cb106a4828 Mon Sep 17 00:00:00 2001 From: Mathieu Champlon Date: Mon, 8 Feb 2016 05:39:21 +0100 Subject: [PATCH 2/3] Removed unneeded inline --- include/turtle/log.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/turtle/log.hpp b/include/turtle/log.hpp index b5dfcdf..2680365 100644 --- a/include/turtle/log.hpp +++ b/include/turtle/log.hpp @@ -140,7 +140,7 @@ namespace detail return s << mock::format( t.lock() ); } template< typename T, typename D > - inline stream& operator<<( stream& s, const std::unique_ptr< T, D >& p ) + stream& operator<<( stream& s, const std::unique_ptr< T, D >& p ) { return s << mock::format( p.get() ); } From 506e10f76aa02b8c3abeea0a0d0ced554dff192d Mon Sep 17 00:00:00 2001 From: Mathieu Champlon Date: Mon, 8 Feb 2016 05:40:39 +0100 Subject: [PATCH 3/3] Added logging support for boost::optional --- doc/changelog.qbk | 1 + include/turtle/log.hpp | 13 +++++++++++++ test/test_log.cpp | 10 ++++++++++ 3 files changed, 24 insertions(+) diff --git a/doc/changelog.qbk b/doc/changelog.qbk index 6aeb960..44f4815 100644 --- a/doc/changelog.qbk +++ b/doc/changelog.qbk @@ -14,6 +14,7 @@ Not yet released * Fixed build errors with Boost 1.59 * Fixed multiply defined symbol definition for MOCK_FUNCTION included from several translation units * Fixed extra semicolon warning with BOOST_GLOBAL_FIXTURE prior to Boost 1.59 +* Added logging support for boost::optional [endsect] diff --git a/include/turtle/log.hpp b/include/turtle/log.hpp index 2680365..0faff6a 100644 --- a/include/turtle/log.hpp +++ b/include/turtle/log.hpp @@ -15,6 +15,7 @@ #include #include #include +#include #include namespace boost @@ -22,6 +23,7 @@ namespace boost template< typename T > class shared_ptr; template< typename T > class weak_ptr; template< typename T > class reference_wrapper; + template< typename T > class optional; namespace phoenix { @@ -127,6 +129,17 @@ namespace detail { return s << mock::format( t.lock() ); } + inline stream& operator<<( stream& s, const boost::none_t& ) + { + return s << "none"; + } + template< typename T > + stream& operator<<( stream& s, const boost::optional< T >& t ) + { + if( t ) + return s << mock::format( t.get() ); + return s << boost::none; + } #ifdef MOCK_SMART_PTR template< typename T > diff --git a/test/test_log.cpp b/test/test_log.cpp index e39c385..44fdd31 100644 --- a/test/test_log.cpp +++ b/test/test_log.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #ifdef BOOST_MSVC #pragma warning( push, 0 ) #endif @@ -668,3 +669,12 @@ BOOST_AUTO_TEST_CASE( nullptr_is_serialized ) } #endif + +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( "?", to_string( boost::optional< non_serializable >( non_serializable() ) ) ); + BOOST_CHECK_EQUAL( "none", to_string( boost::optional< int >() ) ); + BOOST_CHECK_EQUAL( "none", to_string( boost::optional< non_serializable >() ) ); + BOOST_CHECK_EQUAL( "none", to_string( boost::none ) ); +}