]> git.saurik.com Git - wxWidgets.git/blobdiff - tests/controls/markuptest.cpp
Support for undoable application of custom properties, and customisation of propertie...
[wxWidgets.git] / tests / controls / markuptest.cpp
index 789598b946df237bfacbf860c47d7518972e09a4..c13c38d6734f2b347876b815a029834ec34df76a 100644 (file)
@@ -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);
 };
@@ -38,7 +40,7 @@ private:
 // register in the unnamed registry so that these tests are run by default
 CPPUNIT_TEST_SUITE_REGISTRATION( MarkupTestCase );
 
-// also include in it's own registry so that these tests can be run alone
+// also include in its own registry so that these tests can be run alone
 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( MarkupTestCase, "MarkupTestCase" );
 
 void MarkupTestCase::RoundTrip()
@@ -84,13 +86,13 @@ void MarkupTestCase::RoundTrip()
             m_text << "<span";
 
             if ( !attrs.m_fgCol.empty() )
-                m_text << " foreground=\"" << attrs.m_fgCol << "\"";
+                m_text << " foreground='" << attrs.m_fgCol << "'";
 
             if ( !attrs.m_bgCol.empty() )
-                m_text << " background=\"" << attrs.m_bgCol << "\"";
+                m_text << " background='" << attrs.m_bgCol << "'";
 
             if ( !attrs.m_fontFace.empty() )
-                m_text << " face=\"" << attrs.m_fontFace << "\"";
+                m_text << " face='" << attrs.m_fontFace << "'";
 
             wxString size;
             switch ( attrs.m_sizeKind )
@@ -123,7 +125,7 @@ void MarkupTestCase::RoundTrip()
             }
 
             if ( !size.empty() )
-                m_text << " size=\"" << size << '"';
+                m_text << " size='" << size << '\'';
 
             // TODO: Handle the rest of attributes.
 
@@ -160,17 +162,17 @@ void MarkupTestCase::RoundTrip()
     CHECK_PARSES_OK( "foo" );
     CHECK_PARSES_OK( "foo<b>bar</b>" );
     CHECK_PARSES_OK( "1<big>2<small>3</small>4<big>5</big></big>6" );
-    CHECK_PARSES_OK( "first <span foreground=\"red\">second</span> last" );
-    CHECK_PARSES_OK( "first <span foreground=\"red\" "
-                                 "background=\"#ffffff\">second </span> last" );
-    CHECK_PARSES_OK( "<span size=\"10240\">10pt</span>" );
-    CHECK_PARSES_OK( "<span size=\"x-small\">much smaller</span>" );
-    CHECK_PARSES_OK( "<span size=\"larger\">larger</span>" );
+    CHECK_PARSES_OK( "first <span foreground='red'>second</span> last" );
+    CHECK_PARSES_OK( "first <span foreground='red' "
+                                 "background='#ffffff'>second </span> last" );
+    CHECK_PARSES_OK( "<span size='10240'>10pt</span>" );
+    CHECK_PARSES_OK( "<span size='x-small'>much smaller</span>" );
+    CHECK_PARSES_OK( "<span size='larger'>larger</span>" );
     CHECK_PARSES_OK
     (
-        "<u>Please</u> notice: <i><b>any</b></i> <span foreground=\"grey\">"
-        "<s><tt>bugs</tt></s></span> in this code are <span foreground=\"red\" "
-        "size=\"xx-large\">NOT</span> allowed."
+        "<u>Please</u> notice: <i><b>any</b></i> <span foreground='grey'>"
+        "<s><tt>bugs</tt></s></span> in this code are <span foreground='red' "
+        "size='xx-large'>NOT</span> allowed."
     );
 
     CHECK_PARSES_OK( "foo&bar" );
@@ -196,3 +198,23 @@ void MarkupTestCase::Quote()
     CPPUNIT_ASSERT_EQUAL( "B&amp;B", wxMarkupParser::Quote("B&B") );
     CPPUNIT_ASSERT_EQUAL( "&quot;&quot;", 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( "&lt;foo&gt;", "<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
+}