Autotest: Selftests fail in UTC timezone
Selftests for testlib fail when executed in UTC timezone because local and UTC are the same, but expected to be different. A custom timezone is used instead. Debug output of qCompare does only handle local and non-local timezones, using new Qt5 features allows to show the correct timezone in format string. Change-Id: I753884a12370952b7b62a90d62896db4f2d3d1b4 Reviewed-by: Jason McDonald <macadder1@gmail.com>
This commit is contained in:
parent
ec9bc843d8
commit
20480070a6
@ -91,8 +91,7 @@ template<> inline char *toString(const QDate &date)
|
|||||||
template<> inline char *toString(const QDateTime &dateTime)
|
template<> inline char *toString(const QDateTime &dateTime)
|
||||||
{
|
{
|
||||||
return dateTime.isValid()
|
return dateTime.isValid()
|
||||||
? qstrdup(qPrintable(dateTime.toString(QLatin1String("yyyy/MM/dd hh:mm:ss.zzz")) +
|
? qstrdup(qPrintable(dateTime.toString(QLatin1String("yyyy/MM/dd hh:mm:ss.zzz[t]"))))
|
||||||
(dateTime.timeSpec() == Qt::LocalTime ? QLatin1String("[local time]") : QLatin1String("[UTC]"))))
|
|
||||||
: qstrdup("Invalid QDateTime");
|
: qstrdup("Invalid QDateTime");
|
||||||
}
|
}
|
||||||
#endif // QT_NO_DATESTRING
|
#endif // QT_NO_DATESTRING
|
||||||
|
@ -52,7 +52,7 @@ private slots:
|
|||||||
void tst_DateTime::dateTime() const
|
void tst_DateTime::dateTime() const
|
||||||
{
|
{
|
||||||
const QDateTime utc(QDate(2000, 5, 3), QTime(4, 3, 4), Qt::UTC);
|
const QDateTime utc(QDate(2000, 5, 3), QTime(4, 3, 4), Qt::UTC);
|
||||||
const QDateTime local(QDate(2000, 5, 3), QTime(4, 3, 4), Qt::LocalTime);
|
const QDateTime local(QDate(2000, 5, 3), QTime(4, 3, 4), Qt::OffsetFromUTC, 120 /* 2 minutes */);
|
||||||
|
|
||||||
QCOMPARE(local, utc);
|
QCOMPARE(local, utc);
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
<TestFunction name="dateTime">
|
<TestFunction name="dateTime">
|
||||||
<Incident type="fail" file="tst_datetime.cpp" line="65">
|
<Incident type="fail" file="tst_datetime.cpp" line="65">
|
||||||
<Description><![CDATA[Compared values are not the same
|
<Description><![CDATA[Compared values are not the same
|
||||||
Actual (local): 2000/05/03 04:03:04.000[local time]
|
Actual (local): 2000/05/03 04:03:04.000[UTC+00:02]
|
||||||
Expected (utc) : 2000/05/03 04:03:04.000[UTC]]]></Description>
|
Expected (utc) : 2000/05/03 04:03:04.000[UTC]]]></Description>
|
||||||
</Incident>
|
</Incident>
|
||||||
<Duration msecs="0"/>
|
<Duration msecs="0"/>
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
Config: Using QtTest library @INSERT_QT_VERSION_HERE@, Qt @INSERT_QT_VERSION_HERE@
|
Config: Using QtTest library @INSERT_QT_VERSION_HERE@, Qt @INSERT_QT_VERSION_HERE@
|
||||||
PASS : tst_DateTime::initTestCase()
|
PASS : tst_DateTime::initTestCase()
|
||||||
FAIL! : tst_DateTime::dateTime() Compared values are not the same
|
FAIL! : tst_DateTime::dateTime() Compared values are not the same
|
||||||
Actual (local): 2000/05/03 04:03:04.000[local time]
|
Actual (local): 2000/05/03 04:03:04.000[UTC+00:02]
|
||||||
Expected (utc) : 2000/05/03 04:03:04.000[UTC]
|
Expected (utc) : 2000/05/03 04:03:04.000[UTC]
|
||||||
Loc: [tst_datetime.cpp(65)]
|
Loc: [tst_datetime.cpp(65)]
|
||||||
PASS : tst_DateTime::qurl(empty urls)
|
PASS : tst_DateTime::qurl(empty urls)
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
<TestFunction name="dateTime">
|
<TestFunction name="dateTime">
|
||||||
<Incident type="fail" file="tst_datetime.cpp" line="65">
|
<Incident type="fail" file="tst_datetime.cpp" line="65">
|
||||||
<Description><![CDATA[Compared values are not the same
|
<Description><![CDATA[Compared values are not the same
|
||||||
Actual (local): 2000/05/03 04:03:04.000[local time]
|
Actual (local): 2000/05/03 04:03:04.000[UTC+00:02]
|
||||||
Expected (utc) : 2000/05/03 04:03:04.000[UTC]]]></Description>
|
Expected (utc) : 2000/05/03 04:03:04.000[UTC]]]></Description>
|
||||||
</Incident>
|
</Incident>
|
||||||
<Duration msecs="0"/>
|
<Duration msecs="0"/>
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
<testcase result="pass" name="initTestCase"/>
|
<testcase result="pass" name="initTestCase"/>
|
||||||
<testcase result="fail" name="dateTime">
|
<testcase result="fail" name="dateTime">
|
||||||
<failure message="Compared values are not the same
|
<failure message="Compared values are not the same
|
||||||
Actual (local): 2000/05/03 04:03:04.000[local time]
|
Actual (local): 2000/05/03 04:03:04.000[UTC+00:02]
|
||||||
Expected (utc) : 2000/05/03 04:03:04.000[UTC]" result="fail"/>
|
Expected (utc) : 2000/05/03 04:03:04.000[UTC]" result="fail"/>
|
||||||
</testcase>
|
</testcase>
|
||||||
<testcase result="fail" name="qurl">
|
<testcase result="fail" name="qurl">
|
||||||
|
Loading…
Reference in New Issue
Block a user