1 //////////////////////////////////////////////////////////////////////////////
2 // Name: tests/strings/stdstrings.cpp
3 // Purpose: wxString unit test
4 // Author: Vadim Zeitlin, Wlodzimierz ABX Skiba
7 // Copyright: (c) 2004 Vadim Zeitlin, Wlodzimierz Skiba
8 ///////////////////////////////////////////////////////////////////////////////
10 // ----------------------------------------------------------------------------
12 // ----------------------------------------------------------------------------
24 // ----------------------------------------------------------------------------
26 // ----------------------------------------------------------------------------
28 class StdStringTestCase
: public CppUnit::TestCase
34 CPPUNIT_TEST_SUITE( StdStringTestCase
);
35 CPPUNIT_TEST( StdConstructors
);
36 CPPUNIT_TEST( StdIterators
);
37 CPPUNIT_TEST( StdAppend
);
38 CPPUNIT_TEST( StdAssign
);
39 CPPUNIT_TEST( StdCompare
);
40 CPPUNIT_TEST( StdErase
);
41 CPPUNIT_TEST( StdFind
);
42 CPPUNIT_TEST( StdFindFirst
);
43 CPPUNIT_TEST( StdFindLast
);
44 CPPUNIT_TEST( StdInsert
);
45 CPPUNIT_TEST( StdReplace
);
46 CPPUNIT_TEST( StdRFind
);
47 CPPUNIT_TEST( StdResize
);
48 CPPUNIT_TEST( StdRiter
);
49 CPPUNIT_TEST( StdSubstr
);
51 CPPUNIT_TEST( StdConversion
);
53 CPPUNIT_TEST_SUITE_END();
55 void StdConstructors();
74 DECLARE_NO_COPY_CLASS(StdStringTestCase
)
77 // register in the unnamed registry so that these tests are run by default
78 CPPUNIT_TEST_SUITE_REGISTRATION( StdStringTestCase
);
80 // also include in it's own registry so that these tests can be run alone
81 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( StdStringTestCase
, "StdStringTestCase" );
83 StdStringTestCase::StdStringTestCase()
87 void StdStringTestCase::StdConstructors()
89 wxString
s1(_T("abcdefgh")),
90 s2(_T("abcdefghijklm"), 8),
91 s3(_T("abcdefghijklm")),
95 s7(s3
.begin(), s3
.begin() + 8);
96 wxString
s8(s1
, 4, 8);
98 CPPUNIT_ASSERT_EQUAL( _T("abcdefgh"), s1
);
99 CPPUNIT_ASSERT_EQUAL( s1
, s2
);
100 CPPUNIT_ASSERT_EQUAL( _T("aaaaaaaa"), s4
);
101 CPPUNIT_ASSERT_EQUAL( _T("abcdefgh"), s5
);
102 CPPUNIT_ASSERT_EQUAL( s1
, s6
);
103 CPPUNIT_ASSERT_EQUAL( s1
, s7
);
104 CPPUNIT_ASSERT_EQUAL( _T("efgh"), s8
);
106 const char *pc
= s1
.c_str();
107 CPPUNIT_ASSERT_EQUAL( "bcd", wxString(pc
+ 1, pc
+ 4) );
109 const wchar_t *pw
= s2
.c_str();
110 CPPUNIT_ASSERT_EQUAL( "a", wxString(pw
, pw
+ 1) );
113 void StdStringTestCase::StdIterators()
115 // test compilation of default iterators ctors:
116 wxString::iterator i1
;
117 wxString::const_iterator i2
;
118 wxString::reverse_iterator i3
;
119 wxString::const_reverse_iterator i4
;
122 void StdStringTestCase::StdAppend()
124 wxString s1
, s2
, s3
, s4
, s5
, s6
, s7
, s8
;
126 s1
= s2
= s3
= s4
= s5
= s6
= _T("abc");
127 s1
.append(_T("def"));
128 s2
.append(_T("defgh"), 3);
129 s3
.append(wxString(_T("abcdef")), 3, 6);
131 s5
.append(3, _T('a'));
133 s5
.append(1, (unsigned char)'y');
134 s6
.append(s1
.begin() + 3, s1
.end());
136 CPPUNIT_ASSERT_EQUAL( _T("abcdef"), s1
);
137 CPPUNIT_ASSERT_EQUAL( _T("abcdef"), s2
);
138 CPPUNIT_ASSERT_EQUAL( _T("abcdef"), s3
);
139 CPPUNIT_ASSERT_EQUAL( _T("abcabcdef"), s4
);
140 CPPUNIT_ASSERT_EQUAL( _T("abcaaaxxy"), s5
);
141 CPPUNIT_ASSERT_EQUAL( _T("abcdef"), s6
);
143 const char *pc
= s1
.c_str() + 2;
144 s7
.append(pc
, pc
+ 4);
145 CPPUNIT_ASSERT_EQUAL( "cdef", s7
);
147 const wchar_t *pw
= s2
.c_str() + 2;
148 s8
.append(pw
, pw
+ 4);
149 CPPUNIT_ASSERT_EQUAL( "cdef", s8
);
151 s7
= s8
= wxString(_T("null\0time"), 9);
153 s7
.append(_T("def"));
154 s8
.append(_T("defgh"), 3);
156 CPPUNIT_ASSERT_EQUAL( wxString(_T("null\0timedef"), 12), s7
);
157 CPPUNIT_ASSERT_EQUAL( wxString(_T("null\0timedef"), 12), s8
);
160 void StdStringTestCase::StdAssign()
162 wxString s1
, s2
, s3
, s4
, s5
, s6
, s7
, s8
;
164 s1
= s2
= s3
= s4
= s5
= s6
= s7
= s8
= _T("abc");
165 s1
.assign(_T("def"));
166 s2
.assign(_T("defgh"), 3);
167 s3
.assign(wxString(_T("abcdef")), 3, 6);
169 s5
.assign(3, _T('a'));
170 s6
.assign(s1
.begin() + 1, s1
.end());
172 CPPUNIT_ASSERT_EQUAL( _T("def"), s1
);
173 CPPUNIT_ASSERT_EQUAL( _T("def"), s2
);
174 CPPUNIT_ASSERT_EQUAL( _T("def"), s3
);
175 CPPUNIT_ASSERT_EQUAL( _T("def"), s4
);
176 CPPUNIT_ASSERT_EQUAL( _T("aaa"), s5
);
177 CPPUNIT_ASSERT_EQUAL( _T("ef"), s6
);
179 const char *pc
= s1
.c_str();
180 s7
.assign(pc
, pc
+ 2);
181 CPPUNIT_ASSERT_EQUAL( "de", s7
);
183 const wchar_t *pw
= s1
.c_str();
184 s8
.assign(pw
+ 2, pw
+ 3);
185 CPPUNIT_ASSERT_EQUAL( "f", s8
);
188 CPPUNIT_ASSERT_EQUAL("e", s1
);
191 void StdStringTestCase::StdCompare()
193 wxString s1
, s2
, s3
, s4
, s5
, s6
, s7
, s8
;
198 s4
= _T("abcdefghi");
202 CPPUNIT_ASSERT( s1
.compare(s2
) == 0 );
203 CPPUNIT_ASSERT( s1
.compare(s3
) > 0 );
204 CPPUNIT_ASSERT( s1
.compare(s4
) < 0 );
205 CPPUNIT_ASSERT( s1
.compare(s5
) > 0 );
206 CPPUNIT_ASSERT( s1
.compare(s6
) < 0 );
207 CPPUNIT_ASSERT( s1
.compare(1, 12, s1
) > 0);
208 CPPUNIT_ASSERT( s1
.compare(_T("abcdefgh")) == 0);
209 CPPUNIT_ASSERT( s1
.compare(1, 7, _T("bcdefgh")) == 0);
210 CPPUNIT_ASSERT( s1
.compare(1, 7, _T("bcdefgh"), 7) == 0);
213 void StdStringTestCase::StdErase()
215 wxString s1
, s2
, s3
, s4
, s5
, s6
, s7
;
220 s4
= _T("abcdefghi");
227 wxString::iterator it
= s3
.erase(s3
.begin() + 1);
228 wxString::iterator it2
= s4
.erase(s4
.begin() + 4, s4
.begin() + 6);
229 wxString::iterator it3
= s7
.erase(s7
.begin() + 4, s7
.begin() + 8);
231 CPPUNIT_ASSERT_EQUAL( _T("acdefgh"), s1
);
232 CPPUNIT_ASSERT_EQUAL( _T("abcd"), s2
);
233 CPPUNIT_ASSERT_EQUAL( _T("ac"), s3
);
234 CPPUNIT_ASSERT_EQUAL( _T("abcdghi"), s4
);
235 CPPUNIT_ASSERT_EQUAL( _T("zabc"), s7
);
236 CPPUNIT_ASSERT( *it
== _T('c') );
237 CPPUNIT_ASSERT( *it2
== _T('g') );
238 CPPUNIT_ASSERT( it3
== s7
.end() );
241 void StdStringTestCase::StdFind()
244 // 01234567890123456789012345
245 wxString s1
= _T("abcdefgABCDEFGabcABCabcABC");
246 wxString s2
= _T("gAB");
248 CPPUNIT_ASSERT( s1
.find(_T('A')) == 7u );
249 CPPUNIT_ASSERT( s1
.find(_T('A'), 7) == 7u );
250 CPPUNIT_ASSERT( s1
.find(_T('Z')) == wxString::npos
);
251 CPPUNIT_ASSERT( s1
.find(_T('C'), 22) == 25u );
253 CPPUNIT_ASSERT( s1
.find(_T("gAB")) == 6u );
254 CPPUNIT_ASSERT( s1
.find(_T("gAB"), 7) == wxString::npos
);
255 CPPUNIT_ASSERT( s1
.find(_T("gAB"), 6) == 6u );
257 CPPUNIT_ASSERT( s1
.find(_T("gABZZZ"), 2, 3) == 6u );
258 CPPUNIT_ASSERT( s1
.find(_T("gABZZZ"), 7, 3) == wxString::npos
);
260 CPPUNIT_ASSERT( s1
.find(s2
) == 6u );
261 CPPUNIT_ASSERT( s1
.find(s2
, 7) == wxString::npos
);
262 CPPUNIT_ASSERT( s1
.find(s2
, 6) == 6u );
265 // 0123456 78901234567 8901234567
266 //wxString _s1 = _T("abcdefg\0ABCDEFGabc\0ABCabcABC");
267 //wxString _s2 = _T("g\0AB");
268 wxString _s1
= _T("abcdefgABCDEFGabcABCabcABC");
269 wxString _s2
= _T("gAB");
271 _s1
.insert(7, 1, '\0');
272 _s1
.insert(18, 1, '\0');
273 _s2
.insert(1, 1, '\0');
275 CPPUNIT_ASSERT( _s1
.find(_T('A')) == 8u );
276 CPPUNIT_ASSERT( _s1
.find(_T('A'), 8) == 8u );
277 CPPUNIT_ASSERT( _s1
.find(_T('Z')) == wxString::npos
);
278 CPPUNIT_ASSERT( _s1
.find(_T('C'), 22) == 27u );
280 CPPUNIT_ASSERT( _s1
.find(_T("AB")) == 8u );
281 CPPUNIT_ASSERT( _s1
.find(_T("AB"), 26) == wxString::npos
);
282 CPPUNIT_ASSERT( _s1
.find(_T("AB"), 23) == 25u );
284 CPPUNIT_ASSERT( _s1
.find(_T("ABZZZ"), 2, 2) == 8u );
285 CPPUNIT_ASSERT( _s1
.find(_T("ABZZZ"), 26, 2) == wxString::npos
);
287 CPPUNIT_ASSERT( _s1
.find(_s2
) == 6u );
288 CPPUNIT_ASSERT( _s1
.find(_s2
, 7) == wxString::npos
);
289 CPPUNIT_ASSERT( _s1
.find(_s2
, 6) == 6u );
292 void StdStringTestCase::StdFindFirst()
295 // 01234567890123456789012345678901234
296 wxString s1
= _T("aaaaaabcdefghlkjiaaaaaabcdbcdbcdbcd");
297 wxString s2
= _T("aaaaaa");
299 CPPUNIT_ASSERT( s1
.find_first_not_of(_T('a')) == 6u );
300 CPPUNIT_ASSERT( s1
.find_first_not_of(_T('a'), 7) == 7u );
301 CPPUNIT_ASSERT( s2
.find_first_not_of(_T('a')) == wxString::npos
);
303 CPPUNIT_ASSERT( s1
.find_first_not_of(_T("abde"), 4) == 7u );
304 CPPUNIT_ASSERT( s1
.find_first_not_of(_T("abde"), 7) == 7u );
305 CPPUNIT_ASSERT( s1
.find_first_not_of(_T("abcdefghijkl")) == wxString::npos
);
307 CPPUNIT_ASSERT( s1
.find_first_not_of(_T("abcdefghi"), 0, 4) == 9u );
309 CPPUNIT_ASSERT( s1
.find_first_of(_T('c')) == 7u );
310 CPPUNIT_ASSERT( s1
.find_first_of(_T('v')) == wxString::npos
);
311 CPPUNIT_ASSERT( s1
.find_first_of(_T('c'), 10) == 24u );
313 CPPUNIT_ASSERT( s1
.find_first_of(_T("ijkl")) == 13u );
314 CPPUNIT_ASSERT( s1
.find_first_of(_T("ddcfg"), 17) == 24u );
315 CPPUNIT_ASSERT( s1
.find_first_of(_T("ddcfga"), 17, 5) == 24u );
318 void StdStringTestCase::StdFindLast()
321 // 01234567890123456789012345678901234
322 wxString s1
= _T("aaaaaabcdefghlkjiaaaaaabcdbcdbcdbcd");
323 wxString s2
= _T("aaaaaa");
325 CPPUNIT_ASSERT( s2
.find_last_not_of(_T('a')) == wxString::npos
);
326 CPPUNIT_ASSERT( s1
.find_last_not_of(_T('d')) == 33u );
327 CPPUNIT_ASSERT( s1
.find_last_not_of(_T('d'), 25) == 24u );
329 CPPUNIT_ASSERT( s1
.find_last_not_of(_T("bcd")) == 22u );
330 CPPUNIT_ASSERT( s1
.find_last_not_of(_T("abc"), 24) == 16u );
332 CPPUNIT_ASSERT( s1
.find_last_not_of(_T("abcdefghijklmnopqrstuv"), 24, 3) == 16u );
334 CPPUNIT_ASSERT( s2
.find_last_of(_T('c')) == wxString::npos
);
335 CPPUNIT_ASSERT( s1
.find_last_of(_T('a')) == 22u );
336 CPPUNIT_ASSERT( s1
.find_last_of(_T('b'), 24) == 23u );
338 CPPUNIT_ASSERT( s1
.find_last_of(_T("ijklm")) == 16u );
339 CPPUNIT_ASSERT( s1
.find_last_of(_T("ijklma"), 33, 4) == 16u );
340 CPPUNIT_ASSERT( s1
.find_last_of(_T("a"), 17) == 17u );
345 // 012345 67890123456789 01234567890123456
346 // wxString s1 = _T("aaaaaa\0bcdefghlkjiaa\0aaaabcdbcdbcdbcd");
347 // wxString s2 = _T("aaaaaa\0");
349 s1
.insert(20,1,'\0');
352 CPPUNIT_ASSERT( s2
.find_last_not_of(_T('a')) == 6u );
353 CPPUNIT_ASSERT( s1
.find_last_not_of(_T('d')) == 35u );
354 CPPUNIT_ASSERT( s1
.find_last_not_of(_T('d'), 27) == 26u );
356 CPPUNIT_ASSERT( s1
.find_last_not_of(_T("bcd")) == 24u );
357 CPPUNIT_ASSERT( s1
.find_last_not_of(_T("abc"), 26) == 20u );
359 CPPUNIT_ASSERT( s1
.find_last_not_of(_T("abcdefghijklmnopqrstuv"), 26, 3) == 20u );
361 CPPUNIT_ASSERT( s2
.find_last_of(_T('c')) == wxString::npos
);
362 CPPUNIT_ASSERT( s1
.find_last_of(_T('a')) == 24u );
363 CPPUNIT_ASSERT( s1
.find_last_of(_T('b'), 26) == 25u );
365 CPPUNIT_ASSERT( s1
.find_last_of(_T("ijklm")) == 17u );
366 CPPUNIT_ASSERT( s1
.find_last_of(_T("ijklma"), 35, 4) == 17u );
367 CPPUNIT_ASSERT( s1
.find_last_of(_T("a"), 18) == 18u );
370 void StdStringTestCase::StdInsert()
372 wxString s1
, s2
, s3
, s4
, s5
, s6
, s7
, s8
, s9
, s10
;
374 s1
= s2
= s3
= s4
= s5
= s6
= s7
= s8
= _T("aaaa");
375 s9
= s10
= _T("cdefg");
377 s1
.insert(1, _T("cc") );
378 s2
.insert(2, _T("cdef"), 3);
380 s4
.insert(2, s10
, 3, 7);
381 s5
.insert(1, 2, _T('c'));
382 s6
.insert(s6
.begin() + 3, _T('X'));
383 s7
.insert(s7
.begin(), s9
.begin(), s9
.end() - 1);
384 s8
.insert(s8
.begin(), 2, _T('c'));
386 CPPUNIT_ASSERT_EQUAL( _T("accaaa") , s1
);
387 CPPUNIT_ASSERT_EQUAL( _T("aacdeaa") , s2
);
388 CPPUNIT_ASSERT_EQUAL( _T("aacdefgaa"), s3
);
389 CPPUNIT_ASSERT_EQUAL( _T("aafgaa") , s4
);
390 CPPUNIT_ASSERT_EQUAL( _T("accaaa") , s5
);
391 CPPUNIT_ASSERT_EQUAL( _T("aaaXa") , s6
);
392 CPPUNIT_ASSERT_EQUAL( _T("cdefaaaa") , s7
);
393 CPPUNIT_ASSERT_EQUAL( _T("ccaaaa") , s8
);
395 s1
= s2
= s3
= _T("aaaa");
396 s1
.insert(0, _T("ccc"), 2);
397 s2
.insert(4, _T("ccc"), 2);
399 CPPUNIT_ASSERT_EQUAL( _T("ccaaaa"), s1
);
400 CPPUNIT_ASSERT_EQUAL( _T("aaaacc"), s2
);
403 void StdStringTestCase::StdReplace()
405 wxString s1
, s2
, s3
, s4
, s5
, s6
, s7
, s8
, s9
;
407 s1
= s2
= s3
= s4
= s5
= s6
= s7
= s8
= _T("QWERTYUIOP");
410 s1
.replace(3, 4, _T("rtyu"));
411 s1
.replace(8, 7, _T("opopop"));
412 s2
.replace(10, 12, _T("WWWW"));
413 s3
.replace(1, 5, s9
);
414 s4
.replace(1, 4, s9
, 0, 4);
415 s5
.replace(1, 2, s9
, 1, 12);
416 s6
.replace(0, 123, s9
, 0, 123);
417 s7
.replace(2, 7, s9
);
419 CPPUNIT_ASSERT_EQUAL( _T("QWErtyuIopopop"), s1
);
420 CPPUNIT_ASSERT_EQUAL( _T("QWERTYUIOPWWWW"), s2
);
421 CPPUNIT_ASSERT_EQUAL( _T("QwertyUIOP") , s3
);
422 CPPUNIT_ASSERT_EQUAL( _T("QwertYUIOP") , s4
);
423 CPPUNIT_ASSERT_EQUAL( _T("QertyRTYUIOP") , s5
);
424 CPPUNIT_ASSERT_EQUAL( s9
, s6
);
425 CPPUNIT_ASSERT_EQUAL( _T("QWwertyP"), s7
);
428 void StdStringTestCase::StdRFind()
431 // 01234567890123456789012345
432 wxString s1
= _T("abcdefgABCDEFGabcABCabcABC");
433 wxString s2
= _T("gAB");
434 wxString s3
= _T("ab");
436 CPPUNIT_ASSERT( s1
.rfind(_T('A')) == 23u );
437 CPPUNIT_ASSERT( s1
.rfind(_T('A'), 7) == 7u );
438 CPPUNIT_ASSERT( s1
.rfind(_T('Z')) == wxString::npos
);
439 CPPUNIT_ASSERT( s1
.rfind(_T('C'), 22) == 19u );
441 CPPUNIT_ASSERT( s1
.rfind(_T("cAB")) == 22u );
442 CPPUNIT_ASSERT( s1
.rfind(_T("cAB"), 15) == wxString::npos
);
443 CPPUNIT_ASSERT( s1
.rfind(_T("cAB"), 21) == 16u );
445 CPPUNIT_ASSERT( s1
.rfind(_T("gABZZZ"), 7, 3) == 6u );
446 CPPUNIT_ASSERT( s1
.rfind(_T("gABZZZ"), 5, 3) == wxString::npos
);
448 CPPUNIT_ASSERT( s1
.rfind(s2
) == 6u );
449 CPPUNIT_ASSERT( s1
.rfind(s2
, 5) == wxString::npos
);
450 CPPUNIT_ASSERT( s1
.rfind(s2
, 6) == 6u );
451 CPPUNIT_ASSERT( s1
.rfind(s3
, 1) == 0u );
455 // 01234 56789012 345678901234567
456 // wxString s1 = _T("abcde\0fgABCDE\0FGabcABCabcABC");
457 // wxString s2 = _T("gAB");
458 // wxString s3 = _T("ab");
461 s1
.insert(13,1,'\0');
463 CPPUNIT_ASSERT( s1
.rfind(_T('A')) == 25u );
464 CPPUNIT_ASSERT( s1
.rfind(_T('A'), 8) == 8u );
465 CPPUNIT_ASSERT( s1
.rfind(_T('Z')) == wxString::npos
);
466 CPPUNIT_ASSERT( s1
.rfind(_T('C'), 22) == 21u );
468 CPPUNIT_ASSERT( s1
.rfind(_T("cAB")) == 24u );
469 CPPUNIT_ASSERT( s1
.rfind(_T("cAB"), 15) == wxString::npos
);
470 CPPUNIT_ASSERT( s1
.rfind(_T("cAB"), 21) == 18u );
472 CPPUNIT_ASSERT( s1
.rfind(_T("gABZZZ"), 8, 3) == 7u );
473 CPPUNIT_ASSERT( s1
.rfind(_T("gABZZZ"), 5, 3) == wxString::npos
);
476 void StdStringTestCase::StdResize()
478 wxString s1
, s2
, s3
, s4
;
480 s1
= s2
= s3
= s4
= _T("abcABCdefDEF");
484 s3
.resize( 14, _T(' ') );
485 s4
.resize( 14, _T('W') );
487 CPPUNIT_ASSERT_EQUAL( _T("abcABCdefDEF"), s1
);
488 CPPUNIT_ASSERT_EQUAL( _T("abcABCdefD"), s2
);
489 CPPUNIT_ASSERT_EQUAL( _T("abcABCdefDEF "), s3
);
490 CPPUNIT_ASSERT_EQUAL( _T("abcABCdefDEFWW"), s4
);
493 wxString::FromUTF8("\xd0\x9f\xd1\x80\xd0\xb8\xd0\xb2\xd0\xb5\xd1\x82");
495 CPPUNIT_ASSERT_EQUAL("\xd0\x9f\xd1\x80\xd0\xb8", s
);
498 void StdStringTestCase::StdRiter()
500 const wxString
s(_T("fozbar"));
502 wxString::const_reverse_iterator
ri(s
.rbegin());
503 CPPUNIT_ASSERT( _T('r') == *ri
);
504 CPPUNIT_ASSERT( _T('a') == *++ri
);
505 CPPUNIT_ASSERT( _T('r') == *--ri
);
509 CPPUNIT_ASSERT( _T('f') == *ri
);
512 CPPUNIT_ASSERT( _T('o') == *ri
);
514 wxString::const_iterator i
= ri
.base();
515 CPPUNIT_ASSERT( _T('z') == *i
);
518 void StdStringTestCase::StdSubstr()
520 wxString s1
= _T("abcdefgABCDEFG");
522 CPPUNIT_ASSERT( s1
.substr( 0, 14 ) == s1
);
523 CPPUNIT_ASSERT( s1
.substr( 1, 13 ) == _T("bcdefgABCDEFG") );
524 CPPUNIT_ASSERT( s1
.substr( 1, 20 ) == _T("bcdefgABCDEFG") );
525 CPPUNIT_ASSERT( s1
.substr( 14, 30 ) == _T("") );
529 s1
.insert(13,1,'\0');
531 wxString s2
= wxT("bcdefgABCDEFG");
534 s2
.insert(12,1,'\0');
536 CPPUNIT_ASSERT( s1
.substr( 0, 17 ) == s1
);
537 CPPUNIT_ASSERT( s1
.substr( 1, 17 ) == s2
);
538 CPPUNIT_ASSERT( s1
.substr( 1, 20 ) == s2
);
539 CPPUNIT_ASSERT( s1
.substr( 17, 30 ) == _T("") );
543 void StdStringTestCase::StdConversion()
545 std::string
strStd("std::string value");
546 wxStdWideString
strStdWide(L
"std::wstring value");
549 CPPUNIT_ASSERT_EQUAL( "std::string value", s1
);
551 wxString
s2(strStdWide
);
552 CPPUNIT_ASSERT_EQUAL( "std::wstring value", s2
);
556 CPPUNIT_ASSERT_EQUAL( "std::string value", s3
);
558 CPPUNIT_ASSERT_EQUAL( "std::wstring value", s3
);
560 wxString
s4("hello");
562 // wxString -> std::string conversion is only available in wxUSE_STL case,
563 // because it conflicts with conversion to const char*/wchar_t*:
566 CPPUNIT_ASSERT_EQUAL( "hello", s5
);
568 wxStdWideString s6
= s4
;
569 CPPUNIT_ASSERT_EQUAL( "hello", s6
);
573 CPPUNIT_ASSERT( s7
== "hello" );
575 wxStdWideString
s8(s4
);
576 CPPUNIT_ASSERT( s8
== "hello" );
578 #endif // wxUSE_STD_STRING