summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/tools
Commit message (Collapse)AuthorAgeFilesLines
* Tests: remove #define COMMAThiago Macieira2022-08-091-7/+5
| | | | | | | | | | Those were workarounds to passing a comma to a macro, but there are ways around it. The simplest is to just use variadic macros; another, which has been applied to Q_DECLARE_METATYPE for a long time, is to define an alias to the thing you're trying to use. Change-Id: Ie4bb662dcb274440ab8bfffd17097fbf0c53eabc Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Add license headers to cmake filesLucie Gérard2022-08-0346-0/+138
| | | | | | | | | | | | CMakeLists.txt and .cmake files of significant size (more than 2 lines according to our check in tst_license.pl) now have the copyright and license header. Existing copyright statements remain intact Task-number: QTBUG-88621 Change-Id: I3b98cdc55ead806ec81ce09af9271f9b95af97fa Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* CMake: Don't use PUBLIC_LIBRARIES for tests and test helpersAlexandru Croitor2022-07-2812-12/+12
| | | | | Change-Id: I9b7404e1d3a78fe0726ec0f5ce1461f6c209e90d Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
* Increase timeout of slow test for ASAN-enabled buildDimitrios Apostolou2022-06-151-0/+4
| | | | | Change-Id: I47b6e7e1462c1af7d41677bfe7bb0f78430f72d1 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Long live QAtomicScopedValueRollback (private API)!Marc Mutz2022-05-315-3/+169
| | | | | | | | | | | | | | | | | | | | | | | | | QScopedValueRollback has a few users that apply it on QAtomicInt, which happens to work as QAtomicInt is copy-constructible and its ctors are implicit. But that's of course nonsense. We don't need to store the oldValue in an atomic, nor do we need to pass the new value into the ctor as an atomic. So, add a QAtomicScopedValueRollback which works on std::atomic as well as the Qt atomics, but distinguishes between the reference (which is atomic) and the value (which isn't), and use it in one of the users, tst_QList. Keep it private until we know whether there's an actual need for this. The test is a copy of tst_qscopedvaluefallback, so the occasional oddity (like atomic op*=) should be ignored. Task-number: QTBUG-103835 Change-Id: I3c05b3e51f465698657a02ca5521ed465386e9a6 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Use SPDX license identifiersLucie Gérard2022-05-1654-1465/+115
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* QVarLengthArray: add missing (size, value) ctorMarc Mutz2022-04-131-0/+12
| | | | | | | | | | | Extend the corresponding test in tst_containerapisymmetry. [ChangeLog][QtCore][QVarLengthArray] Added (size, value) constructor. Fixes: QTBUG-102469 Change-Id: I4802eebe6ba1a6835e4d6f41e1d3db2a0d7c7894 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Replace uses of _qs with _s in testsSona Kurazyan2022-04-071-1/+3
| | | | | | Task-number: QTBUG-101408 Change-Id: If092a68828a1e8056259cf90d035d9a87989244b Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Q[Multi]Hash: fix squeeze()Ivan Solovev2022-04-061-1/+94
| | | | | | | | | | | | | | | | | | | When calling QHash::reserve(), or when creating the internal QHashPrivate::Data structure, the value 0 for the size parameter is reserved for performing the squeeze operation. However commit 8a984ab772dd194e39094e728b869e65912912a7 broke it, by using the 0 value in QHashPrivate::Data constructors as a mark that no resizing needs to be done. This patch reverts the problematic commit (also applying some later fixes to the code), and adds the missing tests for Q[Multi]Hash::squeeze(). Pick-to: 6.3 6.2 Change-Id: Id644df7b2beb008e6a37b2c89b709adfbd893e25 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Q[Multi]Hash::reserve(): do nothing if desired size is less than currentIvan Solovev2022-04-061-0/+31
| | | | | | | | | | | | | | | | Calling Q[Multi]Hash::reserve(n) when n is much smaller than the current amount of elements in the hash, could result in an infinite loop, because at some point the algorithm could not find a free bucket for the element. Fixing it by returning early if the new desired capacity is less than current. Fixes: QTBUG-102067 Pick-to: 6.3 6.2 Change-Id: I38ef0b2168c4e2a317eedf91b2155b1fdffb1c27 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QByteArray/QVarLengthArray: add missing resize(n, v) overloadsMarc Mutz2022-04-061-0/+23
| | | | | | | | | | | | | | | | | | QList and QString had them, so add them to QByteArray and QVarLengthArray, too. In the QVLA case, we need to jump though a hoop or two to avoid having to duplicate all the reallocation logic. Nothing a few template tricks cannot solve. [ChangeLog][QtCore][QByteArray] Added resize(n, ch) overload. [ChangeLog][QtCore][QVarLengthArray] Added resize(n, v) overload. Fixes: QTBUG-102270 Change-Id: I0d281ae5b574f440f682e4a62427b434dcf5b687 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix compiler warnings in testsVolker Hilsheimer2022-03-241-1/+1
| | | | | | | | Don't mix unsigned and signed types in comparisons. Pick-to: 6.3 Change-Id: Ia4ba9c114177425a21cadc8cafe8179928315a5d Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QRect: add toRectF()Marc Mutz2022-03-191-1/+38
| | | | | | | | | | For symmetry with QRectF::toRect(). [ChangeLog][QtCore][QRect] Added toRectF(). Fixes: QTBUG-73160 Change-Id: If2bda64b8fe4bc113191dda927e9bb86ebcb4c69 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QLine/QMargins: add toLineF/toMarginsF()Marc Mutz2022-03-192-2/+71
| | | | | | | | | | | | | For symmetry with QLineF::toLine(). [ChangeLog][QtCore][QLine] Added toLineF(). [ChangeLog][QtCore][QMargins] Added toMarginsF(). Task-number: QTBUG-73160 Change-Id: I69051cdd2fe4a3c0a000ab86e363a2918a7aea7c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QSize/QPoint: add toSizeF/toPointF()Marc Mutz2022-03-192-2/+60
| | | | | | | | | | | | | For symmetry with QSizeF::toSize(). [ChangeLog][QtCore][QSize] Added toSizeF(). [ChangeLog][QtCore][QPoint] Added toPointF(). Task-number: QTBUG-73160 Change-Id: I65b088b4f7365ab671ef2f0c75821b707f5ac26d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Tests: Do not depend on transitive includesFabian Kosmale2022-03-175-0/+6
| | | | | Change-Id: Ibc6a948480a904913a5427e6408d4d296784fb4f Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* QFlatMap: make insertion STL-compatibleMarc Mutz2022-03-161-16/+3
| | | | | | | | | | | | | | | | | | | | | | That is, insert() doesn't overwrite an existing entry, and range insert inserts the first of equivalent keys' values, not the last. This allowed this author to optimize the implementation of makeUnique() to a O(N) algorithm (was: O(N²)). Said optimization would have been possible with the old semantics, too, but I wrote the algorithm first and only then noticed the broken insert() behavior is present on QFlatMap, too, so I decided not to let good code go to waste and to fix both problems at the same time. In order to give users a hint of the changed semantics, make the new API opt-in until Qt 6.5, so Qt 6.4 ships with the both the old and the new semantics disabled, where they contradict. Fixes: QTBUG-100092 Change-Id: Ic96d8bfe6bed9068dbe8c0d7171bd8921050fd95 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* tst_qflatmap: fix -Wunused-local-typedef (Clang)Marc Mutz2022-03-111-1/+1
| | | | | | | | | | | False Positive, of course, since it's used in dependent callee transparent_impl(). Amends 58e8ae5605abefd0f579586a890dc13fb381b2a3. Pick-to: 6.3 Change-Id: I7520fb7cf6bce28a5fd9381783ba349119309132 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QWeakPointer: befriend other QWeakPointersThiago Macieira2022-03-041-3/+52
| | | | | | | | | | Commit c677b3b8afcdc1d7b57353826cc01f378cd25e99 added move constructors, which introduced the issue. Pick-to: 6.2 6.3 Fixes: QTBUG-100795 Change-Id: I74249c52dc02478ba93cfffd16d2c879b923e352 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Associative containers: add a way to obtain a key/value rangeGiuseppe D'Angelo2022-03-041-0/+131
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Our associative containers' iterator's value_type isn't a destructurable type (yielding key/value). This means that something like for (auto [k, v] : map) doesn't even compile -- one can only "directly" iterate on the values. For quite some time we've had QKeyValueIterator to allow key/value iteration, but then one had to resort to a "traditional" for loop: for (auto i = map.keyValueBegin(), e = keyValueEnd(); i!=e; ++i) This can be easily packaged in an adaptor class, which is what this commmit does, thereby offering a C++17-compatible way to obtain key/value iteration over associative containers. Something possibly peculiar is the fact that the range so obtained is a range of pairs of references -- not a range of references to pairs. But that's easily explained by the fact that we have no pairs to build references to; hence, for (auto &[k, v] : map.asKeyValueRange()) doesn't compile (lvalue reference doesn't bind to prvalue pair). Instead, both of these compile: for (auto [k, v] : map.asKeyValueRange()) for (auto &&[k, v] : map.asKeyValueRange()) and in *both* cases one gets references to the keys/values in the map. If the map is non-const, the reference to the value is mutable. Last but not least, implement pinning for rvalue containers. [ChangeLog][QtCore][QMap] Added asKeyValueRange(). [ChangeLog][QtCore][QMultiMap] Added asKeyValueRange(). [ChangeLog][QtCore][QHash] Added asKeyValueRange(). [ChangeLog][QtCore][QMultiHash] Added asKeyValueRange(). Task-number: QTBUG-4615 Change-Id: Ic8506bff38b2f753494b21ab76f52e05c06ffc8b Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QFlatMap: add remove_ifMarc Mutz2022-03-031-0/+87
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The existing API of QFlatMap did not allow efficient removal of elements: - std::remove_if does not apply, because it works by moving elements back in the range onto those that need to be removed, which doesn't work in flat_map's case, because, like for all associative containers, the key in value_type is const. - The node-based erase-loop (over it = cond ? c.erase(it) : std::next(it)) works, but, unlike in traditional associative containers, is quadratic, because flat_map::erase is a linear operation. According to Stepanov's principle of Efficient Computational Basis (Elements of Programming, Section 1.4), we're therefore missing API. Add it. I couldn't make up my mind about the calling convention for the predicate and, despite having authored a merged paper about erase_if, can never remember what the predicate is supposed to take, so be fancy and accept all: (*it), (it.key(), it.value()), (it.key()). This means that unary predicates can either not be generic or must be properly constrained to distinguish between pair<const K, V> and K, but that's not necessarily a bad thing. There's no reason to supply a Qt-ified removeIf on top of the standard name, because this is private API and doubling the names would do nothing except double the testing overhead. Fixes: QTBUG-100983 Change-Id: I12545058958fc5d620baa770f92193c8de8b2d26 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Exclude denormal test cases if system doesn't support itTatiana Borisova2022-02-151-0/+7
| | | | | | | | | | | | - current INTEGRITY development pack don't support denormals for float and double. All values are rounded to 0. Task-number: QTBUG-99123 Pick-to: 6.2 6.3 Change-Id: Iaaacdc4210c7ac2ec3ec337c61164a1ade0efb01 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QFlatMap: temporarily disable some codeMarc Mutz2022-02-141-4/+18
| | | | | | | | | | | | | | ... which implements or assumes something about the broken^Wnon-STL-compliant insertion behavior. Once this has integrated into all module dependencies, we can re-implement these APIs using STL-compatible semantics. Task-number: QTBUG-100092 Change-Id: I54f4f5ce7addd9543866d2c399f48aff50983b88 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix build with C++20 on macOSAllan Sandfeld Jensen2022-02-111-1/+1
| | | | | | | | | | The macOS standard library doesn't have std::contiguous_iterator yet, and it doesn't seem like libc++ has it either. Checking __cpp_lib_concepts for the C++20 official version appears to work. Pick-to: 6.3 6.2 Change-Id: I8c31cd64de24c03b3a3f37cb393bb2f9b55a834d Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Cleanup tests that add test data to resources explicitlyAlexey Edelev2022-02-111-18/+0
| | | | | | | | | | | | Remove Integrity and Android specific code that explicitly adds test data to the resource files. qt_internal_add_test functions implicitly adds test data to resources for Android and Integrity platforms by default. Change-Id: Ia1d58755b47442e1953462e38606f70fec262368 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Activate tst_QTimeLine on AndroidAndreas Buhr2022-02-101-4/+1
| | | | | | | Fixes: QTBUG-88137 Change-Id: I2b66eefd7733198664eaeecf9507daabb3a04e81 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* tst_QContainerApiSymmetry: fix incorrect P1115 detectionAllan Sandfeld Jensen2022-02-091-1/+1
| | | | | | | | | | | | | The value of __cplusplus has nothing to do with whether the library implements wg21.link/P1115 (libstdc++ even before C++20) or not (libc++, even in C++20). Use the idiomatic check (#if defined(foo) && foo >= x) instead, fixing the Android build. Pick-to: 6.3 6.2 Change-Id: I11bcefe455a1f13865c15d4beecbd3fe32115328 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Add qt_internal_undefine_global_definition functionAlexey Edelev2022-02-024-8/+4
| | | | | | | | | | | | | | | | qt_internal_undefine_global_definition disables an internal global definition that is defined by the qt_internal_add_global_definition function for a specific target. Remove the ability to set the custom "undefine" flag for the definitions since it's hard to control it using the introduced function. Pick-to: 6.2 6.3 Task-number: QTBUG-100334 Change-Id: Ic1637d97aa51bbdd06c5b191c57a941aa208d4dc Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Sequential erase/_if: don't apply predicate twice to elementMarc Mutz2022-02-021-4/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The code was trying to avoid a detach in the case no element needed to be removed, by first running find_if() on const_iterators, and then, after converting its result to (mutable) iterators, start the remove_if() algorithm where find_if() left off. But this applies the predicate to the element found by find_if() (if any) _twice_: first just before we exit the first find_if() and then just as we enter remove_if(), which will start by running find_if() again, with the result of the initial find_if as 'first'. Apart from being needlessly inefficient, this violates the specification of Uniform Erasure, which defines sequential erase_if() as being equivalent to remove_if() + container erase(), with the former being specified to apply the predicate exactly once per element. Fix by writing the remove_if() part by hand. Instead of doing the dance with the loop invariant documentation twice, simply implement erase() via erase_if() (complicated a bit by the weird passing of predicates by lvalue reference instead of by value, as would be idiomatic). This exposes users to: [ChangeLog][QtCore][Potentially Source-Incompatible Changes] A fix in the implementation of the erase-like algorithms of sequential Qt container may re-enable signed/unsigned comparison warnings previously suppressed by having occurred in std library code. To fix, cast the value to look for such that it has the same signedness as the container's elements. ... but the issue would be the same had we inlined std::remove() instead of passing a lambda to sequential_erase_if(), so it's nothing we can, nor should, work around. [ChangeLog][QtCore][Containers] Fixed a bug in the implementation of most sequential Qt container's erase-like algorithms (member removeAll()/removeIf() and free erase()/erase_if()) where the equality operator or the predicate, respectively, was applied to the first matching element twice. Each element is now tested exactly once. Pick-to: 6.3 6.2 Change-Id: Ib6d24b01b40866c125406f1cd6042d4cd083ea0d Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Restore missing Qt definitionsAlexey Edelev2022-01-314-10/+11
| | | | | | | | | | | | | | | | | Restore the 'QT_NO_JAVA_STYLE_ITERATORS' and 'QT_NO_NARROWING_CONVERSIONS_IN_CONNECT' definitions for Qt targets. Add the function that adds global definitions for Qt targets according to the provided scope and the target property-based switch to disable the definition for a specific target. Pick-to: 6.2 6.3 Task-number: QTBUG-100295 Change-Id: I28697e81f9aabc45c48d79aae1e5caea141e04e1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* QFlatMap: fix is_transparent detectionMarc Mutz2022-01-301-2/+25
| | | | | | | | | | | | | | Add a level of indirection via void_t such that struct is_transparent {}; works, and not just using is_transparent = <unspecified>; Pick-to: 6.3 Change-Id: I3ca2af6a07e6989dc95abc10fb2d0078a5269e5b Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* QFlatMap: add full is_transparent support [3/3]: add overloadsMarc Mutz2022-01-301-1/+14
| | | | | | | | | | | Now add the missing overloads for mixed-type lookups, supported by is_transparent Compare objects. Pick-to: 6.3 Change-Id: Ib588b6a4f733d5d9908c8c7d7c209df6e7bd6674 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Fix gcc warning in testsKai Köhne2022-01-241-0/+1
| | | | | | | | | | | | | Fixes /home/qt/work/qt/qtbase/tests/auto/corelib/tools/qcache/tst_qcache.cpp: In function ‘TestNamespace::quint64 qHash(TrivialHashType, size_t)’: /home/qt/work/qt/qtbase/tests/auto/corelib/tools/qcache/tst_qcache.cpp:491:41: warning: unused parameter ‘seed’ [-Wunused-parameter] 491 | quint64 qHash(TrivialHashType t, size_t seed = 0) | ~~~~~~~^~~~~~~~ Change-Id: I70446d3f53770162ec0b99f53695c11c7aac103f Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QVersionNumber: port fromString() to QAnyStringViewMarc Mutz2022-01-181-0/+41
| | | | | | | | | | | | | | | | | We can handle the UTF-8 case by reinterpreting it as Latin-1. This way, the suffixIndex stays valid as a return value. As a drive-by, optimize away toLatin1() calls by using a QVLA. We really need a better way of converting UTF-16 -> L1 than qt_to_latin1()... [ChangeLog][QtCore][QVersionNumber] fromString() now takes QAnyStringView (was: QString, QStringView, QLatin1String) and a qsizetype pointer (was: int pointer). Change-Id: I86abaadba2792658fbf93ccd1e0b86e3302c697c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QVersionNumber: change int to qsizetype in fromString()Thiago Macieira2022-01-171-1/+1
| | | | | | | | | This completes the update to qsizetype in this class, adding a couple of methods that need to be removed in Qt 7. They're only required where int is not qsizetype (i.e., 64-bit platforms). Change-Id: I0e5f6bec596a4a78bd3bfffd16c9de29bec4c637 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Remove unused .qrc filesJoerg Bornemann2022-01-171-6/+0
| | | | | | | | Task-number: QTBUG-94446 Change-Id: I136d8b4ab070a832866aa50b5701fc6bd863df8a Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* QFlatMap: add insert_or_assignMarc Mutz2022-01-121-2/+64
| | | | | | | | | | | | | | | | This does exactly what insert() on Qt associative containers does, but allows to express the intent of using the STL-incompatible Qt insert() semantics, in an STL-compatible way, instead of leaving the reader of the code wondering what semantics are expected. This is part of a very-long-term goal of fixing Qt associative container's insert() behavior, in which QFlatMap, being an affected, but private-API type, is used for proof-of-concept purposes. Task-number: QTBUG-99651 Pick-to: 6.3 6.2 Change-Id: I69010285438259918aef659d3235180c1b5be696 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* QCache: fix potential crash in trim()Mårten Nordheim2022-01-121-0/+66
| | | | | | | | | | | | | | | | | We use raw pointers to the Nodes in the QHash which is inherently fine, but we are then subject to invalidation when nodes are moved around during deletion. In trim() we don't actually need to iterate the linked-list since the node we are interested in is always chain.prev Pick-to: 6.3 6.2 6.2.3 Fixes: QTBUG-99710 Task-number: QTBUG-99224 Task-number: QTBUG-99240 Change-Id: I9c2ed69b29e3cadca013113a3553deb44d7382fc Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
* QFlatMap: add an alias for using QVarLengthArraysMarc Mutz2022-01-121-2/+1
| | | | | | | | | | ... in an attempt to foster the use of this data structure by making it less onerous to spell. Pick-to: 6.3 6.2 Change-Id: Ib9d17029c75278edde6ba90f65f68af179a6d230 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QFlatMap: add try_emplace (w/o hint)Marc Mutz2022-01-121-0/+83
| | | | | | | | | | | | | | | | | | | | | | QFlatMap, like its public brethren, features the broken Qt-style insert() behavior (what the STL calls insert_or_assign()), which makes its insert() unusable for actual STL-style insert() work, with no replacement except the size-check-and-index-operator trick: const auto oldSize = c.size(); auto &e = c[key]; if (c.size() != oldSize) { // inserted } Even though QFlatMap::insert() appears to return the correct info, it's useless, because the old value has been assigned over by the time insert() returns. Pick-to: 6.3 6.2 Change-Id: If4173c42523a128dfd22ab496dde0089ba73f41c Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* QFlatMap: fix mixed rvalue/lvalue insert overloadsMarc Mutz2022-01-071-0/+37
| | | | | | | | They never worked. Pick-to: 6.3 6.2 Change-Id: I9a15c848416419823f28ea580248fbe93a4365dd Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* tst_QHash: Update the erase_edge_case testMårten Nordheim2021-12-171-3/+29
| | | | | | | | | | | | | | | | | By using the bucketForHash function we can loop through and find some appropriate keys to test the edge-case. This will then automatically keep the test working even if some internals of QHash changes. We do this because certain changes which change the bucket the pre-selected keys would end up in could make the test a no-op, without warning. And recent and upcoming changes have changed both this and erase(). We limit the search-space to the minimum numBuckets * 4, where minimum numBuckets is current 128. Change-Id: I13b0bce15ee884144e3248846be34667fb5d35cc Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Fix autotest runtime failures on INTEGRITYTatiana Borisova2021-12-161-1/+1
| | | | | | | | | | | - add test resources to binaries - link Qt::Gui to tst_qpointer for static build case Task-number: QTBUG-99123 Pick-to: 6.2 6.3 Change-Id: I311827b9c641eaf9537091b051c15f9fcbcb9f0c Reviewed-by: Kimmo Ollila <kimmo.ollila@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix hash lookup using the value of a key iteratorLars Knoll2021-12-161-0/+17
| | | | | | | | | | | | | | | QHash::operator[] could grow the hash even if the key being looked up already existed. This in turn invalidated all iterators. Avoid this by refactoring findOrInsert() to not grow if the key already exists. Added advantage is that this should make lookups of existing keys slightly faster. Fixes: QTBUG-97752 Pick-to: 6.3 6.2 Change-Id: I9df30459797b42c434ba0ee299fd1d55af8d2313 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Make QRingBuffer a move-only typeMarc Mutz2021-12-161-2/+13
| | | | | | | | | | | | There's no sense in copying a ring buffer. Moving is enough. This marks an important step on the way to preventing accidental copies of ring buffer content, because the 'QList buffers' member can now no longer be implicitly shared. While the compiler will still emit the code for detach()ing, it will now never be executed. Pick-to: 6.3 Change-Id: I968bfe3e50c46720ed4baca55c99c1f9c518f653 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QVarLengthArray: don't allow syncqt to export base classesMarc Mutz2021-12-151-1/+1
| | | | | | | | Check, in tst_qvarlengtharray, that the forwarding header still works. Pick-to: 6.3 Change-Id: Ia03cf48457f538287880bb676aea3fa44aeb255f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QCache: Adapt to upcoming QHash changesMårten Nordheim2021-12-131-0/+16
| | | | | | | | | | QHash changes some of its preconditions, so we must not call findNode without verifying !isEmpty() Task-number: QTBUG-91739 Task-number: QTBUG-98436 Change-Id: I2701b9a01187530f541a7c9a12db56c92f856d87 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QVarLengthArray: deprecate prepend()Marc Mutz2021-12-112-3/+18
| | | | | | | | | | | | | | | | All Qt 6 containers have "fast" prepend these days. Except QVLA. Instead of enabling "fast" prepend for QVLA, slowing down idiomatic QVLA use, simply deprecate prepend(). There appear to be no users of this function in qtbase outside tests. [ChangeLog][QtCore][Deprecation Notices][QVarLengthArray] Deprecated prepend() because QVarLengthArray is the only Qt container without a "fast" prepend. If you require that functionality, even though it's a linear operation, then use insert(cbegin(), ~~~) instead. Change-Id: I39ff1dd7d4de7fc08d5380a5a7450dd8c8996fe2 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QList: fix typo in QList(It, It)Marc Mutz2021-12-101-12/+0
| | | | | | | | | | | | Remove scaffolding in the test again. [ChangeLog][QtCore][QList] Fixed a regression that caused the range constructor to fail for pure input_iterator's. Pick-to: 6.2 Fixes: QTBUG-99036 Change-Id: I72d01a9c44c3862c335d96538f26a453b4c7c554 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* tst_containerapisymmetry: test ranged ctors with pure input_iterator typesMarc Mutz2021-12-091-0/+52
| | | | | | | | | | | Fails in Qt 6, succeeds in Qt 5.15, therefore needed to add the version check. Pick-to: 6.2 5.15 Task-number: QTBUG-99036 Change-Id: I9da1b2511d844b5fdcb63fdc58c8bc34d0f65736 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>