From a1149fe872705fff5b1b821eb38efc614bb342d4 Mon Sep 17 00:00:00 2001 From: mat007 Date: Mon, 1 Feb 2010 21:49:15 +0000 Subject: [PATCH] Added formatting specializations for Boost.Assign git-svn-id: https://svn.code.sf.net/p/turtle/code/trunk@107 860be788-9bd5-4423-9f1e-828f051e677b --- src/libraries/turtle/format.hpp | 20 ++++++++++++++++++++ src/tests/turtle_test/format_test.cpp | 12 +++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/libraries/turtle/format.hpp b/src/libraries/turtle/format.hpp index 18afa46..81b7fcc 100644 --- a/src/libraries/turtle/format.hpp +++ b/src/libraries/turtle/format.hpp @@ -13,7 +13,9 @@ #include #include #include +#ifndef MOCK_NO_STL_FORMAT #include +#endif // MOCK_NO_STL_FORMAT #include #include @@ -132,4 +134,22 @@ namespace detail #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 diff --git a/src/tests/turtle_test/format_test.cpp b/src/tests/turtle_test/format_test.cpp index 020a6f3..ab41c6a 100644 --- a/src/tests/turtle_test/format_test.cpp +++ b/src/tests/turtle_test/format_test.cpp @@ -7,13 +7,13 @@ // #include +#include #include #include #include #include #include #include -#include #include #define BOOST_LIB_NAME boost_unit_test_framework @@ -150,3 +150,13 @@ BOOST_AUTO_TEST_CASE( std_multisets_are_serialized ) s.insert( 42 ); 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" ) ) ); +}