summaryrefslogtreecommitdiffstats
path: root/src/testlib/qtestxunitstreamer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/testlib/qtestxunitstreamer.cpp')
-rw-r--r--src/testlib/qtestxunitstreamer.cpp42
1 files changed, 20 insertions, 22 deletions
diff --git a/src/testlib/qtestxunitstreamer.cpp b/src/testlib/qtestxunitstreamer.cpp
index 6690cecfb..d5d2631bf 100644
--- a/src/testlib/qtestxunitstreamer.cpp
+++ b/src/testlib/qtestxunitstreamer.cpp
@@ -73,7 +73,7 @@ void QTestXunitStreamer::indentForElement(const QTestElement* element, char* buf
}
}
-void QTestXunitStreamer::formatStart(const QTestElement *element, char *formatted) const
+void QTestXunitStreamer::formatStart(const QTestElement *element, char **formatted) const
{
if(!element || !formatted )
return;
@@ -84,34 +84,34 @@ void QTestXunitStreamer::formatStart(const QTestElement *element, char *formatte
// Errors are written as CDATA within system-err, comments elsewhere
if (element->elementType() == QTest::LET_Error) {
if (element->parentElement()->elementType() == QTest::LET_SystemError) {
- QTest::qt_snprintf(formatted, 1024, "<![CDATA[");
+ QTest::qt_asprintf(formatted, "<![CDATA[");
}
else {
- QTest::qt_snprintf(formatted, 1024, "%s<!--", indent);
+ QTest::qt_asprintf(formatted, "%s<!--", indent);
}
return;
}
- QTest::qt_snprintf(formatted, 1024, "%s<%s", indent, element->elementName());
+ QTest::qt_asprintf(formatted, "%s<%s", indent, element->elementName());
}
-void QTestXunitStreamer::formatEnd(const QTestElement *element, char *formatted) const
+void QTestXunitStreamer::formatEnd(const QTestElement *element, char **formatted) const
{
if(!element || !formatted )
return;
if(!element->childElements()){
- QTest::qt_snprintf(formatted, 10, "");
+ QTest::qt_asprintf(formatted, "");
return;
}
char indent[20];
indentForElement(element, indent, sizeof(indent));
- QTest::qt_snprintf(formatted, 1024, "%s</%s>\n", indent, element->elementName());
+ QTest::qt_asprintf(formatted, "%s</%s>\n", indent, element->elementName());
}
-void QTestXunitStreamer::formatAttributes(const QTestElement* element, const QTestElementAttribute *attribute, char *formatted) const
+void QTestXunitStreamer::formatAttributes(const QTestElement* element, const QTestElementAttribute *attribute, char **formatted) const
{
if(!attribute || !formatted )
return;
@@ -124,7 +124,7 @@ void QTestXunitStreamer::formatAttributes(const QTestElement* element, const QTe
if (attrindex != QTest::AI_Description) return;
- QXmlTestLogger::xmlCdata(formatted, attribute->value(), 1024);
+ QXmlTestLogger::xmlCdata(formatted, attribute->value());
return;
}
@@ -135,16 +135,16 @@ void QTestXunitStreamer::formatAttributes(const QTestElement* element, const QTe
key = attribute->name();
if (key) {
- char quotedValue[900];
- QXmlTestLogger::xmlQuote(quotedValue, attribute->value(), sizeof(quotedValue));
- QTest::qt_snprintf(formatted, 1024, " %s=\"%s\"", key, quotedValue);
+ QTestCharBuffer quotedValue;
+ QXmlTestLogger::xmlQuote(quotedValue, attribute->value());
+ QTest::qt_asprintf(formatted, " %s=\"%s\"", key, quotedValue.constData());
}
else {
- QTest::qt_snprintf(formatted, 10, "");
+ QTest::qt_asprintf(formatted, "");
}
}
-void QTestXunitStreamer::formatAfterAttributes(const QTestElement *element, char *formatted) const
+void QTestXunitStreamer::formatAfterAttributes(const QTestElement *element, char **formatted) const
{
if(!element || !formatted )
return;
@@ -152,31 +152,29 @@ void QTestXunitStreamer::formatAfterAttributes(const QTestElement *element, char
// Errors are written as CDATA within system-err, comments elsewhere
if (element->elementType() == QTest::LET_Error) {
if (element->parentElement()->elementType() == QTest::LET_SystemError) {
- QTest::qt_snprintf(formatted, 1024, "]]>\n");
+ QTest::qt_asprintf(formatted, "]]>\n");
}
else {
- QTest::qt_snprintf(formatted, 1024, " -->\n");
+ QTest::qt_asprintf(formatted, " -->\n");
}
return;
}
if(!element->childElements())
- QTest::qt_snprintf(formatted, 10, "/>\n");
+ QTest::qt_asprintf(formatted, "/>\n");
else
- QTest::qt_snprintf(formatted, 10, ">\n");
+ QTest::qt_asprintf(formatted, ">\n");
}
void QTestXunitStreamer::output(QTestElement *element) const
{
- char buf[1024];
- QTest::qt_snprintf(buf, sizeof(buf), "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n");
- outputString(buf);
+ outputString("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n");
QTestBasicStreamer::output(element);
}
void QTestXunitStreamer::outputElements(QTestElement *element, bool) const
{
- char buf[1024];
+ QTestCharBuffer buf;
bool hasChildren;
/*
Elements are in reverse order of occurrence, so start from the end and work