From fca3ea040c9d05f112c6fc018f0c8e8c68892642 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 4 Jan 2021 13:40:24 +0100 Subject: QTestlib: Fix custom toString() implementations for QList comparison MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit d25589e0529732996e405aaff8d6c46b012e1601 mistakenly changed the code to use toString() from the QTest namespace. Call toString() unqualified and move the compareSequence() helper out of the internal namespace. Fixes: QTBUG-89737 Pick-to: 6.0 Change-Id: I8452a0aead7771ad13a5b95438b54e202ccce76b Reviewed-by: Tor Arne Vestbø --- src/testlib/qtest.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/testlib/qtest.h b/src/testlib/qtest.h index 4e6a4d3611..4bf5e018a7 100644 --- a/src/testlib/qtest.h +++ b/src/testlib/qtest.h @@ -420,14 +420,12 @@ inline bool qCompare(QLatin1String const &t1, QString const &t2, const char *act return qCompare(QString(t1), t2, actual, expected, file, line); } -namespace Internal { - // Compare sequences of equal size template -bool compareSequence(ActualIterator actualIt, ActualIterator actualEnd, - ExpectedIterator expectedBegin, ExpectedIterator expectedEnd, - const char *actual, const char *expected, - const char *file, int line) +bool _q_compareSequence(ActualIterator actualIt, ActualIterator actualEnd, + ExpectedIterator expectedBegin, ExpectedIterator expectedEnd, + const char *actual, const char *expected, + const char *file, int line) { char msg[1024]; msg[0] = '\0'; @@ -446,8 +444,8 @@ bool compareSequence(ActualIterator actualIt, ActualIterator actualEnd, for (auto expectedIt = expectedBegin; isOk && expectedIt < expectedEnd; ++actualIt, ++expectedIt) { if (!(*actualIt == *expectedIt)) { const qsizetype i = qsizetype(expectedIt - expectedBegin); - char *val1 = QTest::toString(*actualIt); - char *val2 = QTest::toString(*expectedIt); + char *val1 = toString(*actualIt); + char *val2 = toString(*expectedIt); qsnprintf(msg, sizeof(msg), "Compared lists differ at index %zd.\n" " Actual (%s): %s\n" @@ -462,6 +460,8 @@ bool compareSequence(ActualIterator actualIt, ActualIterator actualEnd, return compare_helper(isOk, msg, nullptr, nullptr, actual, expected, file, line); } +namespace Internal { + #if defined(TESTCASE_LOWDPI) void disableHighDpi() { @@ -476,7 +476,7 @@ template inline bool qCompare(QList const &t1, QList const &t2, const char *actual, const char *expected, const char *file, int line) { - return Internal::compareSequence(t1.cbegin(), t1.cend(), t2.cbegin(), t2.cend(), + return _q_compareSequence(t1.cbegin(), t1.cend(), t2.cbegin(), t2.cend(), actual, expected, file, line); } @@ -485,7 +485,7 @@ bool qCompare(QList const &t1, std::initializer_list t2, const char *actual, const char *expected, const char *file, int line) { - return Internal::compareSequence(t1.cbegin(), t1.cend(), t2.cbegin(), t2.cend(), + return _q_compareSequence(t1.cbegin(), t1.cend(), t2.cbegin(), t2.cend(), actual, expected, file, line); } @@ -495,7 +495,7 @@ bool qCompare(QList const &t1, const T (& t2)[N], const char *actual, const char *expected, const char *file, int line) { - return Internal::compareSequence(t1.cbegin(), t1.cend(), t2, t2 + N, + return _q_compareSequence(t1.cbegin(), t1.cend(), t2, t2 + N, actual, expected, file, line); } -- cgit v1.2.3