diff options
author | Jens Georg <jensg@openismus.com> | 2011-04-13 08:14:46 (GMT) |
---|---|---|
committer | Zeno Albisser <zeno.albisser@nokia.com> | 2011-04-27 13:26:02 (GMT) |
commit | d9e0c2ea4d64b8fdfb31b28e71373735be38101b (patch) | |
tree | 21367d747e04cf323e60bfcef7ce3a2a938813cc /tests/auto | |
parent | 3d4149afe62b4fc5d519a2a155b8f8c32e7e95c4 (diff) | |
download | Qt-d9e0c2ea4d64b8fdfb31b28e71373735be38101b.zip Qt-d9e0c2ea4d64b8fdfb31b28e71373735be38101b.tar.gz Qt-d9e0c2ea4d64b8fdfb31b28e71373735be38101b.tar.bz2 |
Add test for ISODate change in QDateTime::toString
Merge-request: 1149
Reviewed-by: Zeno Albisser <zeno.albisser@nokia.com>
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/qdatetime/tst_qdatetime.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/auto/qdatetime/tst_qdatetime.cpp b/tests/auto/qdatetime/tst_qdatetime.cpp index f8836a6..d612911 100644 --- a/tests/auto/qdatetime/tst_qdatetime.cpp +++ b/tests/auto/qdatetime/tst_qdatetime.cpp @@ -85,6 +85,8 @@ private slots: void setTime_t(); void setMSecsSinceEpoch_data(); void setMSecsSinceEpoch(); + void toString_isoDate_data(); + void toString_isoDate(); void toString_enumformat(); void toString_strformat_data(); void toString_strformat(); @@ -506,6 +508,36 @@ void tst_QDateTime::setMSecsSinceEpoch() QCOMPARE(dt, reference.addMSecs(msecs)); } +void tst_QDateTime::toString_isoDate_data() +{ + QTest::addColumn<QDateTime>("dt"); + QTest::addColumn<QString>("formatted"); + + QTest::newRow("localtime") + << QDateTime(QDate(1978, 11, 9), QTime(13, 28, 34)) + << QString("1978-11-09T13:28:34"); + QTest::newRow("UTC") + << QDateTime(QDate(1978, 11, 9), QTime(13, 28, 34), Qt::UTC) + << QString("1978-11-09T13:28:34Z"); + QDateTime dt(QDate(1978, 11, 9), QTime(13, 28, 34)); + dt.setUtcOffset(19800); + QTest::newRow("positive OffsetFromUTC") + << dt + << QString("1978-11-09T13:28:34+05:30"); + dt.setUtcOffset(-7200); + QTest::newRow("negative OffsetFromUTC") + << dt + << QString("1978-11-09T13:28:34-02:00"); +} + +void tst_QDateTime::toString_isoDate() +{ + QFETCH(QDateTime, dt); + QFETCH(QString, formatted); + + QCOMPARE(dt.toString(Qt::ISODate), formatted); +} + void tst_QDateTime::toString_enumformat() { QDateTime dt1(QDate(1995, 5, 20), QTime(12, 34, 56)); |