+static wxString
+NormalizeFormat(const wxString& fmtOrig)
+{
+ wxString fmt(fmtOrig);
+
+#ifdef __GLIBC__
+ // glibc uses some extensions in its formats which we need to convert to
+ // standard form
+ fmt.Replace("%T", "%H:%M:%S");
+ fmt.Replace("%e", "%d");
+#endif // __GLIBC__
+
+ return fmt;
+}
+
+#define WX_ASSERT_EQUAL_FORMAT(msg, expected, actual) \
+ if ( !actual.empty() ) \
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, expected, NormalizeFormat(actual))
+
+void IntlTestCase::DateTimeFmtFrench()
+{
+ if ( !m_locale )
+ return;
+
+#ifdef __GLIBC__
+ // glibc also uses dots for French locale separator for some reason (the
+ // standard format uses slashes)
+ static const char *FRENCH_DATE_FMT = "%d.%m.%Y";
+ static const char *FRENCH_LONG_DATE_FMT = "%a %d %b %Y";
+ static const char *FRENCH_DATE_TIME_FMT = "%a %d %b %Y %H:%M:%S %Z";
+#else
+ static const char *FRENCH_DATE_FMT = "%d/%m/%Y";
+ static const char *FRENCH_LONG_DATE_FMT = "%A %d %B %Y";
+#ifdef __WXOSX__
+ static const char *FRENCH_DATE_TIME_FMT = "%A %d %B %Y %H:%M:%S";
+#else
+ static const char *FRENCH_DATE_TIME_FMT = "%d/%m/%Y %H:%M:%S";
+#endif
+#endif
+
+ WX_ASSERT_EQUAL_FORMAT( "French short date", FRENCH_DATE_FMT,
+ m_locale->GetInfo(wxLOCALE_SHORT_DATE_FMT) );
+ WX_ASSERT_EQUAL_FORMAT( "French long date", FRENCH_LONG_DATE_FMT,
+ m_locale->GetInfo(wxLOCALE_LONG_DATE_FMT) );
+ WX_ASSERT_EQUAL_FORMAT( "French date and time", FRENCH_DATE_TIME_FMT,
+ m_locale->GetInfo(wxLOCALE_DATE_TIME_FMT) );
+ WX_ASSERT_EQUAL_FORMAT( "French time", "%H:%M:%S",
+ m_locale->GetInfo(wxLOCALE_TIME_FMT) );
+}
+
+void IntlTestCase::DateTimeFmtC()
+{
+ // again, glibc uses different defaults
+#ifdef __GLIBC__
+ static const char *C_DATE_FMT = "%m/%d/%y";
+ static const char *C_LONG_DATE_FMT = "%a %b %d %Y";
+ static const char *C_DATE_TIME_FMT = "%a %b %d %H:%M:%S %Y";
+#else
+ static const char *C_DATE_FMT = "%d/%m/%Y";
+ static const char *C_LONG_DATE_FMT = "%A %d %B %Y";
+#ifdef __WXOSX__
+ static const char *C_DATE_TIME_FMT = "%A %d %B %Y %H:%M:%S";
+#else
+ static const char *C_DATE_TIME_FMT = "%d/%m/%Y %H:%M:%S";
+#endif
+#endif
+
+ setlocale(LC_ALL, "C");
+
+ WX_ASSERT_EQUAL_FORMAT( "C short date", C_DATE_FMT,
+ m_locale->GetInfo(wxLOCALE_SHORT_DATE_FMT) );
+ WX_ASSERT_EQUAL_FORMAT( "C long date", C_LONG_DATE_FMT,
+ m_locale->GetInfo(wxLOCALE_LONG_DATE_FMT) );
+ WX_ASSERT_EQUAL_FORMAT( "C date and time", C_DATE_TIME_FMT,
+ m_locale->GetInfo(wxLOCALE_DATE_TIME_FMT) );
+ WX_ASSERT_EQUAL_FORMAT( "C time", "%H:%M:%S",
+ m_locale->GetInfo(wxLOCALE_TIME_FMT) );
+}
+
+void IntlTestCase::IsAvailable()
+{
+ const wxString origLocale(setlocale(LC_ALL, NULL));
+
+ // Calling IsAvailable() shouldn't change the locale.
+ wxLocale::IsAvailable(wxLANGUAGE_ENGLISH);
+
+ CPPUNIT_ASSERT_EQUAL( origLocale, setlocale(LC_ALL, NULL) );
+}
+