diff options
author | Harald Fernengel <harald@trolltech.com> | 2009-08-07 13:08:09 (GMT) |
---|---|---|
committer | Harald Fernengel <harald@trolltech.com> | 2009-08-07 13:10:36 (GMT) |
commit | dfa284220498a1e32ab3133f203bcb41cfa136b7 (patch) | |
tree | e6e8a6cae4b2195313258c5001100e2557c6463e /src/testlib/qplaintestlogger.cpp | |
parent | 658c30c214070e8ff05ddaf1cb7b161c1b73f5ce (diff) | |
download | Qt-dfa284220498a1e32ab3133f203bcb41cfa136b7.zip Qt-dfa284220498a1e32ab3133f203bcb41cfa136b7.tar.gz Qt-dfa284220498a1e32ab3133f203bcb41cfa136b7.tar.bz2 |
Refactor QTestCharBuffer a bit
Use a static buffer for small strings, and making it oom safe.
We can now see messages up to 512 bytes even if we run out of memory
(important for OOM tests). Also, testlogging (< 512 bytes per line)
should again work without a single allocation.
Reviewed-By: Rohan McGovern <rohan.mcgovern@nokia.com>
Diffstat (limited to 'src/testlib/qplaintestlogger.cpp')
-rw-r--r-- | src/testlib/qplaintestlogger.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/testlib/qplaintestlogger.cpp b/src/testlib/qplaintestlogger.cpp index e075b36..2515c51 100644 --- a/src/testlib/qplaintestlogger.cpp +++ b/src/testlib/qplaintestlogger.cpp @@ -180,7 +180,7 @@ namespace QTest { : ""; const char *filler = (tag[0] && gtag[0]) ? ":" : ""; if (file) { - QTest::qt_asprintf(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 @@ -189,14 +189,14 @@ namespace QTest { , type, QTestResult::currentTestObjectName(), fn, gtag, filler, tag, msg[0] ? " " : "", msg, file, line); } else { - QTest::qt_asprintf(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); + memcpy(buf.data(), type, strlen(type)); + outputMessage(buf.data()); } template <typename T> @@ -207,7 +207,7 @@ namespace QTest { int digits = 0; qreal divisor = 1; - + while (num / divisor >= 1) { divisor *= 10; ++digits; |