summaryrefslogtreecommitdiffstats
path: root/src/testlib/qplaintestlogger.cpp
diff options
context:
space:
mode:
authorRohan McGovern <rohan.mcgovern@nokia.com>2009-07-29 07:26:37 (GMT)
committerRohan McGovern <rohan.mcgovern@nokia.com>2009-07-30 04:54:44 (GMT)
commita92117be4323e26efe3f13b5c624e5010a7cd26a (patch)
tree23aa971a07a98543324fa69761a1b4183a537991 /src/testlib/qplaintestlogger.cpp
parent5246aeb198ccfd2a3fc94298161c24cb8f57f81f (diff)
downloadQt-a92117be4323e26efe3f13b5c624e5010a7cd26a.zip
Qt-a92117be4323e26efe3f13b5c624e5010a7cd26a.tar.gz
Qt-a92117be4323e26efe3f13b5c624e5010a7cd26a.tar.bz2
Allow testlib loggers to dynamically allocate storage for strings.
This enables very long failure messages (e.g. including an entire build log in a failure message). This change modifies only the plain test logger to use this feature. Task: 253861 Reviewed-by: Michael Goddard
Diffstat (limited to 'src/testlib/qplaintestlogger.cpp')
-rw-r--r--src/testlib/qplaintestlogger.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/testlib/qplaintestlogger.cpp b/src/testlib/qplaintestlogger.cpp
index 071b55e..7bebaa1 100644
--- a/src/testlib/qplaintestlogger.cpp
+++ b/src/testlib/qplaintestlogger.cpp
@@ -168,7 +168,7 @@ namespace QTest {
QTEST_ASSERT(type);
QTEST_ASSERT(msg);
- char buf[1024];
+ QTestCharBuffer buf;
const char *fn = QTestResult::currentTestFunction() ? QTestResult::currentTestFunction()
: "UnknownTestFunc";
@@ -178,7 +178,7 @@ namespace QTest {
: "";
const char *filler = (tag[0] && gtag[0]) ? ":" : "";
if (file) {
- QTest::qt_snprintf(buf, sizeof(buf), "%s: %s::%s(%s%s%s)%s%s\n"
+ QTest::qt_asprintf(buf, "%s: %s::%s(%s%s%s)%s%s\n"
#ifdef Q_OS_WIN
"%s(%d) : failure location\n"
#else
@@ -187,10 +187,12 @@ namespace QTest {
, type, QTestResult::currentTestObjectName(), fn, gtag, filler, tag,
msg[0] ? " " : "", msg, file, line);
} else {
- QTest::qt_snprintf(buf, sizeof(buf), "%s: %s::%s(%s%s%s)%s%s\n",
+ QTest::qt_asprintf(buf, "%s: %s::%s(%s%s%s)%s%s\n",
type, QTestResult::currentTestObjectName(), fn, gtag, filler, tag,
msg[0] ? " " : "", msg);
}
+ // In colored mode, printf above stripped our nonprintable control characters.
+ // Put them back.
memcpy(buf, type, strlen(type));
outputMessage(buf);
}