revert previous revision about localization of decimal points in GetHumanReadableSize() test strings: using CLocaleSetter is a better solution.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64515 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -83,18 +83,6 @@ private:
|
|||||||
|
|
||||||
#endif // CHANGE_SYSTEM_DATE
|
#endif // CHANGE_SYSTEM_DATE
|
||||||
|
|
||||||
// helper class setting the locale to "C" for its lifetime
|
|
||||||
class CLocaleSetter
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CLocaleSetter() : m_locOld(setlocale(LC_ALL, "C")) { }
|
|
||||||
~CLocaleSetter() { setlocale(LC_ALL, m_locOld); }
|
|
||||||
|
|
||||||
private:
|
|
||||||
const char * const m_locOld;
|
|
||||||
wxDECLARE_NO_COPY_CLASS(CLocaleSetter);
|
|
||||||
};
|
|
||||||
|
|
||||||
// helper function translating week day/month names from English to the current
|
// helper function translating week day/month names from English to the current
|
||||||
// locale
|
// locale
|
||||||
static wxString TranslateDate(const wxString& str)
|
static wxString TranslateDate(const wxString& str)
|
||||||
|
@@ -503,26 +503,25 @@ void FileNameTestCase::TestGetHumanReadable()
|
|||||||
{ "304 KB", 304351, 0, wxSIZE_CONV_SI },
|
{ "304 KB", 304351, 0, wxSIZE_CONV_SI },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
CLocaleSetter loc; // we want to use "C" locale for LC_NUMERIC
|
||||||
|
// so that regardless of the system's locale
|
||||||
|
// the decimal point used by GetHumanReadableSize()
|
||||||
|
// is always '.'
|
||||||
for ( unsigned n = 0; n < WXSIZEOF(testData); n++ )
|
for ( unsigned n = 0; n < WXSIZEOF(testData); n++ )
|
||||||
{
|
{
|
||||||
const TestData& td = testData[n];
|
const TestData& td = testData[n];
|
||||||
|
|
||||||
// take care of using the decimal point for the current locale before
|
// take care of using the decimal point for the current locale before
|
||||||
// the actual comparison
|
// the actual comparison
|
||||||
wxString result_localized = wxString(td.result);
|
|
||||||
result_localized.Replace(".", wxLocale::GetInfo(wxLOCALE_DECIMAL_POINT, wxLOCALE_CAT_NUMBER));
|
|
||||||
|
|
||||||
CPPUNIT_ASSERT_EQUAL
|
CPPUNIT_ASSERT_EQUAL
|
||||||
(
|
(
|
||||||
result_localized,
|
td.result,
|
||||||
wxFileName::GetHumanReadableSize(td.size, "NA", td.prec, td.conv)
|
wxFileName::GetHumanReadableSize(td.size, "NA", td.prec, td.conv)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// also test the default convention value
|
// also test the default convention value
|
||||||
wxString result_localized = wxString("1.4 MB");
|
CPPUNIT_ASSERT_EQUAL( "1.4 MB", wxFileName::GetHumanReadableSize(1512993, "") );
|
||||||
result_localized.Replace(".", wxLocale::GetInfo(wxLOCALE_DECIMAL_POINT, wxLOCALE_CAT_NUMBER));
|
|
||||||
CPPUNIT_ASSERT_EQUAL( result_localized, wxFileName::GetHumanReadableSize(1512993, "") );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileNameTestCase::TestStrip()
|
void FileNameTestCase::TestStrip()
|
||||||
@@ -594,8 +593,9 @@ void FileNameTestCase::TestCreateTempFileName()
|
|||||||
{ "foo", "$SYSTEM_TEMP", false },
|
{ "foo", "$SYSTEM_TEMP", false },
|
||||||
{ "..", "$SYSTEM_TEMP", false },
|
{ "..", "$SYSTEM_TEMP", false },
|
||||||
{ "../bar", "..", false },
|
{ "../bar", "..", false },
|
||||||
|
#ifdef __WXMSW__
|
||||||
{ "c:\\a\\place\\which\\does\\not\\exist", "", true },
|
{ "c:\\a\\place\\which\\does\\not\\exist", "", true },
|
||||||
#ifdef __UNIX__
|
#else if defined( __UNIX__ )
|
||||||
{ "/tmp/foo", "/tmp", false },
|
{ "/tmp/foo", "/tmp", false },
|
||||||
{ "/tmp/foo/bar", "", true },
|
{ "/tmp/foo/bar", "", true },
|
||||||
#endif // __UNIX__
|
#endif // __UNIX__
|
||||||
|
@@ -67,3 +67,15 @@ extern void SetFilterEventFunc(FilterEventFunc func);
|
|||||||
extern void SetProcessEventFunc(ProcessEventFunc func);
|
extern void SetProcessEventFunc(ProcessEventFunc func);
|
||||||
|
|
||||||
extern bool IsNetworkAvailable();
|
extern bool IsNetworkAvailable();
|
||||||
|
|
||||||
|
// helper class setting the locale to "C" for its lifetime
|
||||||
|
class CLocaleSetter
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CLocaleSetter() : m_locOld(setlocale(LC_ALL, "C")) { }
|
||||||
|
~CLocaleSetter() { setlocale(LC_ALL, m_locOld); }
|
||||||
|
|
||||||
|
private:
|
||||||
|
const char * const m_locOld;
|
||||||
|
wxDECLARE_NO_COPY_CLASS(CLocaleSetter);
|
||||||
|
};
|
||||||
|
Reference in New Issue
Block a user