1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: tests/strings/strings.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 #include "wx/tokenzr.h"
26 // ----------------------------------------------------------------------------
28 // ----------------------------------------------------------------------------
30 class StringTestCase
: public CppUnit::TestCase
36 CPPUNIT_TEST_SUITE( StringTestCase
);
37 CPPUNIT_TEST( String
);
38 CPPUNIT_TEST( PChar
);
39 CPPUNIT_TEST( Format
);
40 CPPUNIT_TEST( Constructors
);
42 CPPUNIT_TEST( ConstructorsWithConversion
);
43 CPPUNIT_TEST( Conversion
);
44 CPPUNIT_TEST( ConversionUTF7
);
45 CPPUNIT_TEST( ConversionUTF8
);
46 #endif // wxUSE_WCHAR_T
47 CPPUNIT_TEST( Extraction
);
49 CPPUNIT_TEST( Tokenizer
);
50 CPPUNIT_TEST( TokenizerGetPosition
);
51 CPPUNIT_TEST( Replace
);
52 CPPUNIT_TEST( Match
);
53 CPPUNIT_TEST( CaseChanges
);
54 CPPUNIT_TEST( Compare
);
55 CPPUNIT_TEST( CompareNoCase
);
56 CPPUNIT_TEST( ToLong
);
57 CPPUNIT_TEST( ToULong
);
58 CPPUNIT_TEST( ToDouble
);
59 CPPUNIT_TEST_SUITE_END();
66 void ConstructorsWithConversion();
68 void ConversionUTF7();
69 void ConversionUTF8();
70 #endif // wxUSE_WCHAR_T
73 void SingleTokenizerTest( wxChar
*str
, wxChar
*delims
, size_t count
, wxStringTokenizerMode mode
);
75 void TokenizerGetPosition();
86 // test if converting s using the given encoding gives ws and vice versa
88 // if either of the first 2 arguments is NULL, the conversion is supposed
90 void DoTestConversion(const char *s
, const wchar_t *w
, wxCSConv
& conv
);
91 #endif // wxUSE_WCHAR_T
93 DECLARE_NO_COPY_CLASS(StringTestCase
)
96 // register in the unnamed registry so that these tests are run by default
97 CPPUNIT_TEST_SUITE_REGISTRATION( StringTestCase
);
99 // also include in it's own registry so that these tests can be run alone
100 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( StringTestCase
, "StringTestCase" );
102 StringTestCase::StringTestCase()
106 void StringTestCase::String()
114 for (int i
= 0; i
< 2; ++i
)
118 c
= _T("! How'ya doin'?");
121 c
= _T("Hello world! What's up?");
122 CPPUNIT_ASSERT( c
!= a
);
126 void StringTestCase::PChar()
132 for (int i
= 0; i
< 2; ++i
)
134 wxStrcpy (a
, _T("Hello"));
135 wxStrcpy (b
, _T(" world"));
136 wxStrcpy (c
, _T("! How'ya doin'?"));
139 wxStrcpy (c
, _T("Hello world! What's up?"));
140 CPPUNIT_ASSERT( wxStrcmp (c
, a
) != 0 );
144 void StringTestCase::Format()
147 s1
.Printf(_T("%03d"), 18);
148 CPPUNIT_ASSERT( s1
== wxString::Format(_T("%03d"), 18) );
149 s2
.Printf(_T("Number 18: %s\n"), s1
.c_str());
150 CPPUNIT_ASSERT( s2
== wxString::Format(_T("Number 18: %s\n"), s1
.c_str()) );
152 static const size_t lengths
[] = { 1, 512, 1024, 1025, 2048, 4096, 4097 };
153 for ( size_t n
= 0; n
< WXSIZEOF(lengths
); n
++ )
155 const size_t len
= lengths
[n
];
157 wxString
s(_T('Z'), len
);
158 CPPUNIT_ASSERT_EQUAL( len
, wxString::Format(_T("%s"), s
.c_str()).length());
162 void StringTestCase::Constructors()
164 #define TEST_CTOR(args, res) \
167 CPPUNIT_ASSERT( s == res ); \
170 TEST_CTOR((_T('Z'), 4), _T("ZZZZ"));
171 TEST_CTOR((_T("Hello"), 4), _T("Hell"));
172 TEST_CTOR((_T("Hello"), 5), _T("Hello"));
174 static const wxChar
*s
= _T("?really!");
175 const wxChar
*start
= wxStrchr(s
, _T('r'));
176 const wxChar
*end
= wxStrchr(s
, _T('!'));
177 TEST_CTOR((start
, end
), _T("really"));
181 void StringTestCase::ConstructorsWithConversion()
183 // the string "Déjà" in UTF-8 and wchar_t:
184 const unsigned char utf8Buf
[] = {0x44,0xC3,0xA9,0x6A,0xC3,0xA0,0};
185 const wchar_t wchar
[] = {0x44,0xE9,0x6A,0xE0,0};
186 const unsigned char utf8subBuf
[] = {0x44,0xC3,0xA9,0x6A,0}; // just "Déj"
187 const char *utf8
= (char *)utf8Buf
;
188 const char *utf8sub
= (char *)utf8subBuf
;
190 wxString
s1(utf8
, wxConvUTF8
);
191 wxString
s2(wchar
, wxConvUTF8
);
194 CPPUNIT_ASSERT( s1
== wchar
);
195 CPPUNIT_ASSERT( s2
== wchar
);
197 CPPUNIT_ASSERT( s1
== utf8
);
198 CPPUNIT_ASSERT( s2
== utf8
);
201 wxString
sub(utf8sub
, wxConvUTF8
); // "Dej" substring
202 wxString
s3(utf8
, wxConvUTF8
, 4);
203 wxString
s4(wchar
, wxConvUTF8
, 3);
205 CPPUNIT_ASSERT( s3
== sub
);
206 CPPUNIT_ASSERT( s4
== sub
);
209 CPPUNIT_ASSERT ( wxString("\t[pl]open.format.Sformatuj dyskietkê=gfloppy %f",
210 wxConvUTF8
) == wxT("") ); //should stop at pos 35
214 void StringTestCase::Conversion()
217 wxString
szTheString(L
"The\0String", wxConvLibc
, 10);
218 wxCharBuffer theBuffer
= szTheString
.mb_str();
220 CPPUNIT_ASSERT( memcmp(theBuffer
.data(), "The\0String", 11) == 0 );
222 wxString
szTheString2("The\0String", wxConvLocal
, 10);
223 CPPUNIT_ASSERT( szTheString2
.length() == 11 );
224 CPPUNIT_ASSERT( wxTmemcmp(szTheString2
.c_str(), L
"The\0String", 11) == 0 );
226 wxString
szTheString(wxT("TheString"));
227 szTheString
.insert(3, 1, '\0');
228 wxWCharBuffer theBuffer
= szTheString
.wc_str(wxConvLibc
);
230 CPPUNIT_ASSERT( memcmp(theBuffer
.data(), L
"The\0String", 11 * sizeof(wchar_t)) == 0 );
232 wxString
szLocalTheString(wxT("TheString"));
233 szLocalTheString
.insert(3, 1, '\0');
234 wxWCharBuffer theLocalBuffer
= szLocalTheString
.wc_str(wxConvLocal
);
236 CPPUNIT_ASSERT( memcmp(theLocalBuffer
.data(), L
"The\0String", 11 * sizeof(wchar_t)) == 0 );
241 // in case wcscmp is missing
243 static int wx_wcscmp(const wchar_t *s1
, const wchar_t *s2
)
245 while (*s1
== *s2
&& *s1
!= 0)
255 StringTestCase::DoTestConversion(const char *s
,
262 wxCharBuffer
buf(wxString(ws
).mb_str(conv
));
264 CPPUNIT_ASSERT( strcmp(buf
, s
) == 0 );
266 #else // wxUSE_UNICODE
269 wxWCharBuffer
wbuf(wxString(s
).wc_str(conv
));
272 CPPUNIT_ASSERT( wx_wcscmp(wbuf
, ws
) == 0 );
274 CPPUNIT_ASSERT( !*wbuf
);
276 #endif // wxUSE_UNICODE/!wxUSE_UNICODE
279 struct StringConversionData
285 void StringTestCase::ConversionUTF7()
287 static const StringConversionData utf7data
[] =
291 //\u isn't recognized on MSVC 6
292 #if !defined(_MSC_VER)
293 #if !defined(__GNUC__) || (__GNUC__ >= 3)
294 { "+AKM-", L
"\u00a3" },
297 // Windows accepts invalid UTF-7 strings and so does our UTF-7
298 // conversion code -- this is wrong IMO but the way it is for now
300 // notice that converting "+" still behaves as expected because the
301 // result is just an empty string, i.e. the same as if there were an
302 // error, but converting "a+" results in "a" while it really should
308 wxCSConv
conv(_T("utf-7"));
309 for ( size_t n
= 0; n
< WXSIZEOF(utf7data
); n
++ )
311 const StringConversionData
& d
= utf7data
[n
];
312 DoTestConversion(d
.str
, d
.wcs
, conv
);
316 void StringTestCase::ConversionUTF8()
318 static const StringConversionData utf8data
[] =
320 //\u isn't recognized on MSVC 6
321 #if !defined(_MSC_VER)
322 #if !defined(__GNUC__) || (__GNUC__ >= 3)
323 { "\xc2\xa3", L
"\u00a3" },
329 wxCSConv
conv(_T("utf-8"));
330 for ( size_t n
= 0; n
< WXSIZEOF(utf8data
); n
++ )
332 const StringConversionData
& d
= utf8data
[n
];
333 DoTestConversion(d
.str
, d
.wcs
, conv
);
337 #endif // wxUSE_WCHAR_T
340 void StringTestCase::Extraction()
342 wxString
s(_T("Hello, world!"));
344 CPPUNIT_ASSERT( wxStrcmp( s
.c_str() , _T("Hello, world!") ) == 0 );
345 CPPUNIT_ASSERT( wxStrcmp( s
.Left(5).c_str() , _T("Hello") ) == 0 );
346 CPPUNIT_ASSERT( wxStrcmp( s
.Right(6).c_str() , _T("world!") ) == 0 );
347 CPPUNIT_ASSERT( wxStrcmp( s(3, 5).c_str() , _T("lo, w") ) == 0 );
348 CPPUNIT_ASSERT( wxStrcmp( s
.Mid(3).c_str() , _T("lo, world!") ) == 0 );
349 CPPUNIT_ASSERT( wxStrcmp( s
.substr(3, 5).c_str() , _T("lo, w") ) == 0 );
350 CPPUNIT_ASSERT( wxStrcmp( s
.substr(3).c_str() , _T("lo, world!") ) == 0 );
354 #define TEST_STARTS_WITH( prefix , correct_rest, result ) \
356 ( s.StartsWith( prefix, &rest ) == result ) && \
357 ( ( result == false ) || ( wxStrcmp( correct_rest , rest ) == 0 ) ) \
360 TEST_STARTS_WITH( _T("Hello"), _T(", world!"), true );
361 TEST_STARTS_WITH( _T("Hello, "), _T("world!"), true );
362 TEST_STARTS_WITH( _T("Hello, world!"), _T(""), true );
363 TEST_STARTS_WITH( _T("Hello, world!!!"), _T(""), false );
364 TEST_STARTS_WITH( _T(""), _T("Hello, world!"), true );
365 TEST_STARTS_WITH( _T("Goodbye"), _T(""), false );
366 TEST_STARTS_WITH( _T("Hi"), _T(""), false );
368 #undef TEST_STARTS_WITH
371 void StringTestCase::Find()
373 #define TEST_FIND( str , start , result ) \
374 CPPUNIT_ASSERT( wxString(str).find(_T("ell"), start) == result );
376 TEST_FIND( _T("Well, hello world"), 0, 1 );
377 TEST_FIND( _T("Well, hello world"), 6, 7 );
378 TEST_FIND( _T("Well, hello world"), 9, wxString::npos
);
383 void StringTestCase::SingleTokenizerTest( wxChar
*str
, wxChar
*delims
, size_t count
, wxStringTokenizerMode mode
)
385 wxStringTokenizer
tkz( str
, delims
, mode
);
386 CPPUNIT_ASSERT( tkz
.CountTokens() == count
);
388 wxChar
*buf
, *s
= NULL
, *last
;
390 if ( tkz
.GetMode() == wxTOKEN_STRTOK
)
392 buf
= new wxChar
[wxStrlen(str
) + 1];
394 s
= wxStrtok(buf
, delims
, &last
);
402 while ( tkz
.HasMoreTokens() )
404 wxString token
= tkz
.GetNextToken();
407 CPPUNIT_ASSERT( token
== s
);
408 s
= wxStrtok(NULL
, delims
, &last
);
413 CPPUNIT_ASSERT( count2
== count
);
420 void StringTestCase::Tokenizer()
422 SingleTokenizerTest( _T(""), _T(" "), 0, wxTOKEN_DEFAULT
);
423 SingleTokenizerTest( _T("Hello, world"), _T(" "), 2, wxTOKEN_DEFAULT
);
424 SingleTokenizerTest( _T("Hello, world "), _T(" "), 2, wxTOKEN_DEFAULT
);
425 SingleTokenizerTest( _T("Hello, world"), _T(","), 2, wxTOKEN_DEFAULT
);
426 SingleTokenizerTest( _T("Hello, world!"), _T(",!"), 2, wxTOKEN_DEFAULT
);
427 SingleTokenizerTest( _T("Hello,, world!"), _T(",!"), 3, wxTOKEN_DEFAULT
);
428 SingleTokenizerTest( _T("Hello, world!"), _T(",!"), 3, wxTOKEN_RET_EMPTY_ALL
);
429 SingleTokenizerTest( _T("username:password:uid:gid:gecos:home:shell"), _T(":"), 7, wxTOKEN_DEFAULT
);
430 SingleTokenizerTest( _T("1 \t3\t4 6 "), wxDEFAULT_DELIMITERS
, 4, wxTOKEN_DEFAULT
);
431 SingleTokenizerTest( _T("1 \t3\t4 6 "), wxDEFAULT_DELIMITERS
, 6, wxTOKEN_RET_EMPTY
);
432 SingleTokenizerTest( _T("1 \t3\t4 6 "), wxDEFAULT_DELIMITERS
, 9, wxTOKEN_RET_EMPTY_ALL
);
433 SingleTokenizerTest( _T("01/02/99"), _T("/-"), 3, wxTOKEN_DEFAULT
);
434 SingleTokenizerTest( _T("01-02/99"), _T("/-"), 3, wxTOKEN_RET_DELIMS
);
437 // call this with the string to tokenize, delimeters to use and the expected
438 // positions (i.e. results of GetPosition()) after each GetNextToken() call,
439 // terminate positions with 0
440 static void DoTokenizerGetPosition(const wxChar
*s
,
441 const wxChar
*delims
, int pos
, ...)
443 wxStringTokenizer
tkz(s
, delims
);
445 CPPUNIT_ASSERT( tkz
.GetPosition() == 0 );
454 CPPUNIT_ASSERT( !tkz
.HasMoreTokens() );
460 CPPUNIT_ASSERT( tkz
.GetPosition() == (size_t)pos
);
462 pos
= va_arg(ap
, int);
468 void StringTestCase::TokenizerGetPosition()
470 DoTokenizerGetPosition(_T("foo"), _T("_"), 3, 0);
471 DoTokenizerGetPosition(_T("foo_bar"), _T("_"), 4, 7, 0);
472 DoTokenizerGetPosition(_T("foo_bar_"), _T("_"), 4, 8, 0);
475 void StringTestCase::Replace()
477 #define TEST_REPLACE( original , pos , len , replacement , result ) \
479 wxString s = original; \
480 s.replace( pos , len , replacement ); \
481 CPPUNIT_ASSERT( s == result ); \
484 TEST_REPLACE( _T("012-AWORD-XYZ"), 4, 5, _T("BWORD"), _T("012-BWORD-XYZ") );
485 TEST_REPLACE( _T("increase"), 0, 2, _T("de"), _T("decrease") );
486 TEST_REPLACE( _T("wxWindow"), 8, 0, _T("s"), _T("wxWindows") );
487 TEST_REPLACE( _T("foobar"), 3, 0, _T("-"), _T("foo-bar") );
488 TEST_REPLACE( _T("barfoo"), 0, 6, _T("foobar"), _T("foobar") );
491 #define TEST_NULLCHARREPLACE( o , olen, pos , len , replacement , r, rlen ) \
493 wxString s(o,olen); \
494 s.replace( pos , len , replacement ); \
495 CPPUNIT_ASSERT( s == wxString(r,rlen) ); \
498 TEST_NULLCHARREPLACE( _T("null\0char"), 9, 5, 1, _T("d"),
499 _T("null\0dhar"), 9 );
501 #define TEST_WXREPLACE( o , olen, olds, news, all, r, rlen ) \
503 wxString s(o,olen); \
504 s.Replace( olds, news, all ); \
505 CPPUNIT_ASSERT( s == wxString(r,rlen) ); \
508 TEST_WXREPLACE( _T("null\0char"), 9, _T("c"), _T("de"), true,
509 _T("null\0dehar"), 10 );
511 TEST_WXREPLACE( _T("null\0dehar"), 10, _T("de"), _T("c"), true,
512 _T("null\0char"), 9 );
514 #undef TEST_WXREPLACE
515 #undef TEST_NULLCHARREPLACE
519 void StringTestCase::Match()
521 #define TEST_MATCH( s1 , s2 , result ) \
522 CPPUNIT_ASSERT( wxString(s1).Matches(s2) == result )
524 TEST_MATCH( _T("foobar"), _T("foo*"), true );
525 TEST_MATCH( _T("foobar"), _T("*oo*"), true );
526 TEST_MATCH( _T("foobar"), _T("*bar"), true );
527 TEST_MATCH( _T("foobar"), _T("??????"), true );
528 TEST_MATCH( _T("foobar"), _T("f??b*"), true );
529 TEST_MATCH( _T("foobar"), _T("f?b*"), false );
530 TEST_MATCH( _T("foobar"), _T("*goo*"), false );
531 TEST_MATCH( _T("foobar"), _T("*foo"), false );
532 TEST_MATCH( _T("foobarfoo"), _T("*foo"), true );
533 TEST_MATCH( _T(""), _T("*"), true );
534 TEST_MATCH( _T(""), _T("?"), false );
540 void StringTestCase::CaseChanges()
542 wxString
s1(_T("Hello!"));
551 CPPUNIT_ASSERT( s1u
== _T("HELLO!") );
552 CPPUNIT_ASSERT( s1l
== _T("hello!") );
553 CPPUNIT_ASSERT( s2u
== wxEmptyString
);
554 CPPUNIT_ASSERT( s2l
== wxEmptyString
);
557 wxLocale
locRu(wxLANGUAGE_RUSSIAN
, 0 /* flags */);
560 // try upper casing 8bit strings
561 wxString
sUpper("\xdf"),
564 CPPUNIT_ASSERT( sUpper
.Lower() == sLower
);
565 CPPUNIT_ASSERT( sLower
.Upper() == sUpper
);
567 #endif // !wxUSE_UNICODE
570 void StringTestCase::Compare()
572 wxString s1
= wxT("AHH");
573 wxString eq
= wxT("AHH");
574 wxString neq1
= wxT("HAH");
575 wxString neq2
= wxT("AH");
576 wxString neq3
= wxT("AHHH");
577 wxString neq4
= wxT("AhH");
579 CPPUNIT_ASSERT( s1
== eq
);
580 CPPUNIT_ASSERT( s1
!= neq1
);
581 CPPUNIT_ASSERT( s1
!= neq2
);
582 CPPUNIT_ASSERT( s1
!= neq3
);
583 CPPUNIT_ASSERT( s1
!= neq4
);
585 // wxString _s1 = wxT("A\0HH");
586 // wxString _eq = wxT("A\0HH");
587 // wxString _neq1 = wxT("H\0AH");
588 // wxString _neq2 = wxT("A\0H");
589 // wxString _neq3 = wxT("A\0HHH");
590 // wxString _neq4 = wxT("A\0hH");
593 neq1
.insert(1,1,'\0');
594 neq2
.insert(1,1,'\0');
595 neq3
.insert(1,1,'\0');
596 neq4
.insert(1,1,'\0');
598 CPPUNIT_ASSERT( s1
== eq
);
599 CPPUNIT_ASSERT( s1
!= neq1
);
600 CPPUNIT_ASSERT( s1
!= neq2
);
601 CPPUNIT_ASSERT( s1
!= neq3
);
602 CPPUNIT_ASSERT( s1
!= neq4
);
605 void StringTestCase::CompareNoCase()
607 wxString s1
= wxT("AHH");
608 wxString eq
= wxT("AHH");
609 wxString eq2
= wxT("AhH");
610 wxString eq3
= wxT("ahh");
611 wxString neq
= wxT("HAH");
612 wxString neq2
= wxT("AH");
613 wxString neq3
= wxT("AHHH");
615 #define CPPUNIT_CNCEQ_ASSERT(s1, s2) CPPUNIT_ASSERT( s1.CmpNoCase(s2) == 0)
616 #define CPPUNIT_CNCNEQ_ASSERT(s1, s2) CPPUNIT_ASSERT( s1.CmpNoCase(s2) != 0)
618 CPPUNIT_CNCEQ_ASSERT( s1
, eq
);
619 CPPUNIT_CNCEQ_ASSERT( s1
, eq2
);
620 CPPUNIT_CNCEQ_ASSERT( s1
, eq3
);
622 CPPUNIT_CNCNEQ_ASSERT( s1
, neq
);
623 CPPUNIT_CNCNEQ_ASSERT( s1
, neq2
);
624 CPPUNIT_CNCNEQ_ASSERT( s1
, neq3
);
627 // wxString _s1 = wxT("A\0HH");
628 // wxString _eq = wxT("A\0HH");
629 // wxString _eq2 = wxT("A\0hH");
630 // wxString _eq3 = wxT("a\0hh");
631 // wxString _neq = wxT("H\0AH");
632 // wxString _neq2 = wxT("A\0H");
633 // wxString _neq3 = wxT("A\0HHH");
637 eq2
.insert(1,1,'\0');
638 eq3
.insert(1,1,'\0');
639 neq
.insert(1,1,'\0');
640 neq2
.insert(1,1,'\0');
641 neq3
.insert(1,1,'\0');
643 CPPUNIT_CNCEQ_ASSERT( s1
, eq
);
644 CPPUNIT_CNCEQ_ASSERT( s1
, eq2
);
645 CPPUNIT_CNCEQ_ASSERT( s1
, eq3
);
647 CPPUNIT_CNCNEQ_ASSERT( s1
, neq
);
648 CPPUNIT_CNCNEQ_ASSERT( s1
, neq2
);
649 CPPUNIT_CNCNEQ_ASSERT( s1
, neq3
);
652 void StringTestCase::ToLong()
655 static const struct ToLongData
662 { _T("1"), 1, true },
663 { _T("0"), 0, true },
664 { _T("a"), 0, false },
665 { _T("12345"), 12345, true },
666 { _T("-1"), -1, true },
667 { _T("--1"), 0, false },
671 for ( n
= 0; n
< WXSIZEOF(longData
); n
++ )
673 const ToLongData
& ld
= longData
[n
];
674 CPPUNIT_ASSERT_EQUAL( ld
.ok
, wxString(ld
.str
).ToLong(&l
) );
676 CPPUNIT_ASSERT_EQUAL( ld
.value
, l
);
680 void StringTestCase::ToULong()
683 static const struct ToULongData
690 { _T("1"), 1, true },
691 { _T("0"), 0, true },
692 { _T("a"), 0, false },
693 { _T("12345"), 12345, true },
694 // this is surprizing but consistent with strtoul() behaviour
695 { _T("-1"), ULONG_MAX
, true },
699 for ( n
= 0; n
< WXSIZEOF(ulongData
); n
++ )
701 const ToULongData
& uld
= ulongData
[n
];
702 CPPUNIT_ASSERT_EQUAL( uld
.ok
, wxString(uld
.str
).ToULong(&ul
) );
704 CPPUNIT_ASSERT_EQUAL( uld
.value
, ul
);
708 void StringTestCase::ToDouble()
711 static const struct ToDoubleData
718 { _T("1"), 1, true },
719 { _T("1.23"), 1.23, true },
720 { _T(".1"), .1, true },
721 { _T("1."), 1, true },
722 { _T("1.."), 0, false },
723 { _T("0"), 0, true },
724 { _T("a"), 0, false },
725 { _T("12345"), 12345, true },
726 { _T("-1"), -1, true },
727 { _T("--1"), 0, false },
730 // we need to use decimal point, not comma or whatever is its value for the
732 wxSetlocale(LC_ALL
, _T("C"));
735 for ( n
= 0; n
< WXSIZEOF(doubleData
); n
++ )
737 const ToDoubleData
& ld
= doubleData
[n
];
738 CPPUNIT_ASSERT_EQUAL( ld
.ok
, wxString(ld
.str
).ToDouble(&d
) );
740 CPPUNIT_ASSERT_EQUAL( ld
.value
, d
);