Add wxMarkupParser::Strip().
This helper function strips all markup tags from the string (and also decodes the XML entities in it). git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67049 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -27,10 +27,12 @@ private:
|
||||
CPPUNIT_TEST_SUITE( MarkupTestCase );
|
||||
CPPUNIT_TEST( RoundTrip );
|
||||
CPPUNIT_TEST( Quote );
|
||||
CPPUNIT_TEST( Strip );
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
void RoundTrip();
|
||||
void Quote();
|
||||
void Strip();
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(MarkupTestCase);
|
||||
};
|
||||
@@ -196,3 +198,23 @@ void MarkupTestCase::Quote()
|
||||
CPPUNIT_ASSERT_EQUAL( "B&B", wxMarkupParser::Quote("B&B") );
|
||||
CPPUNIT_ASSERT_EQUAL( """", wxMarkupParser::Quote("\"\"") );
|
||||
}
|
||||
|
||||
void MarkupTestCase::Strip()
|
||||
{
|
||||
#define CHECK_STRIP( text, stripped ) \
|
||||
CPPUNIT_ASSERT_EQUAL( stripped, wxMarkupParser::Strip(text) )
|
||||
|
||||
CHECK_STRIP( "", "" );
|
||||
CHECK_STRIP( "foo", "foo" );
|
||||
CHECK_STRIP( "<foo>", "<foo>" );
|
||||
CHECK_STRIP( "<b>Big</b> problem", "Big problem" );
|
||||
CHECK_STRIP( "<span foreground=\"red\">c</span>"
|
||||
"<span background=\"green\">o</span>"
|
||||
"<span background=\"blue\">l</span>"
|
||||
"<span background=\"green\">o</span>"
|
||||
"<span foreground=\"yellow\">u</span>"
|
||||
"<span background=\"green\">r</span>",
|
||||
"colour" );
|
||||
|
||||
#undef CHECK_STRIP
|
||||
}
|
||||
|
Reference in New Issue
Block a user