{
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);
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()
{
{ "+-", 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
{
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 },
};
// 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);
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
}