+}
+
+void StringTestCase::FromDouble()
+{
+ static const struct FromDoubleTestData
+ {
+ double value;
+ int prec;
+ const char *str;
+ } testData[] =
+ {
+ { 1.23, -1, "1.23" },
+ // NB: there are no standards about the minimum exponent width
+ // and newer MSVC versions use 3 digits as minimum exponent
+ // width while GNU libc uses 2 digits as minimum width...
+#ifdef wxUSING_VC_CRT_IO
+ { -3e-10, -1, "-3e-010" },
+#else
+ { -3e-10, -1, "-3e-10" },
+#endif
+ { -0.45678, -1, "-0.45678" },
+ { 1.2345678, 0, "1" },
+ { 1.2345678, 1, "1.2" },
+ { 1.2345678, 2, "1.23" },
+ { 1.2345678, 3, "1.235" },
+ };
+
+ for ( unsigned n = 0; n < WXSIZEOF(testData); n++ )
+ {
+ const FromDoubleTestData& td = testData[n];
+ CPPUNIT_ASSERT_EQUAL( td.str, wxString::FromCDouble(td.value, td.prec) );
+ }
+
+ if ( !wxLocale::IsAvailable(wxLANGUAGE_FRENCH) )
+ return;
+
+ wxLocale locale;
+ CPPUNIT_ASSERT( locale.Init(wxLANGUAGE_FRENCH, wxLOCALE_DONT_LOAD_DEFAULT) );
+
+ for ( unsigned m = 0; m < WXSIZEOF(testData); m++ )
+ {
+ const FromDoubleTestData& td = testData[m];
+
+ wxString str(td.str);
+ str.Replace(".", ",");
+ CPPUNIT_ASSERT_EQUAL( str, wxString::FromDouble(td.value, td.prec) );
+ }