yet more wxString tests for null chars
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@33444 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -98,7 +98,7 @@ void StdStringTestCase::StdAppend()
|
||||
{
|
||||
wxString s1, s2, s3, s4, s5, s6, s7, s8;
|
||||
|
||||
s1 = s2 = s3 = s4 = s5 = s6 = s7 = s8 = _T("abc");
|
||||
s1 = s2 = s3 = s4 = s5 = s6 = _T("abc");
|
||||
s1.append(_T("def"));
|
||||
s2.append(_T("defgh"), 3);
|
||||
s3.append(wxString(_T("abcdef")), 3, 6);
|
||||
@@ -112,6 +112,14 @@ void StdStringTestCase::StdAppend()
|
||||
CPPUNIT_ASSERT( s4 == _T("abcabcdef") );
|
||||
CPPUNIT_ASSERT( s5 == _T("abcaaa") );
|
||||
CPPUNIT_ASSERT( s6 == _T("abcdef") );
|
||||
|
||||
s7 = s8 = wxString(_T("null\0time"), 9);
|
||||
|
||||
s7.append(_T("def"));
|
||||
s8.append(_T("defgh"), 3);
|
||||
|
||||
CPPUNIT_ASSERT( s7 == wxString(_T("null\0timedef"), 12) );
|
||||
CPPUNIT_ASSERT( s8 == wxString(_T("null\0timedef"), 12) );
|
||||
}
|
||||
|
||||
void StdStringTestCase::StdAssign()
|
||||
|
@@ -259,8 +259,11 @@ void StringTestCase::ConversionUTF7()
|
||||
{
|
||||
{ "+-", L"+" },
|
||||
{ "+--", L"+-" },
|
||||
//\u isn't recognized on MSVC 6
|
||||
#if !defined(_MSC_VER)
|
||||
#if !defined(__GNUC__) || (__GNUC__ >= 3)
|
||||
{ "+AKM-", L"\u00a3" },
|
||||
#endif
|
||||
#endif
|
||||
// Windows accepts invalid UTF-7 strings and so does our UTF-7
|
||||
// conversion code -- this is wrong IMO but the way it is for now
|
||||
@@ -285,8 +288,11 @@ void StringTestCase::ConversionUTF8()
|
||||
{
|
||||
static const StringConversionData utf8data[] =
|
||||
{
|
||||
//\u isn't recognized on MSVC 6
|
||||
#if !defined(_MSC_VER)
|
||||
#if !defined(__GNUC__) || (__GNUC__ >= 3)
|
||||
{ "\xc2\xa3", L"\u00a3" },
|
||||
#endif
|
||||
#endif
|
||||
{ "\xc2", NULL },
|
||||
};
|
||||
@@ -402,8 +408,8 @@ void StringTestCase::Tokenizer()
|
||||
// call this with the string to tokenize, delimeters to use and the expected
|
||||
// positions (i.e. results of GetPosition()) after each GetNextToken() call,
|
||||
// terminate positions with 0
|
||||
static void
|
||||
DoTokenizerGetPosition(const wxChar *s, const wxChar *delims, int pos, ...)
|
||||
static void DoTokenizerGetPosition(const wxChar *s,
|
||||
const wxChar *delims, int pos, ...)
|
||||
{
|
||||
wxStringTokenizer tkz(s, delims);
|
||||
|
||||
@@ -452,6 +458,29 @@ void StringTestCase::Replace()
|
||||
TEST_REPLACE( _T("foobar"), 3, 0, _T("-"), _T("foo-bar") );
|
||||
TEST_REPLACE( _T("barfoo"), 0, 6, _T("foobar"), _T("foobar") );
|
||||
|
||||
|
||||
#define TEST_NULLCHARREPLACE( o , olen, pos , len , replacement , r, rlen ) \
|
||||
{ \
|
||||
wxString s(o,olen); \
|
||||
s.replace( pos , len , replacement ); \
|
||||
CPPUNIT_ASSERT( s == wxString(r,rlen) ); \
|
||||
}
|
||||
|
||||
TEST_NULLCHARREPLACE( _T("null\0char"), 9, 5, 1, _T("d"),
|
||||
_T("null\0dhar"), 9 );
|
||||
|
||||
#define TEST_WXREPLACE( o , olen, olds, news, all, r, rlen ) \
|
||||
{ \
|
||||
wxString s(o,olen); \
|
||||
s.Replace( olds, news, all ); \
|
||||
CPPUNIT_ASSERT( s == wxString(r,rlen) ); \
|
||||
}
|
||||
|
||||
TEST_WXREPLACE( _T("null\0char"), 9, _T("c"), _T("d"), true,
|
||||
_T("null\0dhar"), 9 );
|
||||
|
||||
#undef TEST_WXREPLACE
|
||||
#undef TEST_NULLCHARREPLACE
|
||||
#undef TEST_REPLACE
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user