diff options
author | Simon Hausmann <simon.hausmann@theqtcompany.com> | 2015-03-18 15:23:56 +0000 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2015-03-18 22:27:24 +0000 |
commit | dcf0ececbf167502ac9943c6435bb9ddeeb29d5e (patch) | |
tree | 19416d427b84f0a90e0d3028588404a544003734 /src/testlib | |
parent | 7aad6b9fd426e05fdfb3892d60432a45e4079887 (diff) | |
parent | 198606f6dbca95ba3a170fff387327d8271018cd (diff) |
Merge "Merge remote-tracking branch 'origin/5.5' into dev" into refs/staging/dev
Diffstat (limited to 'src/testlib')
-rw-r--r-- | src/testlib/qtestcase.cpp | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index fa2080fe69..222bdd3f39 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -88,6 +88,7 @@ QT_BEGIN_NAMESPACE using QtMiscUtils::toHexUpper; +using QtMiscUtils::fromHex; /*! \namespace QTest @@ -2056,6 +2057,7 @@ static bool qInvokeTestMethod(const char *slotName, const char *data=0) /* For each entry in the data table, do: */ do { QTestResult::setSkipCurrentTest(false); + QTestResult::setBlacklistCurrentTest(false); if (!data || !qstrcmp(data, table.testData(curDataIndex)->dataTag())) { foundFunction = true; @@ -2087,6 +2089,7 @@ static bool qInvokeTestMethod(const char *slotName, const char *data=0) QTestResult::finishedCurrentTestFunction(); QTestResult::setSkipCurrentTest(false); + QTestResult::setBlacklistCurrentTest(false); QTestResult::setCurrentTestData(0); delete[] slot; @@ -2184,7 +2187,7 @@ char *toHexRepresentation(const char *ba, int length) /*! \internal Returns the same QByteArray but with only the ASCII characters still shown; - everything else is replaced with \c {\OOO}. + everything else is replaced with \c {\xHH}. */ char *toPrettyCString(const char *p, int length) { @@ -2193,14 +2196,30 @@ char *toPrettyCString(const char *p, int length) const char *end = p + length; char *dst = buffer.data(); + bool lastWasHexEscape = false; *dst++ = '"'; for ( ; p != end; ++p) { + // we can add: + // 1 byte: a single character + // 2 bytes: a simple escape sequence (\n) + // 3 bytes: "" and a character + // 4 bytes: an hex escape sequence (\xHH) if (dst - buffer.data() > 246) { - // plus the the quote, the three dots and NUL, it's 251, 252 or 255 + // plus the the quote, the three dots and NUL, it's 255 in the worst case trimmed = true; break; } + // check if we need to insert "" to break an hex escape sequence + if (Q_UNLIKELY(lastWasHexEscape)) { + if (fromHex(*p) != -1) { + // yes, insert it + *dst++ = '"'; + *dst++ = '"'; + } + lastWasHexEscape = false; + } + if (*p < 0x7f && *p >= 0x20 && *p != '\\' && *p != '"') { *dst++ = *p; continue; @@ -2230,10 +2249,12 @@ char *toPrettyCString(const char *p, int length) *dst++ = 't'; break; default: - // write as octal - *dst++ = '0' + ((uchar(*p) >> 6) & 7); - *dst++ = '0' + ((uchar(*p) >> 3) & 7); - *dst++ = '0' + ((uchar(*p)) & 7); + // print as hex escape + *dst++ = 'x'; + *dst++ = toHexUpper(uchar(*p) >> 4); + *dst++ = toHexUpper(uchar(*p)); + lastWasHexEscape = true; + break; } } @@ -2362,6 +2383,7 @@ static void qInvokeTestMethods(QObject *testObject) } QTestResult::setSkipCurrentTest(false); + QTestResult::setBlacklistCurrentTest(false); QTestResult::setCurrentTestFunction("cleanupTestCase"); invokeMethod(testObject, "cleanupTestCase()"); QTestResult::finishedCurrentTestData(); |