mirror of
https://github.com/wxWidgets/wxWidgets.git
synced 2026-09-22 06:05:36 +08:00
Fix wxString::BeforeFirst() when "rest" is the string itself
This didn't work correctly before, but there doesn't seem to be any good reason to not allow this, as it allows to naturally extract some leading prefix from a string and it also already worked for BeforeLast(), so make it work for BeforeFirst() too.
This commit is contained in:
@@ -1127,6 +1127,10 @@ TEST_CASE("StringBeforeAndAfter", "[wxString]")
|
||||
CHECK( s.BeforeFirst('!', &r) == s );
|
||||
CHECK( r == "" );
|
||||
|
||||
const wxString phrase("Two words apart");
|
||||
r = phrase;
|
||||
CHECK( r.BeforeFirst(' ', &r) == "Two" );
|
||||
CHECK( r == "words apart" );
|
||||
|
||||
CHECK( s.BeforeLast('=', &r) == FIRST_PART wxT("=") MIDDLE_PART );
|
||||
CHECK( r == LAST_PART );
|
||||
@@ -1134,6 +1138,10 @@ TEST_CASE("StringBeforeAndAfter", "[wxString]")
|
||||
CHECK( s.BeforeLast('!', &r) == "" );
|
||||
CHECK( r == s );
|
||||
|
||||
r = phrase;
|
||||
CHECK( r.BeforeLast(' ', &r) == "Two words" );
|
||||
CHECK( r == "apart" );
|
||||
|
||||
|
||||
CHECK( s.AfterFirst('=') == MIDDLE_PART wxT("=") LAST_PART );
|
||||
CHECK( s.AfterFirst('!') == "" );
|
||||
|
||||
Reference in New Issue
Block a user