summaryrefslogtreecommitdiffstats
path: root/src/testlib/qtestlightxmlstreamer.cpp
diff options
context:
space:
mode:
authorRohan McGovern <rohan.mcgovern@nokia.com>2009-07-30 00:53:28 (GMT)
committerRohan McGovern <rohan.mcgovern@nokia.com>2009-07-30 04:54:44 (GMT)
commit79ed97b8298e3c7e3c7d266c905024affeba7258 (patch)
tree9306b4a8bcaface2c243217aa3bc527aa553ef2f /src/testlib/qtestlightxmlstreamer.cpp
parenta92117be4323e26efe3f13b5c624e5010a7cd26a (diff)
downloadQt-79ed97b8298e3c7e3c7d266c905024affeba7258.zip
Qt-79ed97b8298e3c7e3c7d266c905024affeba7258.tar.gz
Qt-79ed97b8298e3c7e3c7d266c905024affeba7258.tar.bz2
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/qtestlightxmlstreamer.cpp')
-rw-r--r--src/testlib/qtestlightxmlstreamer.cpp42
1 files changed, 21 insertions, 21 deletions
diff --git a/src/testlib/qtestlightxmlstreamer.cpp b/src/testlib/qtestlightxmlstreamer.cpp
index 170938a..a7e205a 100644
--- a/src/testlib/qtestlightxmlstreamer.cpp
+++ b/src/testlib/qtestlightxmlstreamer.cpp
@@ -59,7 +59,7 @@ QTestLightXmlStreamer::QTestLightXmlStreamer()
QTestLightXmlStreamer::~QTestLightXmlStreamer()
{}
-void QTestLightXmlStreamer::formatStart(const QTestElement *element, char *formatted) const
+void QTestLightXmlStreamer::formatStart(const QTestElement *element, char **formatted) const
{
if(!element || !formatted)
return;
@@ -70,7 +70,7 @@ void QTestLightXmlStreamer::formatStart(const QTestElement *element, char *forma
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: {
@@ -78,7 +78,7 @@ void QTestLightXmlStreamer::formatStart(const QTestElement *element, char *forma
QXmlTestLogger::xmlCdata(cdataDesc, element->attributeValue(QTest::AI_Description),
sizeof(cdataDesc));
- QTest::qt_snprintf(formatted, 1024, " <Description><![CDATA[%s]]></Description>\n",
+ QTest::qt_asprintf(formatted, " <Description><![CDATA[%s]]></Description>\n",
cdataDesc);
break;
}
@@ -91,7 +91,7 @@ void QTestLightXmlStreamer::formatStart(const QTestElement *element, char *forma
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,
@@ -109,7 +109,7 @@ void QTestLightXmlStreamer::formatStart(const QTestElement *element, char *forma
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),
@@ -121,61 +121,61 @@ void QTestLightXmlStreamer::formatStart(const QTestElement *element, char *forma
break;
}
default:
- QTest::qt_snprintf(formatted, 10, "");
+ QTest::qt_asprintf(formatted, "");
}
}
-void QTestLightXmlStreamer::formatEnd(const QTestElement *element, char *formatted) const
+void QTestLightXmlStreamer::formatEnd(const QTestElement *element, char **formatted) const
{
if(!element || !formatted)
return;
if (element->elementType() == QTest::LET_TestCase) {
if( element->attribute(QTest::AI_Result) && element->childElements())
- QTest::qt_snprintf(formatted, 1024, "</Incident>\n</TestFunction>\n");
+ QTest::qt_asprintf(formatted, "</Incident>\n</TestFunction>\n");
else
- QTest::qt_snprintf(formatted, 1024, "</TestFunction>\n");
+ QTest::qt_asprintf(formatted, "</TestFunction>\n");
}
else
- QTest::qt_snprintf(formatted, 10, "");
+ QTest::qt_asprintf(formatted, "");
}
-void QTestLightXmlStreamer::formatBeforeAttributes(const QTestElement *element, char *formatted) const
+void QTestLightXmlStreamer::formatBeforeAttributes(const QTestElement *element, char **formatted) const
{
if(!element || !formatted)
return;
if (element->elementType() == QTest::LET_TestCase && element->attribute(QTest::AI_Result)){
- char buf[900];
+ QTestCharBuffer buf;
char quotedFile[700];
QXmlTestLogger::xmlQuote(quotedFile, element->attributeValue(QTest::AI_File),
sizeof(quotedFile));
- QTest::qt_snprintf(buf, sizeof(buf), "%s=\"%s\" %s=\"%s\"",
+ QTest::qt_asprintf(buf, "%s=\"%s\" %s=\"%s\"",
element->attributeName(QTest::AI_File),
quotedFile,
element->attributeName(QTest::AI_Line),
element->attributeValue(QTest::AI_Line));
if( !element->childElements() )
- QTest::qt_snprintf(formatted, 1024, "<Incident type=\"%s\" %s/>\n",
- element->attributeValue(QTest::AI_Result), buf);
+ QTest::qt_asprintf(formatted, "<Incident type=\"%s\" %s/>\n",
+ element->attributeValue(QTest::AI_Result), buf.constData());
else
- QTest::qt_snprintf(formatted, 1024, "<Incident type=\"%s\" %s>\n",
- element->attributeValue(QTest::AI_Result), buf);
+ QTest::qt_asprintf(formatted, "<Incident type=\"%s\" %s>\n",
+ element->attributeValue(QTest::AI_Result), buf.constData());
}else{
- QTest::qt_snprintf(formatted, 10, "");
+ QTest::qt_asprintf(formatted, "");
}
}
void QTestLightXmlStreamer::output(QTestElement *element) const
{
- char buf[1024];
- QTest::qt_snprintf(buf, sizeof(buf), "<Environment>\n <QtVersion>%s</QtVersion>\n <QTestVersion>%s</QTestVersion>\n",
+ QTestCharBuffer buf;
+ QTest::qt_asprintf(buf, "<Environment>\n <QtVersion>%s</QtVersion>\n <QTestVersion>%s</QTestVersion>\n",
qVersion(), QTEST_VERSION_STR );
outputString(buf);
- QTest::qt_snprintf(buf, sizeof(buf), "</Environment>\n");
+ QTest::qt_asprintf(buf, "</Environment>\n");
outputString(buf);
QTestBasicStreamer::output(element);