#if wxUSE_DATETIME
#include "wx/datetime.h"
+#include "wx/wxcrt.h" // for wxStrstr()
// need this to be able to use CPPUNIT_ASSERT_EQUAL with wxDateTime objects
static std::ostream& operator<<(std::ostream& ostr, const wxDateTime& dt)
for ( size_t n = 0; n < WXSIZEOF(formatTestFormats); n++ )
{
const char *fmt = formatTestFormats[n].format;
+
+ // skip the check with %p for those locales which have empty AM/PM strings:
+ // for those locales it's impossible to pass the test with %p...
+ wxString am, pm;
+ wxDateTime::GetAmPmStrings(&am, &pm);
+ if (am.empty() && pm.empty() && wxStrstr(fmt, "%p") != NULL)
+ continue;
+
wxString s = dt.Format(fmt);
// what can we recover?
}
else // conversion succeeded
{
- // should have parsed the entire string
- CPPUNIT_ASSERT( !*result );
+ // ParseFormat() should have parsed the entire string or left
+ // some final useless strings (e.g. with Italian locale the
+ // 's' string for the first test date looks like
+ // "---> sab 29 mag 1976 18:30:00 CET"
+ // so we just need to ignore CET)
+ CPPUNIT_ASSERT( !*result || strcmp(result, "CET") == 0 );
switch ( kind )
{