X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f0f6a32d4d276dd09ecf34cf60d435d2687731f9..fdb97de42b8a1491257566fb7bbd343916f1f2b8:/tests/controls/textentrytest.cpp?ds=sidebyside

diff --git a/tests/controls/textentrytest.cpp b/tests/controls/textentrytest.cpp
index 80e6482fa9..fcd911cf8c 100644
--- a/tests/controls/textentrytest.cpp
+++ b/tests/controls/textentrytest.cpp
@@ -36,7 +36,7 @@ void TextEntryTestCase::SetValue()
     CPPUNIT_ASSERT_EQUAL( "bye", entry->GetValue() );
 }
 
-void TextEntryTestCase::TextChangeEvents()
+namespace
 {
     class TextTestEventHandler : public wxEvtHandler
     {
@@ -55,7 +55,12 @@ void TextEntryTestCase::TextChangeEvents()
 
     private:
         int m_events;
-    } handler;
+    };
+}
+
+void TextEntryTestCase::TextChangeEvents()
+{
+    TextTestEventHandler handler;
 
     GetTestWindow()->Connect
                      (
@@ -96,6 +101,11 @@ void TextEntryTestCase::TextChangeEvents()
     CPPUNIT_ASSERT_EQUAL( 1, handler.GetEvents() );
 }
 
+void TextEntryTestCase::CheckStringSelection(const char *sel)
+{
+    CPPUNIT_ASSERT_EQUAL( sel, GetTestEntry()->GetStringSelection() );
+}
+
 void TextEntryTestCase::AssertSelection(int from, int to, const char *sel)
 {
     wxTextEntry * const entry = GetTestEntry();
@@ -107,9 +117,10 @@ void TextEntryTestCase::AssertSelection(int from, int to, const char *sel)
     entry->GetSelection(&fromReal, &toReal);
     CPPUNIT_ASSERT_EQUAL( from, fromReal );
     CPPUNIT_ASSERT_EQUAL( to, toReal );
-    CPPUNIT_ASSERT_EQUAL( sel, entry->GetStringSelection() );
 
     CPPUNIT_ASSERT_EQUAL( from, entry->GetInsertionPoint() );
+
+    CheckStringSelection(sel);
 }
 
 void TextEntryTestCase::Selection()
@@ -159,3 +170,27 @@ void TextEntryTestCase::InsertionPoint()
     CPPUNIT_ASSERT_EQUAL( 1, entry->GetInsertionPoint() );
 }
 
+void TextEntryTestCase::Replace()
+{
+    wxTextEntry * const entry = GetTestEntry();
+
+    entry->SetValue("Hello replace!"
+                    "0123456789012");
+    entry->SetInsertionPoint(0);
+
+    entry->Replace(6, 13, "changed");
+
+    CPPUNIT_ASSERT_EQUAL("Hello changed!"
+                         "0123456789012",
+                         entry->GetValue());
+    CPPUNIT_ASSERT_EQUAL(13, entry->GetInsertionPoint());
+
+    entry->Replace(13, -1, "");
+    CPPUNIT_ASSERT_EQUAL("Hello changed", entry->GetValue());
+    CPPUNIT_ASSERT_EQUAL(13, entry->GetInsertionPoint());
+
+    entry->Replace(0, 6, "Un");
+    CPPUNIT_ASSERT_EQUAL("Unchanged", entry->GetValue());
+    CPPUNIT_ASSERT_EQUAL(2, entry->GetInsertionPoint());
+}
+