mirror of
https://github.com/mat007/turtle.git
synced 2026-06-22 12:13:43 +00:00
Added support for logging std::auto_ptr, boost::shared_ptr and boost::weak_ptr
git-svn-id: https://svn.code.sf.net/p/turtle/code/trunk@305 860be788-9bd5-4423-9f1e-828f051e677b
This commit is contained in:
parent
5ad7562d65
commit
d6850d9c20
3 changed files with 59 additions and 0 deletions
|
|
@ -14,9 +14,13 @@
|
||||||
#include <boost/function_types/is_callable_builtin.hpp>
|
#include <boost/function_types/is_callable_builtin.hpp>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
namespace boost
|
namespace boost
|
||||||
{
|
{
|
||||||
|
template< typename T > class shared_ptr;
|
||||||
|
template< typename T > class weak_ptr;
|
||||||
|
|
||||||
namespace assign_detail
|
namespace assign_detail
|
||||||
{
|
{
|
||||||
template< typename T > class generic_list;
|
template< typename T > class generic_list;
|
||||||
|
|
@ -173,6 +177,11 @@ namespace detail2
|
||||||
return detail2::formatter< T >( t );
|
return detail2::formatter< T >( t );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template< typename T >
|
||||||
|
stream& operator<<( stream& s, const std::auto_ptr< T >& t )
|
||||||
|
{
|
||||||
|
return s << mock::format( t.get() );
|
||||||
|
}
|
||||||
template< typename T1, typename T2 >
|
template< typename T1, typename T2 >
|
||||||
stream& operator<<( stream& s, const std::pair< T1, T2 >& p )
|
stream& operator<<( stream& s, const std::pair< T1, T2 >& p )
|
||||||
{
|
{
|
||||||
|
|
@ -247,6 +256,16 @@ namespace detail
|
||||||
{
|
{
|
||||||
return s << mock::format( t.get() );
|
return s << mock::format( t.get() );
|
||||||
}
|
}
|
||||||
|
template< typename T >
|
||||||
|
stream& operator<<( stream& s, boost::shared_ptr< T > t )
|
||||||
|
{
|
||||||
|
return s << mock::format( t.get() );
|
||||||
|
}
|
||||||
|
template< typename T >
|
||||||
|
stream& operator<<( stream& s, boost::weak_ptr< T > t )
|
||||||
|
{
|
||||||
|
return s << mock::format( t.lock() );
|
||||||
|
}
|
||||||
|
|
||||||
template< typename T >
|
template< typename T >
|
||||||
BOOST_DEDUCED_TYPENAME boost::enable_if<
|
BOOST_DEDUCED_TYPENAME boost::enable_if<
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,8 @@
|
||||||
#define MOCK_USE_CONVERSIONS
|
#define MOCK_USE_CONVERSIONS
|
||||||
#include <turtle/log.hpp>
|
#include <turtle/log.hpp>
|
||||||
#include <boost/assign.hpp>
|
#include <boost/assign.hpp>
|
||||||
|
#include <boost/shared_ptr.hpp>
|
||||||
|
#include <boost/weak_ptr.hpp>
|
||||||
#include <boost/lexical_cast.hpp>
|
#include <boost/lexical_cast.hpp>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <deque>
|
#include <deque>
|
||||||
|
|
@ -359,6 +361,24 @@ BOOST_AUTO_TEST_CASE( std_pairs_are_serialized_with_conversions )
|
||||||
BOOST_CHECK_EQUAL( "(3,42)", to_string( std::make_pair( 3, 42.f ) ) );
|
BOOST_CHECK_EQUAL( "(3,42)", to_string( std::make_pair( 3, 42.f ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE( std_auto_ptr_are_serialized_with_conversions )
|
||||||
|
{
|
||||||
|
BOOST_CHECK_NE( "?", to_string( std::auto_ptr< int >() ) );
|
||||||
|
BOOST_CHECK_NE( "?", to_string( std::auto_ptr< int >( new int( 42 ) ) ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE( boost_shared_ptr_are_serialized_with_conversions )
|
||||||
|
{
|
||||||
|
BOOST_CHECK_NE( "?", to_string( boost::shared_ptr< int >() ) );
|
||||||
|
BOOST_CHECK_NE( "?", to_string( boost::shared_ptr< int >( new int( 42 ) ) ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE( boost_weak_ptr_are_serialized_with_conversions )
|
||||||
|
{
|
||||||
|
BOOST_CHECK_NE( "?", to_string( boost::weak_ptr< int >( boost::shared_ptr< int >() ) ) );
|
||||||
|
BOOST_CHECK_NE( "?", to_string( boost::weak_ptr< int >( boost::shared_ptr< int >( new int( 42 ) ) ) ) );
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE( std_deques_are_serialized_with_conversions )
|
BOOST_AUTO_TEST_CASE( std_deques_are_serialized_with_conversions )
|
||||||
{
|
{
|
||||||
std::deque< int > d;
|
std::deque< int > d;
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,8 @@
|
||||||
|
|
||||||
#include <turtle/log.hpp>
|
#include <turtle/log.hpp>
|
||||||
#include <boost/assign.hpp>
|
#include <boost/assign.hpp>
|
||||||
|
#include <boost/shared_ptr.hpp>
|
||||||
|
#include <boost/weak_ptr.hpp>
|
||||||
#include <boost/lexical_cast.hpp>
|
#include <boost/lexical_cast.hpp>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <deque>
|
#include <deque>
|
||||||
|
|
@ -355,6 +357,24 @@ BOOST_AUTO_TEST_CASE( std_pairs_are_serialized_without_conversions )
|
||||||
BOOST_CHECK_EQUAL( "(3,42)", to_string( std::make_pair( 3, 42.f ) ) );
|
BOOST_CHECK_EQUAL( "(3,42)", to_string( std::make_pair( 3, 42.f ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE( std_auto_ptr_are_serialized_without_conversions )
|
||||||
|
{
|
||||||
|
BOOST_CHECK_NE( "?", to_string( std::auto_ptr< int >() ) );
|
||||||
|
BOOST_CHECK_NE( "?", to_string( std::auto_ptr< int >( new int( 42 ) ) ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE( boost_shared_ptr_are_serialized_without_conversions )
|
||||||
|
{
|
||||||
|
BOOST_CHECK_NE( "?", to_string( boost::shared_ptr< int >() ) );
|
||||||
|
BOOST_CHECK_NE( "?", to_string( boost::shared_ptr< int >( new int( 42 ) ) ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE( boost_weak_ptr_are_serialized_without_conversions )
|
||||||
|
{
|
||||||
|
BOOST_CHECK_NE( "?", to_string( boost::weak_ptr< int >( boost::shared_ptr< int >() ) ) );
|
||||||
|
BOOST_CHECK_NE( "?", to_string( boost::weak_ptr< int >( boost::shared_ptr< int >( new int( 42 ) ) ) ) );
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE( std_deques_are_serialized_without_conversions )
|
BOOST_AUTO_TEST_CASE( std_deques_are_serialized_without_conversions )
|
||||||
{
|
{
|
||||||
std::deque< int > d;
|
std::deque< int > d;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue