summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Keller <rainer.keller@theqtcompany.com>2015-01-15 09:45:07 +0100
committerRainer Keller <rainer.keller@theqtcompany.com>2015-01-19 10:21:26 +0100
commit20480070a60469017770257b6c574c5707cda58b (patch)
tree17486649663c004d7355e5b448d00c7042acac77
parentec9bc843d8a5c18459f3669c6e22acac2077df67 (diff)
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>
-rw-r--r--src/testlib/qtest.h3
-rw-r--r--tests/auto/testlib/selftests/datetime/tst_datetime.cpp2
-rw-r--r--tests/auto/testlib/selftests/expected_datetime.lightxml2
-rw-r--r--tests/auto/testlib/selftests/expected_datetime.txt2
-rw-r--r--tests/auto/testlib/selftests/expected_datetime.xml2
-rw-r--r--tests/auto/testlib/selftests/expected_datetime.xunitxml2
6 files changed, 6 insertions, 7 deletions
diff --git a/src/testlib/qtest.h b/src/testlib/qtest.h
index 6298262958..995d653118 100644
--- a/src/testlib/qtest.h
+++ b/src/testlib/qtest.h
@@ -91,8 +91,7 @@ template<> inline char *toString(const QDate &date)
template<> inline char *toString(const QDateTime &dateTime)
{
return dateTime.isValid()
- ? qstrdup(qPrintable(dateTime.toString(QLatin1String("yyyy/MM/dd hh:mm:ss.zzz")) +
- (dateTime.timeSpec() == Qt::LocalTime ? QLatin1String("[local time]") : QLatin1String("[UTC]"))))
+ ? qstrdup(qPrintable(dateTime.toString(QLatin1String("yyyy/MM/dd hh:mm:ss.zzz[t]"))))
: qstrdup("Invalid QDateTime");
}
#endif // QT_NO_DATESTRING
diff --git a/tests/auto/testlib/selftests/datetime/tst_datetime.cpp b/tests/auto/testlib/selftests/datetime/tst_datetime.cpp
index d684f46f16..95bc72298e 100644
--- a/tests/auto/testlib/selftests/datetime/tst_datetime.cpp
+++ b/tests/auto/testlib/selftests/datetime/tst_datetime.cpp
@@ -52,7 +52,7 @@ private slots:
void tst_DateTime::dateTime() const
{
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);
}
diff --git a/tests/auto/testlib/selftests/expected_datetime.lightxml b/tests/auto/testlib/selftests/expected_datetime.lightxml
index 48ad0933f7..1aeac37e42 100644
--- a/tests/auto/testlib/selftests/expected_datetime.lightxml
+++ b/tests/auto/testlib/selftests/expected_datetime.lightxml
@@ -10,7 +10,7 @@
<TestFunction name="dateTime">
<Incident type="fail" file="tst_datetime.cpp" line="65">
<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>
</Incident>
<Duration msecs="0"/>
diff --git a/tests/auto/testlib/selftests/expected_datetime.txt b/tests/auto/testlib/selftests/expected_datetime.txt
index 1139c70ab8..c29fa050a1 100644
--- a/tests/auto/testlib/selftests/expected_datetime.txt
+++ b/tests/auto/testlib/selftests/expected_datetime.txt
@@ -2,7 +2,7 @@
Config: Using QtTest library @INSERT_QT_VERSION_HERE@, Qt @INSERT_QT_VERSION_HERE@
PASS : tst_DateTime::initTestCase()
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]
Loc: [tst_datetime.cpp(65)]
PASS : tst_DateTime::qurl(empty urls)
diff --git a/tests/auto/testlib/selftests/expected_datetime.xml b/tests/auto/testlib/selftests/expected_datetime.xml
index 30afde60ec..4c5bb0525b 100644
--- a/tests/auto/testlib/selftests/expected_datetime.xml
+++ b/tests/auto/testlib/selftests/expected_datetime.xml
@@ -12,7 +12,7 @@
<TestFunction name="dateTime">
<Incident type="fail" file="tst_datetime.cpp" line="65">
<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>
</Incident>
<Duration msecs="0"/>
diff --git a/tests/auto/testlib/selftests/expected_datetime.xunitxml b/tests/auto/testlib/selftests/expected_datetime.xunitxml
index 901462b6bf..6fc95719f3 100644
--- a/tests/auto/testlib/selftests/expected_datetime.xunitxml
+++ b/tests/auto/testlib/selftests/expected_datetime.xunitxml
@@ -8,7 +8,7 @@
<testcase result="pass" name="initTestCase"/>
<testcase result="fail" name="dateTime">
<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"/>
</testcase>
<testcase result="fail" name="qurl">