mirror of
https://github.com/mat007/turtle.git
synced 2026-06-22 12:13:43 +00:00
Added logging support for boost::optional
This commit is contained in:
parent
c35b76c8f0
commit
506e10f76a
3 changed files with 24 additions and 0 deletions
|
|
@ -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]
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
#include <boost/utility/enable_if.hpp>
|
||||
#include <boost/detail/container_fwd.hpp>
|
||||
#include <boost/function_types/is_callable_builtin.hpp>
|
||||
#include <boost/none.hpp>
|
||||
#include <memory>
|
||||
|
||||
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 >
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/weak_ptr.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
#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 ) );
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue