summaryrefslogtreecommitdiffstats
path: root/src/testlib/qtestxmlstreamer.cpp
diff options
context:
space:
mode:
authorRohan McGovern <rohan.mcgovern@nokia.com>2009-07-30 10:53:28 +1000
committerRohan McGovern <rohan.mcgovern@nokia.com>2009-07-30 14:54:44 +1000
commit79ed97b8298e3c7e3c7d266c905024affeba7258 (patch)
tree9306b4a8bcaface2c243217aa3bc527aa553ef2f /src/testlib/qtestxmlstreamer.cpp
parenta92117be4323e26efe3f13b5c624e5010a7cd26a (diff)
Make QTestBasicStreamer use dynamically allocated strings.
This commit contains the bare minimum needed for the API to use dynamic allocation; some parts of the code still use static buffers and therefore have constraints on the size of output messages. Task: 253861 Reviewed-by: Michael Goddard
Diffstat (limited to 'src/testlib/qtestxmlstreamer.cpp')
-rw-r--r--src/testlib/qtestxmlstreamer.cpp28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/testlib/qtestxmlstreamer.cpp b/src/testlib/qtestxmlstreamer.cpp
index 5172bcdf35..b9e0a381d8 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, char **formatted) const
{
if(!element || !formatted)
return;
@@ -71,7 +71,7 @@ void QTestXmlStreamer::formatStart(const QTestElement *element, char *formatted)
QXmlTestLogger::xmlQuote(quotedTf, element->attributeValue(QTest::AI_Name),
sizeof(quotedTf));
- QTest::qt_snprintf(formatted, 1024, "<TestFunction name=\"%s\">\n", quotedTf);
+ QTest::qt_asprintf(formatted, "<TestFunction name=\"%s\">\n", quotedTf);
break;
}
case QTest::LET_Failure: {
@@ -94,14 +94,14 @@ void QTestXmlStreamer::formatStart(const QTestElement *element, char *formatted)
char cdataTag[100];
QXmlTestLogger::xmlCdata(cdataTag, element->attributeValue(QTest::AI_Tag),
sizeof(cdataTag));
- QTest::qt_snprintf(formatted, 1024, "<Incident type=\"%s\" %s>\n"
+ QTest::qt_asprintf(formatted, "<Incident type=\"%s\" %s>\n"
" <DataTag><![CDATA[%s]]></DataTag>\n"
" <Description><![CDATA[%s]]></Description>\n"
"</Incident>\n", element->attributeValue(QTest::AI_Result),
location, cdataTag, cdataDesc);
}
else {
- QTest::qt_snprintf(formatted, 1024, "<Incident type=\"%s\" %s>\n"
+ QTest::qt_asprintf(formatted, "<Incident type=\"%s\" %s>\n"
" <Description><![CDATA[%s]]></Description>\n"
"</Incident>\n", element->attributeValue(QTest::AI_Result),
location, cdataDesc);
@@ -117,7 +117,7 @@ void QTestXmlStreamer::formatStart(const QTestElement *element, char *formatted)
QXmlTestLogger::xmlCdata(cdataDesc, element->attributeValue(QTest::AI_Description),
sizeof(cdataDesc));
- QTest::qt_snprintf(formatted, 1024, "<Message type=\"%s\" %s=\"%s\" %s=\"%s\">\n <Description><![CDATA[%s]]></Description>\n</Message>\n",
+ QTest::qt_asprintf(formatted, "<Message type=\"%s\" %s=\"%s\" %s=\"%s\">\n <Description><![CDATA[%s]]></Description>\n</Message>\n",
element->attributeValue(QTest::AI_Type),
element->attributeName(QTest::AI_File),
quotedFile,
@@ -135,7 +135,7 @@ void QTestXmlStreamer::formatStart(const QTestElement *element, char *formatted)
QXmlTestLogger::xmlQuote(quotedTag, element->attributeValue(QTest::AI_Tag),
sizeof(quotedTag));
- QTest::qt_snprintf(formatted, 1024, "<BenchmarkResult %s=\"%s\" %s=\"%s\" %s=\"%s\" %s=\"%s\" />\n",
+ QTest::qt_asprintf(formatted, "<BenchmarkResult %s=\"%s\" %s=\"%s\" %s=\"%s\" %s=\"%s\" />\n",
element->attributeName(QTest::AI_Metric),
quotedMetric,
element->attributeName(QTest::AI_Tag),
@@ -147,23 +147,23 @@ void QTestXmlStreamer::formatStart(const QTestElement *element, char *formatted)
break;
}
default:
- QTest::qt_snprintf(formatted, 10, "");
+ QTest::qt_asprintf(formatted, "");
}
}
-void QTestXmlStreamer::formatEnd(const QTestElement *element, char *formatted) const
+void QTestXmlStreamer::formatEnd(const QTestElement *element, char **formatted) const
{
if(!element || !formatted)
return;
if (element->elementType() == QTest::LET_TestCase) {
- QTest::qt_snprintf(formatted, 1024, "</TestFunction>\n");
+ QTest::qt_asprintf(formatted, "</TestFunction>\n");
}
else
- QTest::qt_snprintf(formatted, 10, "");
+ QTest::qt_asprintf(formatted, "");
}
-void QTestXmlStreamer::formatBeforeAttributes(const QTestElement *element, char *formatted) const
+void QTestXmlStreamer::formatBeforeAttributes(const QTestElement *element, char **formatted) const
{
if(!element || !formatted)
return;
@@ -181,14 +181,14 @@ void QTestXmlStreamer::formatBeforeAttributes(const QTestElement *element, char
element->attributeValue(QTest::AI_Line));
if( !element->childElements() ) {
- QTest::qt_snprintf(formatted, 1024, "<Incident type=\"%s\" %s/>\n",
+ QTest::qt_asprintf(formatted, "<Incident type=\"%s\" %s/>\n",
element->attributeValue(QTest::AI_Result), buf);
}
else {
- QTest::qt_snprintf(formatted, 10, "");
+ QTest::qt_asprintf(formatted, "");
}
}else{
- QTest::qt_snprintf(formatted, 10, "");
+ QTest::qt_asprintf(formatted, "");
}
}