1. changed wxStringTokenizer to not modify the string we're iterating over

but to just update our position in it (makes the code much more clear)
2. added GetLastDelimiter() to make up for lack of mode combining
   wxTOKEN_RET_EMPTY_ALL and RET_DELIMS
3. documented it and added unit tests for it


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@36552 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2005-12-24 00:12:54 +00:00
parent 505a8c2ced
commit 4626c57c58
5 changed files with 112 additions and 62 deletions

View File

@@ -36,11 +36,13 @@ private:
CPPUNIT_TEST_SUITE( TokenizerTestCase );
CPPUNIT_TEST( GetCount );
CPPUNIT_TEST( GetPosition );
CPPUNIT_TEST( LastDelimiter );
CPPUNIT_TEST( StrtokCompat );
CPPUNIT_TEST_SUITE_END();
void GetCount();
void GetPosition();
void LastDelimiter();
void StrtokCompat();
DECLARE_NO_COPY_CLASS(TokenizerTestCase)
@@ -184,6 +186,23 @@ void TokenizerTestCase::GetPosition()
DoTestGetPosition(_T("foo_bar_"), _T("_"), 4, 8, 0);
}
void TokenizerTestCase::LastDelimiter()
{
wxStringTokenizer tkz(_T("a+-b=c"), _T("+-="));
tkz.GetNextToken();
CPPUNIT_ASSERT_EQUAL( _T('+'), tkz.GetLastDelimiter() );
tkz.GetNextToken();
CPPUNIT_ASSERT_EQUAL( _T('-'), tkz.GetLastDelimiter() );
tkz.GetNextToken();
CPPUNIT_ASSERT_EQUAL( _T('='), tkz.GetLastDelimiter() );
tkz.GetNextToken();
CPPUNIT_ASSERT_EQUAL( _T('\0'), tkz.GetLastDelimiter() );
}
void TokenizerTestCase::StrtokCompat()
{
for ( size_t n = 0; n < WXSIZEOF(gs_testData); n++ )