diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2022-07-09 16:12:40 +0200 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2022-07-10 03:08:32 +0000 |
commit | 54b276be0b5885bbaee2c38f472eb39731fd684a (patch) | |
tree | 54930bb8584873a4d4db9845d8722dae4c556fcc /src/testlib/qtestcase.h | |
parent | 07ada0b971a84483f3676b5fef46ff2bd6d26dbb (diff) |
testlib: Don't print QCOMPARE values if they lack string representation
Before 0681a2dd5a8095baddb5905fb21a58ce19b958c5, QCOMPARE'ing types
for which no QTest::toString specialization exists did not output
Actual and Expected lines on failure, as that would only print <null>
for both values (which then look like the same value, confusingly).
Commit 0681a2dd5a8095baddb5905fb21a58ce19b958c5 changed that behavior,
and started printing the confusing <null> values.
Take care of the logic in the formatFailMessage function: if both values
are nullptr, then print only the variable names, but not the confusing
<null> text representation of the values.
Remove dead and duplicated code related to the formatting logic, add a
self-test function, and update the expected_cmptest files.
Fixes: QTBUG-104867
Pick-to: 6.4
Change-Id: I4be98e79f91196b14690a2cc0a68ffd50b431a45
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/testlib/qtestcase.h')
-rw-r--r-- | src/testlib/qtestcase.h | 11 |
1 files changed, 0 insertions, 11 deletions
diff --git a/src/testlib/qtestcase.h b/src/testlib/qtestcase.h index 7db64af8ab..0412f872f7 100644 --- a/src/testlib/qtestcase.h +++ b/src/testlib/qtestcase.h @@ -437,17 +437,6 @@ namespace QTest Q_TESTLIB_EXPORT QTestData &newRow(const char *dataTag); Q_TESTLIB_EXPORT QTestData &addRow(const char *format, ...) Q_ATTRIBUTE_FORMAT_PRINTF(1, 2); -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - // kept after adding implementation of <T1, T2> out of paranoia: - template <typename T> - inline bool qCompare(T const &t1, T const &t2, const char *actual, const char *expected, - const char *file, int line) - { - return compare_helper(t1 == t2, "Compared values are not the same", - toString(t1), toString(t2), actual, expected, file, line); - } -#endif - Q_TESTLIB_EXPORT bool qCompare(qfloat16 const &t1, qfloat16 const &t2, const char *actual, const char *expected, const char *file, int line); |