Added formatting specializations for Boost.Assign

git-svn-id: https://svn.code.sf.net/p/turtle/code/trunk@107 860be788-9bd5-4423-9f1e-828f051e677b
This commit is contained in:
mat007 2010-02-01 21:49:15 +00:00
parent cf9bb5d89b
commit a1149fe872
2 changed files with 31 additions and 1 deletions

View file

@ -13,7 +13,9 @@
#include <boost/static_assert.hpp> #include <boost/static_assert.hpp>
#include <boost/utility/enable_if.hpp> #include <boost/utility/enable_if.hpp>
#include <boost/type_traits/integral_constant.hpp> #include <boost/type_traits/integral_constant.hpp>
#ifndef MOCK_NO_STL_FORMAT
#include <boost/detail/container_fwd.hpp> #include <boost/detail/container_fwd.hpp>
#endif // MOCK_NO_STL_FORMAT
#include <sstream> #include <sstream>
#include <ostream> #include <ostream>
@ -132,4 +134,22 @@ namespace detail
#endif // MOCK_NO_STL_FORMAT #endif // MOCK_NO_STL_FORMAT
} }
#ifndef MOCK_NO_BOOST_FORMAT
namespace boost
{
namespace assign_detail
{
template< typename T > class generic_list;
}
}
namespace mock
{
template< typename T >
std::string format( const boost::assign_detail::generic_list< T >& l )
{
return format( l.begin(), l.end() );
}
}
#endif // MOCK_NO_BOOST_FORMAT
#endif // #ifndef MOCK_FORMAT_HPP_INCLUDED #endif // #ifndef MOCK_FORMAT_HPP_INCLUDED

View file

@ -7,13 +7,13 @@
// //
#include <turtle/format.hpp> #include <turtle/format.hpp>
#include <boost/assign.hpp>
#include <ostream> #include <ostream>
#include <deque> #include <deque>
#include <list> #include <list>
#include <vector> #include <vector>
#include <map> #include <map>
#include <set> #include <set>
#include <boost/assign.hpp>
#include <boost/test/auto_unit_test.hpp> #include <boost/test/auto_unit_test.hpp>
#define BOOST_LIB_NAME boost_unit_test_framework #define BOOST_LIB_NAME boost_unit_test_framework
@ -150,3 +150,13 @@ BOOST_AUTO_TEST_CASE( std_multisets_are_serialized )
s.insert( 42 ); s.insert( 42 );
BOOST_CHECK_EQUAL( "(12,42)", mock::format( s ) ); BOOST_CHECK_EQUAL( "(12,42)", mock::format( s ) );
} }
BOOST_AUTO_TEST_CASE( boost_assign_list_of_are_serialized )
{
BOOST_CHECK_EQUAL( "(12,42)", mock::format( boost::assign::list_of( 12 )( 42 ) ) );
}
BOOST_AUTO_TEST_CASE( boost_assign_map_list_of_are_serialized )
{
BOOST_CHECK_EQUAL( "((12,\"12\"),(42,\"42\"))", mock::format( boost::assign::map_list_of( 12, "12" )( 42, "42" ) ) );
}