qt5base-lts/tests/auto
Ivan Solovev 0681a2dd5a QTestLib: rework QTest::compare_helper()
[ChangeLog][QTestLib] QCOMPARE now evaluates toString() on its
arguments lazily, speeding up the general case where the comparison
doesn't fail. This is true for the QCOMPARE functionality provided
by Qt. If you specialized qCompare() for your own types, then you
need to change its implementation in line with Qt's own qCompare()
specializations in order to enable this feature.

[ChangeLog][QTestLib] QCOMPARE calls with nullptr argument(s) will
now print the actual and expected values upon failure.

Previously it was not like that because of the compareHelper()
overload in qtestresult.cpp that treated the presence of
nullptr-arguments as a reason to ignore formatFailMessage() call.
New implementation does not have this check, and correctly
executes formatFailMessage() for all arguments.

Note that the qCompare() overloads that call QTestResult::compare()
internally were not affected by this patch, because they already
defer toString() invocation until the comparison fails.

Some numbers, collected against shared release developer build.
I checked how this change affects the test execution. The idea was
to pick some tests for types that do not have a specific
QTestResult::compare overload, so I picked a couple of QByteArray
tests.
The comparison is done by running a test 10 times and taking the
average execution duration, as reported in the log.

tst_qbytearrayapisymmetry:
 Before: 15.6 ms
 After:  14.2 ms

tst_qbytearray:
 Before: 41 ms
 After:  36 ms

The benefit is around 9% and 12% respectively.

Fixes: QTBUG-98874
Change-Id: I7d59ddc760168b15974e7720930f629fb34efa13
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-06-03 20:37:51 +00:00
..
bic/data Add BiC data for the new way to do BiC testing 2022-05-12 13:33:41 +03:00
cmake Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
concurrent QtConcurrent: prevent conversion of ReduceOption to initial value 2022-05-20 17:11:15 +02:00
corelib QTestLib: rework QTest::compare_helper() 2022-06-03 20:37:51 +00:00
dbus QDBusArgument: ensure std::vector isn't seen as an associative container 2022-05-17 01:27:33 +02:00
gui Do metadata detach simpler than full detach 2022-06-01 15:54:50 +02:00
guiapplauncher Move QStateMachine from QtCore to QtScxml 2020-08-24 20:10:25 +02:00
network Network: update Public Suffix List 2022-05-23 22:28:49 +02:00
opengl Remove the qmake project files 2021-01-07 15:32:28 +01:00
other Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
printsupport Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
shared Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
sql Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
testlib QTestLib: rework QTest::compare_helper() 2022-06-03 20:37:51 +00:00
tools Make uic generate correct C++ comments 2022-05-18 11:53:26 +02:00
widgets Fix separate delete of window and windowcontainer 2022-05-23 21:25:46 +02:00
xml Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
CMakeLists.txt Only configure one test for wasm 2022-05-12 18:55:04 +02:00
network-settings.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00