qt5base-lts/tests/auto/testlib/selftests/expected_testlib.xml
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

51 lines
1.7 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<TestCase name="tst_TestLib">
<Environment>
<QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
<QtBuild/>
<QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
</Environment>
<TestFunction name="initTestCase">
<Incident type="pass" file="" line="0" />
<Duration msecs="0"/>
</TestFunction>
<TestFunction name="basics">
<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/testlib/tst_testlib.cpp" line="0">
<Description><![CDATA[Compared QObject pointers are not the same
Actual (QTest::testObject()): tst_TestLib/"TestObject"
Expected (nullptr) : <null>]]></Description>
</Incident>
<Duration msecs="0"/>
</TestFunction>
<TestFunction name="delays">
<Incident type="pass" file="" line="0" />
<Duration msecs="0"/>
</TestFunction>
<TestFunction name="reals">
<Incident type="pass" file="" line="0">
<DataTag><![CDATA[zero]]></DataTag>
</Incident>
<Incident type="pass" file="" line="0">
<DataTag><![CDATA[self-qQNaN]]></DataTag>
</Incident>
<Incident type="pass" file="" line="0">
<DataTag><![CDATA[self-qInf]]></DataTag>
</Incident>
<Incident type="pass" file="" line="0">
<DataTag><![CDATA[infineg]]></DataTag>
</Incident>
<Incident type="pass" file="" line="0">
<DataTag><![CDATA[Sin(turn/4)]]></DataTag>
</Incident>
<Incident type="pass" file="" line="0">
<DataTag><![CDATA[Cos(turn/2)]]></DataTag>
</Incident>
<Duration msecs="0"/>
</TestFunction>
<TestFunction name="cleanupTestCase">
<Incident type="pass" file="" line="0" />
<Duration msecs="0"/>
</TestFunction>
<Duration msecs="0"/>
</TestCase>