diff options
Diffstat (limited to 'boost/test/utils/xml_printer.hpp')
-rw-r--r-- | boost/test/utils/xml_printer.hpp | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/boost/test/utils/xml_printer.hpp b/boost/test/utils/xml_printer.hpp index ae73cce105..8552a173f9 100644 --- a/boost/test/utils/xml_printer.hpp +++ b/boost/test/utils/xml_printer.hpp @@ -1,4 +1,4 @@ -// (C) Copyright Gennadiy Rozental 2004-2008. +// (C) Copyright Gennadiy Rozental 2004-2014. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) @@ -9,11 +9,11 @@ // // Version : $Revision$ // -// Description : common code used by any agent serving as XML printer +// Description : common code used by any agent serving as OF_XML printer // *************************************************************************** -#ifndef BOOST_TEST_XML_PRINTER_HPP_071894GER -#define BOOST_TEST_XML_PRINTER_HPP_071894GER +#ifndef BOOST_TEST_UTILS_XML_PRINTER_HPP +#define BOOST_TEST_UTILS_XML_PRINTER_HPP // Boost.Test #include <boost/test/utils/basic_cstring/basic_cstring.hpp> @@ -33,7 +33,6 @@ //____________________________________________________________________________// namespace boost { - namespace unit_test { // ************************************************************************** // @@ -82,6 +81,22 @@ print_escaped( std::ostream& where_to, T const& value ) //____________________________________________________________________________// +inline void +print_escaped_cdata( std::ostream& where_to, const_string value ) +{ + static const_string cdata_end( "]]>" ); + + const_string::size_type pos = value.find( cdata_end ); + if( pos == const_string::npos ) + where_to << value; + else { + where_to << value.substr( 0, pos+2 ) << cdata_end + << BOOST_TEST_L( "<![CDATA[" ) << value.substr( pos+2 ); + } +} + +//____________________________________________________________________________// + typedef custom_manip<struct attr_value_t> attr_value; template<typename T> @@ -102,17 +117,16 @@ typedef custom_manip<struct cdata_t> cdata; inline std::ostream& operator<<( custom_printer<cdata> const& p, const_string value ) { - return *p << BOOST_TEST_L( "<![CDATA[" ) << value << BOOST_TEST_L( "]]>" ); + *p << BOOST_TEST_L( "<![CDATA[" ); + print_escaped_cdata( *p, value ); + return *p << BOOST_TEST_L( "]]>" ); } //____________________________________________________________________________// } // namespace unit_test - } // namespace boost -//____________________________________________________________________________// - #include <boost/test/detail/enable_warnings.hpp> -#endif // BOOST_TEST_XML_PRINTER_HPP_071894GER +#endif // BOOST_TEST_UTILS_XML_PRINTER_HPP |