Added logging support for std::unique_ptr, std::shared_ptr and std::weak_ptr

git-svn-id: https://svn.code.sf.net/p/turtle/code/trunk@677 860be788-9bd5-4423-9f1e-828f051e677b
This commit is contained in:
mat007 2013-07-09 08:46:43 +00:00
parent 068f73b0bc
commit 808af17eb8
3 changed files with 43 additions and 0 deletions

View file

@ -6,6 +6,7 @@ Not yet released
* Reworked MOCK_CONSTRAINT to be able to provide names to parameters
* Added MOCK_NO_VARIADIC_MACROS to deactivate variadic macros support
* Added support for movable only types as parameters
* Added logging support for std::unique_ptr, std::shared_ptr and std::weak_ptr
[endsect]

View file

@ -402,6 +402,28 @@ BOOST_AUTO_TEST_CASE( boost_weak_ptr_are_serialized )
BOOST_CHECK_NE( "?", to_string( boost::weak_ptr< int >( boost::shared_ptr< int >( new int( 42 ) ) ) ) );
}
#ifdef MOCK_SMART_PTR
BOOST_AUTO_TEST_CASE( std_shared_ptr_are_serialized )
{
BOOST_CHECK_NE( "?", to_string( std::shared_ptr< int >() ) );
BOOST_CHECK_NE( "?", to_string( std::shared_ptr< int >( new int( 42 ) ) ) );
}
BOOST_AUTO_TEST_CASE( std_weak_ptr_are_serialized )
{
BOOST_CHECK_NE( "?", to_string( std::weak_ptr< int >( std::shared_ptr< int >() ) ) );
BOOST_CHECK_NE( "?", to_string( std::weak_ptr< int >( std::shared_ptr< int >( new int( 42 ) ) ) ) );
}
BOOST_AUTO_TEST_CASE( std_unique_ptr_are_serialized )
{
BOOST_CHECK_NE( "?", to_string( std::unique_ptr< int >() ) );
BOOST_CHECK_NE( "?", to_string( std::unique_ptr< int >( new int( 42 ) ) ) );
}
#endif
BOOST_AUTO_TEST_CASE( std_deques_are_serialized )
{
std::deque< int > d;

View file

@ -127,6 +127,25 @@ namespace detail
{
return s << mock::format( t.lock() );
}
#ifdef MOCK_SMART_PTR
template< typename T >
stream& operator<<( stream& s, const std::shared_ptr< T >& t )
{
return s << mock::format( t.get() );
}
template< typename T >
stream& operator<<( stream& s, const std::weak_ptr< T >& t )
{
return s << mock::format( t.lock() );
}
template< typename T, typename Deleter >
inline stream& operator<<( stream& s, const std::unique_ptr< T, Deleter >& p )
{
return s << mock::format( p.get() );
}
#endif
template< typename T >
stream& operator<<( stream& s, const boost::lambda::lambda_functor< T >& )
{
@ -137,6 +156,7 @@ namespace detail
{
return s << '?';
}
#ifdef MOCK_NULLPTR
inline stream& operator<<( stream& s, std::nullptr_t )
{