summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorShenghua Su <shenghua.su@tieto.com>2010-02-17 11:03:05 (GMT)
committerThiago Macieira <thiago.macieira@nokia.com>2010-02-17 11:46:54 (GMT)
commit00f1ec35393cf8cc5b96fc11dd1e35078d02ba0a (patch)
tree6cede272a5c8a9025f130f8690885a9a3b80ff7e /tests
parent38a38b0c971ee910cbe1d6359eba57dd2a1a279f (diff)
downloadQt-00f1ec35393cf8cc5b96fc11dd1e35078d02ba0a.zip
Qt-00f1ec35393cf8cc5b96fc11dd1e35078d02ba0a.tar.gz
Qt-00f1ec35393cf8cc5b96fc11dd1e35078d02ba0a.tar.bz2
add test case for QTBUG-7898 that QLocale::toDateTime(QString, FormatType) cannot convert value correctly
Merge-request: 455 Reviewed-by: Thiago Macieira <thiago.macieira@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qlocale/tst_qlocale.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/auto/qlocale/tst_qlocale.cpp b/tests/auto/qlocale/tst_qlocale.cpp
index 3dc4dad..ff77db1 100644
--- a/tests/auto/qlocale/tst_qlocale.cpp
+++ b/tests/auto/qlocale/tst_qlocale.cpp
@@ -141,6 +141,8 @@ private slots:
void ampm();
+ void QTBUG_7898();
+
private:
QString m_decimal, m_thousand, m_sdate, m_ldate, m_time;
};
@@ -2019,5 +2021,23 @@ void tst_QLocale::symbianSystemLocale()
}
#endif
+void tst_QLocale::QTBUG_7898()
+{
+ QLocale locale = QLocale(QLocale::English);
+ //QString dateTimeStr = QString("Monday, January 5, 2009 11:48:32 AM"); // with no blank space char after "AM", call "toDateTime" will get invalid value
+ QString dateTimeStr = QString("Monday, January 5, 2009 11:48:32 AM ");
+
+ QDateTime value1 = locale.toDateTime(dateTimeStr , locale.dateTimeFormat(QLocale::LongFormat));qDebug()<<locale.toString(value1);
+ QDateTime value2 = locale.toDateTime(dateTimeStr , QLocale::LongFormat);
+ QCOMPARE(value1.isValid(), value2.isValid());
+ if (value1.isValid()) {
+ QCOMPARE(value1, value2);
+ QCOMPARE(locale.toString(value1), dateTimeStr);
+ QCOMPARE(locale.toString(value2), dateTimeStr);
+ QCOMPARE(locale.toString(value1, locale.dateTimeFormat(QLocale::LongFormat)), dateTimeStr);
+ QCOMPARE(locale.toString(value2, locale.dateTimeFormat(QLocale::LongFormat)), dateTimeStr);
+ }
+}
+
QTEST_APPLESS_MAIN(tst_QLocale)
#include "tst_qlocale.moc"