boostorg / test

The reference C++ unit testing framework (TDD, xUnit, C++03/11/14/17)
http://boost.org/libs/test
Boost Software License 1.0
183 stars 140 forks source link

print_escaped_cdata only escapes first cdata #350

Open davidmatson opened 2 years ago

davidmatson commented 2 years ago

This works:

BOOST_AUTO_TEST_CASE(one_embedded_cdata_section)
{
    BOOST_REQUIRE_MESSAGE(false, "<![CDATA[EmbeddedCDATA]]>AdditionalTextAfterwards");
}

This produces invalid XML data using -o XML:

BOOST_AUTO_TEST_CASE(two_embedded_cdata_sections)
{
    BOOST_REQUIRE_MESSAGE(false, "<![CDATA[EmbeddedCDATA1]]><![CDATA[EmbeddedCDATA2]]>AdditionalTextAfterwards");
}

I believe the if test here: if( pos == const_string::npos ) needs to be a loop instead.