Added "rest" argument to wxString::Before{First,Last}().

This allows to search the string just once, in BeforeXXX(), when both the
parts of the string before and after some character are needed instead of
having to do it twice in both BeforeXXX() and AfterXXX().

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65862 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2010-10-22 14:17:37 +00:00
parent f48a115976
commit 6becc1e617
5 changed files with 77 additions and 17 deletions

View File

@@ -970,18 +970,33 @@ void StringTestCase::BeforeAndAfter()
{
const wxString s(L"letter=\xe9;\xe7a=l\xe0");
CPPUNIT_ASSERT_EQUAL( "letter", s.BeforeFirst('=') );
CPPUNIT_ASSERT_EQUAL( s, s.BeforeFirst('!') );
CPPUNIT_ASSERT_EQUAL( L"letter=\xe9", s.BeforeFirst(';') );
wxString r;
CPPUNIT_ASSERT_EQUAL( "letter", s.BeforeFirst('=', &r) );
CPPUNIT_ASSERT_EQUAL( L"\xe9;\xe7a=l\xe0", r );
CPPUNIT_ASSERT_EQUAL( s, s.BeforeFirst('!', &r) );
CPPUNIT_ASSERT_EQUAL( "", r );
CPPUNIT_ASSERT_EQUAL( L"letter=\xe9", s.BeforeFirst(';', &r) );
CPPUNIT_ASSERT_EQUAL( L"\xe7a=l\xe0", r );
CPPUNIT_ASSERT_EQUAL( L"letter=\xe9;\xe7a", s.BeforeLast('=', &r) );
CPPUNIT_ASSERT_EQUAL( L"l\xe0", r );
CPPUNIT_ASSERT_EQUAL( "", s.BeforeLast('!', &r) );
CPPUNIT_ASSERT_EQUAL( s, r );
CPPUNIT_ASSERT_EQUAL( L"letter=\xe9", s.BeforeLast(';', &r) );
CPPUNIT_ASSERT_EQUAL( L"\xe7a=l\xe0", r );
CPPUNIT_ASSERT_EQUAL( L"letter=\xe9;\xe7a", s.BeforeLast('=') );
CPPUNIT_ASSERT_EQUAL( "", s.BeforeLast('!') );
CPPUNIT_ASSERT_EQUAL( L"letter=\xe9", s.BeforeLast(';') );
CPPUNIT_ASSERT_EQUAL( L"\xe9;\xe7a=l\xe0", s.AfterFirst('=') );
CPPUNIT_ASSERT_EQUAL( "", s.AfterFirst('!') );
CPPUNIT_ASSERT_EQUAL( L"\xe7a=l\xe0", s.AfterFirst(';') );
CPPUNIT_ASSERT_EQUAL( L"l\xe0", s.AfterLast('=') );
CPPUNIT_ASSERT_EQUAL( s, s.AfterLast('!') );
CPPUNIT_ASSERT_EQUAL( L"\xe7a=l\xe0", s.AfterLast(';') );