summaryrefslogtreecommitdiffstats
path: root/src/testlib/qxmltestlogger.cpp
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2019-01-24 12:18:15 +0100
committerAapo Keskimolo <aapo.keskimolo@qt.io>2019-01-24 20:31:41 +0000
commit7511697efe31f57d66f77729413f05d6dafc0059 (patch)
tree110021d16e19df635b332edf09f48b15763b1ee5 /src/testlib/qxmltestlogger.cpp
parentc907becbf166593c1b6b21e92eef032fefe48aba (diff)
testlib: Format durations using C locale
XML expects '.' as the decimal separator, but when using normal %f formatting we end up depending on the user's current locale. By using QString::number() we tap into qt_doubleToAscii which forces the use of the C locale, giving predictable output. Fixes: QTBUG-73227 Change-Id: I04d1adae2ef079442605e962007e5ce3fce896b7 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
Diffstat (limited to 'src/testlib/qxmltestlogger.cpp')
-rw-r--r--src/testlib/qxmltestlogger.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/testlib/qxmltestlogger.cpp b/src/testlib/qxmltestlogger.cpp
index 72cb53bca7..7153c016c5 100644
--- a/src/testlib/qxmltestlogger.cpp
+++ b/src/testlib/qxmltestlogger.cpp
@@ -136,8 +136,9 @@ void QXmlTestLogger::startLogging()
void QXmlTestLogger::stopLogging()
{
QTestCharBuffer buf;
- QTest::qt_asprintf(&buf,
- "<Duration msecs=\"%f\"/>\n", QTestLog::msecsTotalTime());
+
+ QTest::qt_asprintf(&buf, "<Duration msecs=\"%s\"/>\n",
+ QString::number(QTestLog::msecsTotalTime()).toUtf8().constData());
outputString(buf.constData());
if (xmlmode == QXmlTestLogger::Complete) {
outputString("</TestCase>\n");
@@ -159,9 +160,9 @@ void QXmlTestLogger::leaveTestFunction()
{
QTestCharBuffer buf;
QTest::qt_asprintf(&buf,
- " <Duration msecs=\"%f\"/>\n"
+ " <Duration msecs=\"%s\"/>\n"
"</TestFunction>\n",
- QTestLog::msecsFunctionTime());
+ QString::number(QTestLog::msecsFunctionTime()).toUtf8().constData());
outputString(buf.constData());
}