corrected expected test results to conform to current wxTOKEN_RET_EMPTY behaviour; added the value of loop index for which the test fails to the diagnostic messages

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@36549 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2005-12-23 23:38:22 +00:00
parent 2461117002
commit 822c2b9f65

View File

@@ -93,10 +93,10 @@ gs_testData[] =
{ _T("1:2::3:"), _T(":"), wxTOKEN_RET_DELIMS, 4 }, { _T("1:2::3:"), _T(":"), wxTOKEN_RET_DELIMS, 4 },
{ _T("1:2::3:"), _T(":"), wxTOKEN_STRTOK, 3 }, { _T("1:2::3:"), _T(":"), wxTOKEN_STRTOK, 3 },
{ _T("1:2::3::"), _T(":"), wxTOKEN_DEFAULT, 5 }, { _T("1:2::3::"), _T(":"), wxTOKEN_DEFAULT, 4 },
{ _T("1:2::3::"), _T(":"), wxTOKEN_RET_EMPTY, 4 }, { _T("1:2::3::"), _T(":"), wxTOKEN_RET_EMPTY, 4 },
{ _T("1:2::3::"), _T(":"), wxTOKEN_RET_EMPTY_ALL, 6 }, { _T("1:2::3::"), _T(":"), wxTOKEN_RET_EMPTY_ALL, 6 },
{ _T("1:2::3::"), _T(":"), wxTOKEN_RET_DELIMS, 5 }, { _T("1:2::3::"), _T(":"), wxTOKEN_RET_DELIMS, 4 },
{ _T("1:2::3::"), _T(":"), wxTOKEN_STRTOK, 3 }, { _T("1:2::3::"), _T(":"), wxTOKEN_STRTOK, 3 },
{ _T("1 \t3\t4 6 "), wxDEFAULT_DELIMITERS, wxTOKEN_DEFAULT, 4 }, { _T("1 \t3\t4 6 "), wxDEFAULT_DELIMITERS, wxTOKEN_DEFAULT, 4 },
@@ -108,6 +108,13 @@ gs_testData[] =
{ _T("01-02/99"), _T("/-"), wxTOKEN_RET_DELIMS, 3 }, { _T("01-02/99"), _T("/-"), wxTOKEN_RET_DELIMS, 3 },
}; };
// helper function returning the string showing the index for which the test
// fails in the diagnostic message
static std::string Nth(size_t n)
{
return wxString::Format(_T("for loop index %lu"), (unsigned long)n).mb_str();
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// the tests // the tests
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -119,7 +126,7 @@ void TokenizerTestCase::GetCount()
const TokenizerTestData& ttd = gs_testData[n]; const TokenizerTestData& ttd = gs_testData[n];
wxStringTokenizer tkz(ttd.str, ttd.delims, ttd.mode); wxStringTokenizer tkz(ttd.str, ttd.delims, ttd.mode);
CPPUNIT_ASSERT_EQUAL( ttd.count, tkz.CountTokens() ); CPPUNIT_ASSERT_EQUAL_MESSAGE( Nth(n), ttd.count, tkz.CountTokens() );
size_t count = 0; size_t count = 0;
while ( tkz.HasMoreTokens() ) while ( tkz.HasMoreTokens() )
@@ -128,7 +135,7 @@ void TokenizerTestCase::GetCount()
count++; count++;
} }
CPPUNIT_ASSERT_EQUAL( ttd.count, count ); CPPUNIT_ASSERT_EQUAL_MESSAGE( Nth(n), ttd.count, count );
} }
} }