C++26 adds std::saturate_cast, so follow the established pattern of
other similar "backported" APIs. The old name is left around while
we port other submodules.
While at it, move qt_saturate's tests to the qnumeric test.
Change-Id: I653a2e3d936081378298a9c8e51e7c1a2d438d83
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 7447ad503330ed176cf369792ffb33b7e00a58d3)
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Now when we explicitly have the _NON_NOEXCEPT version of the macros,
and a static_assert() in the "normal" macros, it does not make sense
to have these checks in the helper functions. If the developers choose
the _NON_NOEXCEPT macro, they clearly know what they are doing.
So simply drop the check and get rid of the annoying XFAILs in the
test log.
Change-Id: Id467ae5ad6a852da7c39dd1dbf32ce5838e69ecc
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 80bc0152448fbd4a57a4c95147e7b3f067e6a35c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
The qsnprintf() function introduces even more platform variability
than std::snprintf(), so from now on, we're using only std::snprintf().
Task-number: QTBUG-127110
Change-Id: Ic81b2a760521d77442cc328d2cfa7659bba8b7e2
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit b8a956c2d3f9c158594265eca89185bd2bc671e7)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
As part of the qsnprint() -> std::snprintf() port, we included both
<stdio.h> and <cstdio>. Standardize on the latter; this is a C++
project, after all.
Change-Id: Icd8ef528b94cea75dd0ede18b4105f85b08c3515
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 73d7138c020d0f95ad354c4ec4512a54914e0195)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Drive-by remove an explicit NUL-termination (std::snprintf() does
that) and port a repeated use of printf argument checking to the
protect() idiom.
Change-Id: Ida15940fe9aef0622e9836a229a398c909503a9a
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit b5115d1c2fc73feb149a8ee97de011b3c75694fb)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Use higher-level API (QByteArray::chopped()/operator+()) instead
of new[] and qsnprintf().
methodSignature() already heavily depends on QByteArray concatenation,
therefore trying to avoid using Qt code in QtTest is pointless, at
least here.
Drive-by indent lines so a follow-up port to std::fsprintf() will not
have to re-indent these lines again.
Amends b68bae1132.
Pick-to: 6.7 6.5
Change-Id: I94ec440d7e6d09196cf87cd3dbbfd765e0df69d0
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit a15ff49be73228bbbc72989736d32059322c414f)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Before we roll out QT_NO_QSNPRINTF across Qt, we need to make sure at
least the headers are clean, so downstream modules can port without
being stabbed in the back by unported upstream headers.
Task-number: QTBUG-127110
Change-Id: I7411ff0036482ad68bd5867b624518f68f249228
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 7e2fa57faf230ef8cb505b95c2bc0e70867ac131)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Unit test failure should not happen, so mark failure formatters as
cold (like qFail() itself).
As a drive-by, mark formatFailMessage() overloads file-static, too.
Change-Id: I92f5b674a7282f4ebaa9250894a9971a524f4108
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 69c510d6bcc52ac133a82d7a9493ffba037c4521)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Commit 63295f43e70955a194602a7acf39013f124e14b7 changed the size:
placeholders to %lld, but wrapped only one of the arguments in
qlonglong. This causes 32-bit builds to read past the end of the
expectedSize variable.
Fix by wrapping the other, too.
Pick-to: 6.7 6.5 6.2 5.15
Change-Id: I9c23ab589c8895e8f038fb508e18ac3006fa4f8f
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 57eff5b092dbd692594125edc70d3efd898660ea)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Once we ported the formatting to use formatFailMessage() in
aa8a4be9e9eae82b6c6b8875371114dbfb3ec06a, it became apparent that the
output contained an extra leading newline compared QCOMPARE use of
formatFailMessage(). We kept the newline in the patch that was picked
to older branches. Since this is a stylistic discrepancy, though,
standardize on no leading newline going forward.
Change-Id: I4badf700900a106d835f3f72e92441d8a8912ff7
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 4bc81fe5d1d1e4587075a82a45be9b34825b5233)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
The patch that originally added the function used std::clamp() because
qt_saturate() wasn't available in all the branches to which the patch
was backported. This patch modernizes the code for newer branches.
Pick-to: 6.7 6.5
Change-Id: I1b764d303e00ec04858643efed3dcc71f2c7ce4c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit d042c14c9940c6aabaa5b39d3061c0f9e50fff06)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This is a clean-up after a previous commit that needed the version
check for cherry-picking to 5.15.
Pick-to: 6.7 6.5 6.2
Change-Id: I914ca6ec184e2d7c376de4c7de6f2f0f7e9ecb22
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 4dd730f99fc95ad1e4c231dda70957b6c01df1b0)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Qt 5 had qint64 as __int64 on Windows, so using I64 was correct, then,
but MinGW was already using long long, so using I64 for all Q_OS_WIN
builds was wrong even then. So exclude Q_CC_GNU from the I64
formatting.
In Qt 6, all platforms always use long long, so no Windows-specific
handling is needed anymore.
Found by adding __attribute__((format(printf))) to qsnprintf().
Pick-to: 6.7 6.5 6.2 5.15
Change-Id: Icfa0afc6f0fe06e5d47684702097ac1d3da6cef1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit ab74c1779ec2499758449d41999356a91bb82cf8)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
The mbstowcs() function is not re-entrant, and while we can probably
rule out that our test macros are being executed concurrently, we
can't rule out that other parts of the test concurrently execute
std::mbstowcs().
To fix, de-inline the code so we can re-use the existing
formatFailMessage() in qtestresult.cpp, which has already been fixed
before.
Amends 930e59b798.
Pick-to: 6.7 6.5 6.2
Change-Id: I61144af13a41ea0b4fba17bd232e660ef33dbd20
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit aa8a4be9e9eae82b6c6b8875371114dbfb3ec06a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This function is not re-entrant, and while we can probably rule out
that our test macros are being executed concurrently, we can't rule
out that other parts of the test concurrently execute std::mbstowcs().
Use the re-entrant version and also fix the format string (%* requires
int, not size_t).
Saturation is ok here, because, while std::mbsrtowcs() will happily
return a value > maxMsgLen when dst == nullptr and the string is
longer, we will never actually print more than maxMsgLen of it.
As a drive-by, port to std and adjust the QNX comments to describe the
quirky QNX behavior, if, indeed, still present in the <cwchar>
version, better. This author had to go back in the git history to
figure out what it wanted to tell him.
Amends 2d8028d696 (mbstowcs) and
d040681b6f (%*).
Pick-to: 6.7 6.5 6.2 5.15
Change-Id: I6215713c643647727f73f4e2f2a7ac34204af40d
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 1579b18dfa49252318b4a2b3cfa83a4ce325ba0c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Before we add __attribute__((format(printf))) to qsnprintf(), we need
to make sure our code is clean.
Pick-to: 6.7 6.5 6.2 5.15
Task-number: QTBUG-127110
Change-Id: I7411ff0036482ad68bd5867b624518f68f249229
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 63295f43e70955a194602a7acf39013f124e14b7)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
qsnprintf() does not make a difference between lvalue and rvalue
arguments, so the wrapper doesn't need to perfectly forward.
Use decay-copy via by-value arguments to potentially reduce the number
of instantiations required for the existing calls.
Adjust indentation so the continuation line doesn't need to be
re-indented when we'll port qsnprintf() to std::snprintf().
Amends 0e8eb20af4.
Pick-to: 6.7 6.5
Change-Id: Idcaa441517fdbf00fefd952db7928731779123ab
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit fba67959acb7be39942aa3ce829f6764c46ad3ee)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
qsnprint() is unconditionally called to fill the buffer and is
guaranteed to NUL-terminate, so there's no point in filling the whole
stack buffer with NULs beforehand. Leave it uninitialized.
The code was moved in 4ae6f40b3a, so not
picking further than that.
Change-Id: I34d456ebd2990aa242ccc42693adbbf1f64148de
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 4c5b437a3ce84354dfa3bf2c4706e05144ac03a3)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
qsnprint() is unconditionally called to fill the buffer and is
guaranteed to NUL-terminate, so there's no point in filling the whole
1KiB stack buffer with NULs beforehand. Leave it uninitialized.
Amends 930e59b798.
Pick-to: 6.7 6.5 6.2
Change-Id: I7da859d609ad4492c9038cb3e14f2a721b2acbe4
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 47c2263e896408e733c9aa466aec388cc4b4a6ad)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Document cycle_p.h's provenance - thanks to Morten Sørvig for digging
that up - and update to its version in the most recent release of
FFTW. Include patches to apply (after purging dangling hspace) for
future updates.
[ChangeLog][Third-Party Code] QtTest's benchlib now uses FFTW
v3.3.10's version of the clock-cycle counter, Cycle.
Task-number: QTBUG-126080
Change-Id: Ib59bc53e5d74cfdc889c03e78f9dd72100168f64
Reviewed-by: Jason McDonald <macadder1@gmail.com>
(cherry picked from commit 6e7c158152cef6a1ae6a628f08661fcc4b27de90)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Nothing hugely consequential, although __VALGRIND_MINOR__ was
previously out of step with the version given in qt_attribution.json.
[ChangeLog][Third-Party Code] Updated QtTest's Valgrind headers to
version 3.23.
Fixes: QTBUG-126080
Change-Id: Ie2c9d41d4f35cd497b1dcf9a366cf4b319b361ad
Reviewed-by: Jason McDonald <macadder1@gmail.com>
(cherry picked from commit efab6e69831c7fc8d35f18e211bda20f854f2f39)
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
Our use of the clock-cycle counter from FFTW involved a rename of its
type ticks to our type CycleCounterTicks. This unnaturally bulks up
the diff from upstream, so undo it and use a simple #define to achieve
the same effect, as seen by our code.
Task-number: QTBUG-126080
Change-Id: Icbe9c413b73dd9213b95f183b71585f4a9c38de1
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
(cherry picked from commit ed7becd9cba582640f19704b5c439e5f6807bc29)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Move from tests/auto/testlib/selftests/ to
src/testlib/3rdparty/cache2/, so that its path includes a 3rdparty
component and it's isolated from the rest of the selftest files.
Instead, it's now grouped with QtTest's other 3rdparty components, to
make it easier, when doing a 3rdparty update, to see what might need
an update.
In the process, document where in the upstream to find the file to be
copied, if an update is needed. The file is generated, so document its
generator, too, in case its output gets renamed. There is no more
recent release than the 2.13.10 we currently have, so no update will
follow.
Task-number: QTBUG-126080
Change-Id: I371bac233b00318f59d6043fb245ab44b914bf8a
Reviewed-by: Jason McDonald <macadder1@gmail.com>
(cherry picked from commit 31adb73e289d1bd93276af2b1df9bc356ba14766)
In the process, update the Linux perf_event.h provenance details to
make it possible to find the latest version. Also, remove 3rdparty
headers from the module's CMakeLists.txt (where possible) so that
anything that includes them makes its 3rdparty dependence visible in
the relative path. That can't be applied to cycle_p.h, though, as it's
used by the tests.
Task-number: QTBUG-126080
Change-Id: I3a7099bc123ba7188ad096714cb7ed45ff35a392
Reviewed-by: Jason McDonald <macadder1@gmail.com>
(cherry picked from commit b14906884c63b3f5f239d7d008eb23aba66836fa)
QBenchmarkEvent::nativeEventFilter() was changed with Qt6 but the old
Qt5 version was still there and no longer used.
Pick-to: 6.7 6.5
Change-Id: Ia740ce0dc743666c9b3bcbe12d1d310fb9ffcd7b
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit ef215fdd8bd36c0312d657e0aafaa766d7c297f7)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Better name given the value names, as discussed during header review.
Keep AnnouncementPriority as an alias until dependencies are updated.
Change-Id: I7b60c429fb60fc30378a9560da12abb87499225f
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
(cherry picked from commit bb305e63ff856a8c6f9649a27a5eabfb31df8aa7)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
The behavior that argument was enabling is the default one now.
Task-number: QTBUG-90492
Change-Id: I11711d4c794f0b22169abb595b8ffad2eeb1300d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
(cherry picked from commit 1ef3bd05eb45d53cdcf92b933603b995283b3432)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This enables doing QtGui testing when using QAbstractItemModelTester
in Qt for Python, where the QTestlib binding only links against
QtCore.
Port the code to check against QMetaType constructed from type names.
Task-number: PYSIDE-2772
Change-Id: Ifcd8f1ea4758459d8a178226e3f215e5c2b273b8
Reviewed-by: hjk <hjk@qt.io>
(cherry picked from commit bb542a55b28dd591709ed2c68e4505ec08fc62b5)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
A standalone comment added before a test case or keyword will
be confusing once more test cases and keywords are added, as
the comment likely doesn't apply to those added lines.
Change-Id: I4e36c1c2ae4547bcffa9df817cd53c64cf66defb
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
(cherry picked from commit 2f939540c7a7dac262dd61210351cbd24545ee83)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Returning the wrong data type for Qt::SizeHintRole may lead to a size
of 0,0 and the item disappearing.
Task-number: PYSIDE-2772
Change-Id: I906445f2ed2141da2606774f2b8ad6282662eb17
Reviewed-by: hjk <hjk@qt.io>
(cherry picked from commit 84f2cd6523081ed8774b2a9fe9ee36d05172ff50)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Right now vxworks is not on the list of keywords used to blacklist
tests.
Because of that, it's not possible to blacklist a test specifically on
that platform.
Solve the problem by extending the list.
Pick-to: 6.7
Task-number: QTBUG-115777
Change-Id: I04d55eabc27f7554ea9e3fa030ff118a22a624b6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 8f9b0891f59dbc59d1295bf8eff361070bd01a9d)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Makes sense to collect the stuff in a similarly-named header, and it's
not like any of the QTypeTraits stuff was needed for QTypeInfo.
Makes #include <qtypeinfo.h> _much_ lighter again, at the expense of
qminmax.h now getting <variant>, <tuple> and <optional> instead, but
qminmax.h is much easier to avoid in Qt headers (just use the std
versions) than qtypeinfo.h.
[ChangeLog][QtCore][Potentially Source-Incompatible Changes] The
qtypeinfo.h header no longer transitively includes <optional>, <tuple>
and <variant>.
Task-number: QTBUG-97601
Change-Id: Ied96113f38c1232fef3ec79847ee62f06c68f268
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit b2eb422699118f4ae8370519b4c7bb3fe121beb2)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
It seems like all subclasses of QAccessibleEvent need to be registered
here, otherwise tests explode.
Change-Id: I924961f351bda1f50e2c73d54abe4b51162dc82a
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This requires some fixes in several classes that are also included
in this patch.
The QTestEvent hierarchy is all-inline and changes layout depending on
QT_GUI_LIB and QT_WIDGETS_LIB, so we can't just export it. Suppress the
warning in that header for now. Created QTBUG-104486 to track a fix for
the real issue.
The QFutureInterface hierarchy is also all-inline, but templates, so
doesn't trigger, except the <void> specialization. Created
QTBUG-125115 to track a fix for the real issue.
Done-with: Marc Mutz <marc.mutz@qt.io>
Task-number: QTBUG-45582
Change-Id: I96b3e109aa989b70e0d4809b90bd53a369e50d55
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Previously, the sig member was used to indicate successful
construction of the QSignalSpy (incl. successful connection to the
monitored signal), so it was set only after all other initialization
had taken place, preventing it from being marked as const, which would
indicate that accesses to it need not be protected by the mutex.
Now that we have it, we can instead use the d_ptr's value to indicate
success, and mark sig const.
[ChangeLog][QtTest][Important Behavior Changes][QSignalSpy] The
signal() method no longer necessarily returns an empty byte array when
the connection failed. Use the existing isValid() method to determine
whether a given QSignalSpy object listens to a valid signal on a valid
object.
Change-Id: Ia08fe3b383681f3f203cf1a121c0e1ce08ad268b
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: David Faure <david.faure@kdab.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Now that the private ctor that calls this function is finally
out-of-line, this function need no longer be part of the ABI.
Task-number: QTBUG-123544
Change-Id: Ia4656bf8bfd4d68d6925f93ef150593cd2de6ddf
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Many users (albeit mostly in qtdeclarative) of failOnWarning() are
passing a catch-all regexp, which is only supported when regular
expression support is enabled. Make their lives easier and those
checks independent of the feature by adding a third overload, taking
no parameter, that fails on any (unanticipated) warning.
Implementation is trivial - just put a null QVariant in
failOnWarningList; it won't match either check on the entry that might
exempt a test from failing on a warning, so any warning at all will
trigger failure.
[ChangeLog][QtTest] QTest::failOnWarning() now has a no-parameter
overload to support the common case of fail-on-any-warning, without
needing to construct a match-everything regular expression.
Change-Id: Ic693f1c8619fd6e495543b85737d566134cf9d20
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
There used to be an examples page; this is no longer the case. Thus,
remove the \note that indicates you can access the source code.
Fixes: QTBUG-122166
Pick-to: 6.7 6.6 6.5
Change-Id: I1abe88000ae406e8d2cc9cc1deed42664607626b
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
Normally, we'd fix -Wweak-vtable by exporting the class and making at
least one virtual method out-of-line (typically the dtor), thereby
pinning the vtable to exactly one TU.
We can't export QSignalSpy, though, because it also inherits QList,
and we don't want to export QList subclasses to avoid QList API
becoming part of the ABI.
So remove the vtable, and therefore its being a weak symbol, by moving
the qt_metacall implementation from QSignalSpy into its newly-added
Private, at the cost of an additional memory allocation at
construction (though there was already the wish to make this class
pimpl'ed for extensibility, and this patch accomplishes exactly that).
This class used to be one of few places left that prevents adding
-Wweak-vtable to headersclean, so while this is a breaking change,
QSignalSpy doesn't really model is-a QObject. It uses QObject to
reuse, not to be reused. In fact, no external code should use the
QObject-ness of QSignalSpy, so it should be an acceptable SC break to
drop the inheritance.
We don't need to care about BC here, as we don't promise BC for
QtTest.
This now also allows (and requires) to make the dtor and the private
ctor out-of-line, avoiding the need for the init() hack.
[ChangeLog][QtTest][Potentially Source-Incompatible Changes]
QSignalSpy no longer inherits from QObject. If your code uses the fact
that QSignalSpy is-a QObject, you need to redesign around this now.
Task-number: QTBUG-45582
Fixes: QTBUG-123544
Change-Id: Id93ba0ee6bbb811455d3744a045e38e1b9f9c584
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Jason McDonald <macadder1@gmail.com>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
There's no need to condition that comparison only for heterogeneous
types. The reverse comparisons will compile if the types are homogeneous
(it's what we had already tested), but this now ensures the results are
also the expected ones.
Change-Id: If1bf59ecbe014b569ba1fffd17c4a2dd756157b2
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Using templates to make the code look nicer and be more debuggable.
Previously, if you tried to step into the QCOMPARE_xx, you'd have the
creations of qxp::function_ref from the lambdas before you got to the
actual comparison. And all of this was in-place from macro expansion, so
you couldn't tell what was happening.
Now, if you step into QCOMPARE_xx, you go to qCompareOp. There are 5
frames between that point and the actual comparison (four std::forward()
and the Compare::compare()) and debuggers could step over std::forward.
Even if they can't, both libstdc++ and libc++ implementations are simple
casts, so there's nothing more to step into.
Change-Id: I12a088d1ae424825abd3fffd171dbbf7adb7e7e2
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
[ChangeLog][QtTest] The QCOMPARE_xx macros can now only find
QTest::toString() expansions that are either found via Argument
Dependent Lookup on the type in question or are an instatiation of the
QTest::toString<T>() template. This matches the behavior of the
QCOMPARE() macro.
This changes the way how the toString() overloads are selected, so
we need to explicilty constraint the main QTest::toString() template
in order to pick the free functions when they exist.
Change-Id: Ie28eadac333c4bcd8c08fffd17c54e768c5cffd0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
This is causing huge code bloat because everything is a local lambda.
Instead, pass direct type-erased function and data pointers to the
replacement function. Testing with tst_qcborvalue, this reduces the
compilation time and the output binary size significantly:
Before After
Compiler Time Size Time Size
GCC 13.2 136.99 s 202.3 MB 13.88 s 14.3 MB
GCC 14.0 131.49 s 202.7 MB 14.69 s 14.4 MB
Clang 17 77.2 s 146.7 MB 13.62 s 12.2 MB
Clang 18 141.9 s 187.1 MB 13.62 s 12.4 MB
This causes a difference in how toString() overloads are
found. Previously it would match far more overloads because the
toString() calls were expanded by the macro. Now, we depend on
Argument-Dependent Lookup and associated namespaces, so toString()
overloads should not be in the QTest namespace any more.
With this patch applied, the testlib testcase of tst_selftest
started failing, because nullptr is now handled differently.
However, I consider it as a bugfix, because previously it was
falling back to a default implementation, and now it is using
the QTest::toString(std::nullptr_t) overload, which is a
desired behavior. Update the reference files for tst_selftest
with the new expected output.
Task-number: QTBUG-124272
Change-Id: Ie28eadac333c4bcd8c08fffd17c5484186accdf6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>