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>bb10
parent
c907becbf1
commit
7511697efe
|
|
@ -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());
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue