summaryrefslogtreecommitdiffstats
path: root/src/testlib/qtestxmlstreamer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/testlib/qtestxmlstreamer.cpp')
-rw-r--r--src/testlib/qtestxmlstreamer.cpp61
1 files changed, 30 insertions, 31 deletions
diff --git a/src/testlib/qtestxmlstreamer.cpp b/src/testlib/qtestxmlstreamer.cpp
index 1b6e674..c72d648 100644
--- a/src/testlib/qtestxmlstreamer.cpp
+++ b/src/testlib/qtestxmlstreamer.cpp
@@ -60,7 +60,7 @@ QTestXmlStreamer::QTestXmlStreamer()
QTestXmlStreamer::~QTestXmlStreamer()
{}
-void QTestXmlStreamer::formatStart(const QTestElement *element, char **formatted) const
+void QTestXmlStreamer::formatStart(const QTestElement *element, QTestCharBuffer *formatted) const
{
if(!element || !formatted)
return;
@@ -68,20 +68,20 @@ void QTestXmlStreamer::formatStart(const QTestElement *element, char **formatted
switch(element->elementType()){
case QTest::LET_TestCase: {
QTestCharBuffer quotedTf;
- QXmlTestLogger::xmlQuote(quotedTf, element->attributeValue(QTest::AI_Name));
+ QXmlTestLogger::xmlQuote(&quotedTf, element->attributeValue(QTest::AI_Name));
QTest::qt_asprintf(formatted, "<TestFunction name=\"%s\">\n", quotedTf.constData());
break;
}
case QTest::LET_Failure: {
QTestCharBuffer cdataDesc;
- QXmlTestLogger::xmlCdata(cdataDesc, element->attributeValue(QTest::AI_Description));
+ QXmlTestLogger::xmlCdata(&cdataDesc, element->attributeValue(QTest::AI_Description));
QTestCharBuffer location;
QTestCharBuffer quotedFile;
- QXmlTestLogger::xmlQuote(quotedFile, element->attributeValue(QTest::AI_File));
+ QXmlTestLogger::xmlQuote(&quotedFile, element->attributeValue(QTest::AI_File));
- QTest::qt_asprintf(location, "%s=\"%s\" %s=\"%s\"",
+ QTest::qt_asprintf(&location, "%s=\"%s\" %s=\"%s\"",
element->attributeName(QTest::AI_File),
quotedFile.constData(),
element->attributeName(QTest::AI_Line),
@@ -89,7 +89,7 @@ void QTestXmlStreamer::formatStart(const QTestElement *element, char **formatted
if (element->attribute(QTest::AI_Tag)) {
QTestCharBuffer cdataTag;
- QXmlTestLogger::xmlCdata(cdataTag, element->attributeValue(QTest::AI_Tag));
+ QXmlTestLogger::xmlCdata(&cdataTag, element->attributeValue(QTest::AI_Tag));
QTest::qt_asprintf(formatted, "<Incident type=\"%s\" %s>\n"
" <DataTag><![CDATA[%s]]></DataTag>\n"
" <Description><![CDATA[%s]]></Description>\n"
@@ -108,8 +108,8 @@ void QTestXmlStreamer::formatStart(const QTestElement *element, char **formatted
// assuming type and attribute names don't need quoting
QTestCharBuffer quotedFile;
QTestCharBuffer cdataDesc;
- QXmlTestLogger::xmlQuote(quotedFile, element->attributeValue(QTest::AI_File));
- QXmlTestLogger::xmlCdata(cdataDesc, element->attributeValue(QTest::AI_Description));
+ QXmlTestLogger::xmlQuote(&quotedFile, element->attributeValue(QTest::AI_File));
+ QXmlTestLogger::xmlCdata(&cdataDesc, element->attributeValue(QTest::AI_Description));
QTest::qt_asprintf(formatted, "<Message type=\"%s\" %s=\"%s\" %s=\"%s\">\n <Description><![CDATA[%s]]></Description>\n</Message>\n",
element->attributeValue(QTest::AI_Type),
@@ -124,8 +124,8 @@ void QTestXmlStreamer::formatStart(const QTestElement *element, char **formatted
// assuming value and iterations don't need quoting
QTestCharBuffer quotedMetric;
QTestCharBuffer quotedTag;
- QXmlTestLogger::xmlQuote(quotedMetric, element->attributeValue(QTest::AI_Metric));
- QXmlTestLogger::xmlQuote(quotedTag, element->attributeValue(QTest::AI_Tag));
+ QXmlTestLogger::xmlQuote(&quotedMetric, element->attributeValue(QTest::AI_Metric));
+ QXmlTestLogger::xmlQuote(&quotedTag, element->attributeValue(QTest::AI_Tag));
QTest::qt_asprintf(formatted, "<BenchmarkResult %s=\"%s\" %s=\"%s\" %s=\"%s\" %s=\"%s\" />\n",
element->attributeName(QTest::AI_Metric),
@@ -139,23 +139,23 @@ void QTestXmlStreamer::formatStart(const QTestElement *element, char **formatted
break;
}
default:
- QTest::qt_asprintf(formatted, "");
+ formatted->data()[0] = '\0';
}
}
-void QTestXmlStreamer::formatEnd(const QTestElement *element, char **formatted) const
+void QTestXmlStreamer::formatEnd(const QTestElement *element, QTestCharBuffer *formatted) const
{
if(!element || !formatted)
return;
if (element->elementType() == QTest::LET_TestCase) {
QTest::qt_asprintf(formatted, "</TestFunction>\n");
+ } else {
+ formatted->data()[0] = '\0';
}
- else
- QTest::qt_asprintf(formatted, "");
}
-void QTestXmlStreamer::formatBeforeAttributes(const QTestElement *element, char **formatted) const
+void QTestXmlStreamer::formatBeforeAttributes(const QTestElement *element, QTestCharBuffer *formatted) const
{
if(!element || !formatted)
return;
@@ -163,9 +163,9 @@ void QTestXmlStreamer::formatBeforeAttributes(const QTestElement *element, char
if (element->elementType() == QTest::LET_TestCase && element->attribute(QTest::AI_Result)){
QTestCharBuffer buf;
QTestCharBuffer quotedFile;
- QXmlTestLogger::xmlQuote(quotedFile, element->attributeValue(QTest::AI_File));
+ QXmlTestLogger::xmlQuote(&quotedFile, element->attributeValue(QTest::AI_File));
- QTest::qt_asprintf(buf, "%s=\"%s\" %s=\"%s\"",
+ QTest::qt_asprintf(&buf, "%s=\"%s\" %s=\"%s\"",
element->attributeName(QTest::AI_File),
quotedFile.constData(),
element->attributeName(QTest::AI_Line),
@@ -174,12 +174,11 @@ void QTestXmlStreamer::formatBeforeAttributes(const QTestElement *element, char
if( !element->childElements() ) {
QTest::qt_asprintf(formatted, "<Incident type=\"%s\" %s/>\n",
element->attributeValue(QTest::AI_Result), buf.constData());
+ } else {
+ formatted->data()[0] = '\0';
}
- else {
- QTest::qt_asprintf(formatted, "");
- }
- }else{
- QTest::qt_asprintf(formatted, "");
+ } else {
+ formatted->data()[0] = '\0';
}
}
@@ -187,23 +186,23 @@ void QTestXmlStreamer::output(QTestElement *element) const
{
QTestCharBuffer buf;
QTestCharBuffer quotedTc;
- QXmlTestLogger::xmlQuote(quotedTc, QTestResult::currentTestObjectName());
+ QXmlTestLogger::xmlQuote(&quotedTc, QTestResult::currentTestObjectName());
- QTest::qt_asprintf(buf, "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<TestCase name=\"%s\">\n",
+ QTest::qt_asprintf(&buf, "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<TestCase name=\"%s\">\n",
quotedTc.constData());
- outputString(buf);
+ outputString(buf.constData());
- QTest::qt_asprintf(buf, "<Environment>\n <QtVersion>%s</QtVersion>\n <QTestVersion>%s</QTestVersion>\n",
+ QTest::qt_asprintf(&buf, "<Environment>\n <QtVersion>%s</QtVersion>\n <QTestVersion>%s</QTestVersion>\n",
qVersion(), QTEST_VERSION_STR );
- outputString(buf);
+ outputString(buf.constData());
- QTest::qt_asprintf(buf, "</Environment>\n");
- outputString(buf);
+ QTest::qt_asprintf(&buf, "</Environment>\n");
+ outputString(buf.constData());
QTestBasicStreamer::output(element);
- QTest::qt_asprintf(buf, "</TestCase>\n");
- outputString(buf);
+ QTest::qt_asprintf(&buf, "</TestCase>\n");
+ outputString(buf.constData());
}
QT_END_NAMESPACE