summaryrefslogtreecommitdiffstats
path: root/tests/auto/qdatetime
diff options
context:
space:
mode:
authorJason Hollingsworth <jhworth.developer@gmail.com>2010-05-11 14:26:42 (GMT)
committerBenjamin Poulain <benjamin.poulain@nokia.com>2010-05-11 14:29:51 (GMT)
commita1cda97c4002195f98c18c460d1f30682bb5a82e (patch)
treecb0424081bbd6c34d6b7a010a2d3e992c1c7e9e0 /tests/auto/qdatetime
parent949f49c9ea4dadfc6e7f3bf7d822830b7ef8a8e6 (diff)
downloadQt-a1cda97c4002195f98c18c460d1f30682bb5a82e.zip
Qt-a1cda97c4002195f98c18c460d1f30682bb5a82e.tar.gz
Qt-a1cda97c4002195f98c18c460d1f30682bb5a82e.tar.bz2
Added QDateTime::msecsTo()
This adds a QDateTime::msecsTo() function which is similar to QDateTime::secsTo(). This refers to QTBUG-8790 and task 147685. According to the task this functionality should have been added in version 4.5.0 but it never was. Task-number: 147685 Task-number: QTBUG-8790 Merge-request: 501 Reviewed-by: Benjamin Poulain <benjamin.poulain@nokia.com> Reviewed-by: Andreas Kling <andreas.kling@nokia.com>
Diffstat (limited to 'tests/auto/qdatetime')
-rw-r--r--tests/auto/qdatetime/tst_qdatetime.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/auto/qdatetime/tst_qdatetime.cpp b/tests/auto/qdatetime/tst_qdatetime.cpp
index 6aca996..47c54a5 100644
--- a/tests/auto/qdatetime/tst_qdatetime.cpp
+++ b/tests/auto/qdatetime/tst_qdatetime.cpp
@@ -106,6 +106,8 @@ private slots:
void daysTo();
void secsTo_data();
void secsTo();
+ void msecsTo_data();
+ void msecsTo();
void operator_eqeq();
void currentDateTime();
void currentDateTimeUtc();
@@ -910,6 +912,30 @@ void tst_QDateTime::secsTo()
QVERIFY((dt >= result) == (0 >= nsecs));
}
+void tst_QDateTime::msecsTo_data()
+{
+ addMSecs_data();
+}
+
+void tst_QDateTime::msecsTo()
+{
+ QFETCH(QDateTime, dt);
+ QFETCH(int, nsecs);
+ QFETCH(QDateTime, result);
+
+#ifdef Q_OS_IRIX
+ QEXPECT_FAIL("cet4", "IRIX databases say 1970 had DST", Abort);
+#endif
+ QCOMPARE(dt.msecsTo(result), qint64(nsecs) * 1000);
+ QCOMPARE(result.msecsTo(dt), -qint64(nsecs) * 1000);
+ QVERIFY((dt == result) == (0 == (qint64(nsecs) * 1000)));
+ QVERIFY((dt != result) == (0 != (qint64(nsecs) * 1000)));
+ QVERIFY((dt < result) == (0 < (qint64(nsecs) * 1000)));
+ QVERIFY((dt <= result) == (0 <= (qint64(nsecs) * 1000)));
+ QVERIFY((dt > result) == (0 > (qint64(nsecs) * 1000)));
+ QVERIFY((dt >= result) == (0 >= (qint64(nsecs) * 1000)));
+}
+
void tst_QDateTime::currentDateTime()
{
#if defined(Q_OS_WINCE)