summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/tools/qvector
Commit message (Collapse)AuthorAgeFilesLines
* QVector: add an rvalue overload of push_back/appendMarc Mutz2015-07-192-0/+17
| | | | | | | | | | This is low-hanging fruit, for two reasons: 1. The implementation is dead-simple (unlike, say, in QList). 2. It's completely transparent to the QVector user (unlike, say, emplace_back, which can only be used inside an ifdef). Change-Id: Iaf750100cf61ced77aa452f0e4e3c4ec36b29639 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* QVector: add move(int,int) for QList compatMarc Mutz2015-06-181-0/+50
| | | | | Change-Id: I67948621313f2e7c69abe7ef95ee82ca64c6512a Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* QVector: add const first/last gettersGiuseppe D'Angelo2015-05-261-0/+141
| | | | | | | | | | | | Convenience to avoid annoying detaching (instead of using at()), especially on temporary vectors (returned by functions or so). [ChangeLog][QtCore][QVector] Added the convenience constFirst and constLast functions. Change-Id: If61b1f0096f6a7a1c9074340e237cc2376ce3d18 Task-number: QTBUG-46026 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* Add qHash(QVector)Marc Mutz2015-04-201-0/+18
| | | | | | | | | QVectors can be compared for equality, so qHash should be overloaded, too. [ChangeLog][QtCore][QVector] Added qHash(QVector). Change-Id: I2aacce55d416abf2492631a504a02c6e8fc4ff1c Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* QVector: add {const_,}reverse_iterator, {c,}r{begin,end}()Marc Mutz2015-04-021-0/+16
| | | | | | | | | | | [ChangeLog][QtCore][QVector] Added rbegin(), crbegin(), rend(), crend(), and reverse_iterator and const_reverse_iterator typedefs. Task-number: QTBUG-25919 Change-Id: I8dea52a08e7b1a4442e034c22b83be4d25dc2303 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com> Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QVector: add relational operators <,<=,>,>=Marc Mutz2015-04-021-0/+20
| | | | | | | | | | | std::vector has them, too. [ChangeLog][QtCore][QVector] Added relational operators <, <=, >, >= if the element type supports operator<. Change-Id: I0bcb22dfcc43cb0362f17b4e06154ce18646580a Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Merge remote-tracking branch 'origin/5.4' into 5.5Frederik Gladhorn2015-02-241-0/+7
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: examples/xml/htmlinfo/simpleexample.html examples/xml/rsslisting/rsslisting.cpp qmake/generators/win32/msbuild_objectmodel.cpp src/3rdparty/harfbuzz-ng/src/hb-private.hh src/corelib/global/qlogging.cpp src/corelib/io/qstorageinfo_unix.cpp src/corelib/thread/qwaitcondition_unix.cpp src/gui/kernel/qguiapplication.cpp src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp src/testlib/doc/src/qt-webpages.qdoc tests/auto/other/qaccessibility/tst_qaccessibility.cpp Change-Id: Ib272ff0bc30a1a5d51275eb3cd2f201dc82c11ff
| * QVector: fix use of invalid iterators in removeAll()Marc Mutz2015-02-221-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The c2m() function which converts a const_iterator into an iterator is a broken concept for an implicitly shared container such as QVector, because the act of calling begin() as the starting point already detaches and invalidates the c2m argument. This could be fixed in c2m, but the bug wasn't even in c2m, but in removeAll(), which called end() before c2m, so the c2m argument was already invalidated when entering c2m. The solution is to store the positions as indices instead of iterators before calling the first detaching function. Task-number: QTBUG-44592 Change-Id: I66cf4f1277e71148a4d5b5bbfb6a3369ad02db68 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* | Update copyright headersJani Heikkinen2015-02-111-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Qt copyrights are now in The Qt Company, so we could update the source code headers accordingly. In the same go we should also fix the links to point to qt.io. Outdated header.LGPL removed (use header.LGPL21 instead) Old header.LGPL3 renamed to header.LGPL3-COMM to match actual licensing combination. New header.LGPL-COMM taken in the use file which were using old header.LGPL3 (src/plugins/platforms/android/extract.cpp) Added new header.LGPL3 containing Commercial + LGPLv3 + GPLv2 license combination Change-Id: I6f49b819a8a20cc4f88b794a8f6726d975e8ffbe Reviewed-by: Matti Paaso <matti.paaso@theqtcompany.com>
* | Add a inline QVector::append(const QVector &) overloadhjk2014-11-061-0/+12
|/ | | | | | | | | | | | | | | This is present in QList already and its lack is a nuisance when switching from QList based code to QVector (which makes sense e.g. if the item size exceeds sizeof(void*)) Also, albeit operator+=() and operator<<() exist, some people simply prefer functions with real function names. [ChangeLog][QtCore][QVector] Added QVector::append(const QVector &) overload Change-Id: I9aae8223b086765625f2f3071fab5da0780f8a43 Reviewed-by: Liang Qi <liang.qi@theqtcompany.com> Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Update license headers and add new license filesMatti Paaso2014-09-241-19/+11
| | | | | | | | | - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 - Removed LICENSE.GPL Change-Id: Iec3406e3eb3f133be549092015cefe33d259a3f2 Reviewed-by: Iikka Eklund <iikka.eklund@digia.com>
* Fix typo with impact on test outputJoão Abecasis2014-07-281-1/+1
| | | | | | | | If the test fails here, output the values actually used in comparison. Change-Id: Ie4ed5ebdf1951c02b89a9648aee50a99d0bb0628 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add tests for assignment operatorJoão Abecasis2014-07-031-0/+49
| | | | | | Change-Id: I3265cb75c4d785faaf1efc183d8c1293dfff9165 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Optimize QVector::midJędrzej Nowacki2014-05-161-0/+2
| | | | | Change-Id: Iff7d9ec85a095c6712e6045e7708bb88eac629e1 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
* Merge remote-tracking branch 'origin/stable' into devFrederik Gladhorn2014-05-061-34/+81
|\ | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: mkspecs/qnx-x86-qcc/qplatformdefs.h src/corelib/global/qglobal.h src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp src/opengl/qgl.cpp src/opengl/qglpixelbuffer.cpp src/opengl/qglshaderprogram.cpp tests/auto/opengl/qglthreads/tst_qglthreads.cpp Change-Id: Iaba137884d3526a139000ca26fee02bb27b5cdb5
| * Deprecate setSharable in Qt containersThiago Macieira2014-04-241-34/+81
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The ability to set a container to be unsharable has very little use and it costs us an extra conditional for every refcount up and possibly down. This change is a no-op for current Qt 5. It shuffles a few things around just so Qt can compile if you define QT_NO_UNSHARABLE_CONTAINERS. That is done to ease the fixing of the code in Qt 6 and to make my life easier: I'll keep that defined in my local Qt build so I can catch any misuses of this deprecated API. The newly deprecated methods are not marked QT_DEPRECATED because the bootstrapped tools wouldn't build -- they're built with QT_NO_DEPRECATED defined, which causes build errors. [ChangeLog][QtCore] The setSharable() and isSharable() functions in Qt containers has been deprecated and will be removed in Qt 6. New applications should not use this feature, while old applications that may be using this (undocumented) feature should port away from it. Discussed-on: http://lists.qt-project.org/pipermail/development/2014-February/015724.html Change-Id: I789771743dcaed6a43eccd99382f8b3ffa61e479 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* | Merge remote-tracking branch 'origin/stable' into devFrederik Gladhorn2014-04-111-0/+1
|\| | | | | | | | | | | | | | | | | | | Conflicts: mkspecs/qnx-armv7le-qcc/qplatformdefs.h src/printsupport/kernel/qcups.cpp src/widgets/styles/qstyle.h tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp Change-Id: Ia41e13051169a6d4a8a1267548e7d47b859bb267
| * Fix capacity reservation for shared QByteArrayThiago Macieira2014-04-051-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | We can squeeze, but not by discarding elements. Make sure the size of the object stays intact after changing the reserved capacity. I've also added unit tests for other containers, just to be sure. Task-number: QTBUG-37750 Change-Id: I5135b095943b7589423c51cebcb52af792468e61 Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
* | QVector: add removeOne(), removeAll() for QList compatibilityMarc Mutz2014-03-261-2/+17
| | | | | | | | | | | | | | | | | | | | Eases migration from QList to QVector. [ChangeLog][QtCore][QVector] Added removeOne(), removeAll() for QList compatibility. Change-Id: I4211afb2e077c187d0a39f0ac4528f0c66721fb3 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* | QVector: add more insert() testsMarc Mutz2014-03-261-17/+75
|/ | | | | | | | Add more insert() tests, since the existing ones only covered the index-based insert() variant and only movable types. Change-Id: Ifce7a67be0bef45f926f13521873a1d77430e1e3 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Make sure all containers compile in strict-iterator modeThiago Macieira2014-02-221-1/+1
| | | | | | | | | | | | | | | | | | Unit-test this by making the QList, QVector, QHash and QMap unit tests be duplicated under strict-iterator mode. There's no test for QLinkedList. The tst_Collections test does not compile under strict-iterator mode. It generated over 15000 errors when I tried. The strict iterators required a small change: the difference_type typedef needs to match the operators that get distances (operator-(iterator)) and move the iterator around (+, -, +=, -=, etc.). Task-number: QTBUG-29608 Change-Id: I834873934c51d0f139a994cd395818da4ec997e2 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com> Reviewed-by: Jason McDonald <macadder1@gmail.com>
* Fix crash when constructing a QVector with an empty initializer list.Volker Krause2014-01-181-0/+3
| | | | | | | | | Data::allocate(0) returns a pointer to read-only memory, updating d->size will segfault. The safety check for this exists in all other QVector ctors already. Change-Id: Ida0fe4182de56ee62c7f91e8652cfafbfd7b8410 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QVector - removeLast optimizeThorbjørn Martsum2013-03-071-0/+9
| | | | | | | | | | | | In case somebody uses QVector as a stack, it is not fair to have takeLast, removeLast and pop_back to do way too much work. This is still very slow compared to std::vector::pop_back (mostly due implicit sharing), however it is more than a factor faster than before. Change-Id: I636872675e80c8ca0c8ebc94b04f587a2dcd6d8d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QVector - add functions takeFirst and takeLastThorbjørn Martsum2013-03-071-1/+14
| | | | | | | | This patch adds takeFirst and takeLast which are functions that QList also has. Change-Id: I761f90b529774edc8fa96e07c6fcf76226123b20 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QVector - add remove functionsThorbjørn Martsum2013-03-071-0/+76
| | | | | | | | | | | This patch adds the functions removeFirst() and removeLast(). Functions that QList has. Beside making these functions, pop_back and pop_front are redirected to these rather than calling erase. Change-Id: Ifc5f8a78e33f436f06f21095a920ec5d4311fd6f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix QVector detaching in one thread while another destroys it.Jędrzej Nowacki2013-02-201-1/+77
| | | | | | | | | | | | The patch adds handling for a case when a QVector is shared between two threads. In such scenario detaching in one thread could collide with destruction in the other one, causing a memory leak or assert in debug mode. Task-number: QTBUG-29134 Change-Id: Idbff250d9cfc6cf83174954ea91dbf41f8ea4aa4 Reviewed-by: Olivier Goffart <ogoffart@woboq.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Make QVector instances counter thread safeJędrzej Nowacki2013-02-201-100/+101
| | | | | | Change-Id: I7c7aa1eb0f8e91c43023882a3734e908be4ba4fe Reviewed-by: Olivier Goffart <ogoffart@woboq.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Update copyright year in Digia's license headersSergio Ahumada2013-01-181-1/+1
| | | | | Change-Id: Ic804938fc352291d011800d21e549c10acac66fb Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Core: Remove declaration of built-in and automatic metatypes.Stephen Kelly2013-01-041-1/+0
| | | | | | | | These types are either built-in or 'automatically declared' and so don't need to be explicitly declared as metatypes. Change-Id: I54523eb854619917123d8816d3cd6c3a1f5b4c55 Reviewed-by: David Faure <david.faure@kdab.com>
* detach() safely in QVector::erase(), and update callers to not detach.Andreas Hartmetz2012-10-191-13/+104
| | | | | | | | | | | | | | | | remove() can use non-detaching iterators internally before calling erase(), which hasn't been exploited so far, so that the detach() in erase() never actually detached. When using erase() from outside, you can't do it legally without calling begin() or end() that detach() before erase() is called. Now remove() doesn't detach anymore, and detaching in erase() works. With new tests that fail after changing only the erase() callers and pass again after fixing erase(). Change-Id: I47c0a9e362dce8628ec566f5437d951755de96c8 Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com> Reviewed-by: Olivier Goffart <ogoffart@woboq.com> Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
* Removed the "tst_QVector::outOfMemory" test.Christian Strømme2012-10-081-148/+0
| | | | | | | | | | | The test is useless as we assert if the requested size exceeds a certain limit. We could, as an alternative, throw an exception, but in the end it's the caller's responsibility to ensure that the requested size is a sane value. Task-number: QTBUG-27285 Change-Id: I738950a6a2b51671a54e4d25c7e4c3ac0d7f63b8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Change copyrights from Nokia to DigiaIikka Eklund2012-09-221-24/+24
| | | | | | | | Change copyrights and license headers from Nokia to Digia Change-Id: If1cc974286d29fd01ec6c19dd4719a67f4c3f00e Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Sergio Ahumada <sergio.ahumada@digia.com>
* Test: Update QSKIP message of tst_QVector::outOfMemoryCaroline Chao2012-09-221-1/+1
| | | | | | | | | | | This test is crashing. Specify the bug report number in the QSKIP message. Task-number: QTBUG-22343 Task-number: QTBUG-27285 Change-Id: I4d4ead4f54944a545103a3d01c5c9d302d7fb1df Reviewed-by: Sergio Ahumada <sergio.ahumada@digia.com>
* Set the Qt API level to compatibility mode in all tests.Thiago Macieira2012-08-011-0/+1
| | | | | | | | | | | Qt 5.0 beta requires changing the default to the 5.0 API, disabling the deprecated code. However, tests should test (and often do) the compatibility API too, so turn it back on. Task-number: QTBUG-25053 Change-Id: I8129c3ef3cb58541c95a32d083850d9e7f768927 Reviewed-by: Lars Knoll <lars.knoll@nokia.com> Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* fix compilation with conforming compilers (e.g. GCC >= 4.7)Marc Mutz2012-07-101-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | In qdbus_cast(), qMetaTypeId<QDBusArgument> as well as qvariant_cast<QDBusArgument> are used. They don't depend on any template argument of qdbus_cast(), so their definitions need to be available at function template definition instead of instantiation time. But the necessary Q_DECLARE_METATYPE(QDBusArgument) was at the end of the header, after the defintion of qdbus_cast(), which is too late for conformin compilers. Fixed by moving it up just after the QDBusArgument definition. Similarly, in tst_qdatetime and tst_qvector, the Q_DECLARE_METATYPE() for Qt::DateFormat and QVector<int>, and with it the specialisation of QMetaTypeId<>, were issued after the first use of meta typing; too late for conforming compilers. Change-Id: I25ca0b06e68d5184597a22708404a8f2040b2de1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Don't operate on bogus data, assert on preconditions insteadJoão Abecasis2012-06-231-8/+0
| | | | | | | | | | | | | | | | | | | | | | QVector::erase shouldn't try to make sense of iterators it doesn't own, so the validation being done here is bogus and dangerous. Instead, it's preferrable to assert, the user needs to ensure proper ownership. The case of erasing an empty sequence is not checked for preconditions to allow QVector v; v.erase(v.begin(), v.end()); , while being stricter on other uses. Autotests were using ill-formed calls to the single argument erase() function on an empty vector and were fixed. This function erases exactly one element, the one pointed to by abegin and require the element exist and be valid. Change-Id: I5f1a6d0d8da072eae0c73a3012620c4ce1065cf0 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Implement QVector with QArrayData interface.Jędrzej Nowacki2012-05-301-124/+1362
| | | | | Change-Id: I109f46892aed2f6024459812d24922b12358814d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Merge remote-tracking branch 'gerrit/master' into containersJoão Abecasis2012-02-051-2/+2
|\ | | | | | | | | | | | | Conflicts: src/corelib/tools/qstring.cpp Change-Id: I23d214bf33c2badfae1876da3cc7d6d8f6e635fb
| * Remove "All rights reserved" line from license headers.Jason McDonald2012-01-301-1/+1
| | | | | | | | | | | | | | | | | | | | As in the past, to avoid rewriting various autotests that contain line-number information, an extra blank line has been inserted at the end of the license text to ensure that this commit does not change the total number of lines in the license header. Change-Id: I311e001373776812699d6efc045b5f742890c689 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
| * Update contact information in license headers.Jason McDonald2012-01-231-1/+1
| | | | | | | | | | | | | | Replace Nokia contact email address with Qt Project website. Change-Id: I431bbbf76d7c27d8b502f87947675c116994c415 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* | Merge remote-tracking branch 'gerrit/master' into containersJoão Abecasis2012-01-161-1/+1
|\| | | | | | | Change-Id: I2d358b912f1055ee6021d13de2f66fd459aaa355
| * Update copyright year in license headers.Jason McDonald2012-01-051-1/+1
| | | | | | | | | | Change-Id: I02f2c620296fcd91d4967d58767ea33fc4e1e7dc Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* | Add test for QVector::setSharableJoão Abecasis2012-01-051-0/+94
|/ | | | | | Change-Id: Id31761bfb642d4ce515768c1ffe1e3088d883353 Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Remove TESTED_CLASS/TESTED_FILES comments from tests.Jason McDonald2011-12-061-3/+0
| | | | | | | | | These comments were mostly empty or inaccurate. Appropriate naming of tests and appropriate placement of tests within the directory tree provide more reliable indicators of what is being tested. Change-Id: Ib6bf373d9e79917e4ab1417ee5c1264a2c2d7027 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Cleanup corelib autotestsJason McDonald2011-11-251-7/+9
| | | | | | | | | | Bug trackers come and go, so using bug identifiers in function and test case names will ensure that those names eventually become meaningless. It is better to choose a meaningful name and provide explanatory comments where appropriate. Change-Id: I67c27782ef21b5d4eaab4854079a043c8ef6957b Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Improve QVector autotestJason McDonald2011-11-241-1/+1
| | | | | | | Ensure that data row names are unique. Change-Id: Ia6cf6e440d631928ae3352d7305c6cf2ee5b2a0c Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Cleanup corelib autotestsJason McDonald2011-11-111-3/+2
| | | | | | | | | | | | | Tidy the autotest .pro files. Most autotest .pro files should look like this: CONFIG += testcase TARGET = tst_something QT = core testlib SOURCES = tst_something.cpp Change-Id: I877c2194e9fa9dd13478d117895e1e255a948ad7 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Cleanup corelib autotestsJason McDonald2011-11-071-6/+0
| | | | | | | Remove redundant empty constructors, destructors and test functions. Change-Id: Idb51368895e67ec3fc0345a9a5d33d77730c051b Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* corelib: eliminated usage of qttest_p4.prfRohan McGovern2011-10-251-2/+3
| | | | | | | | | qttest_p4.prf was added as a convenience for Qt's own autotests in Qt4. It enables various crufty undocumented magic, of dubious value. Stop using it, and explicitly enable the things from it which we want. Change-Id: I7c1ffe9c8c294dbdc988e1582e580b1ed3f4593e Reviewed-by: Jason McDonald <jason.mcdonald@nokia.com>
* Remove SkipMode parameter from QSKIP calls.Jason McDonald2011-10-211-1/+1
| | | | | | | | | The previous commit removed SkipMode from the testlib APi. This commit removes the parameter from all calls to QSKIP. Task-number: QTBUG-21851, QTBUG-21652 Change-Id: I21c0ee6731c1bc6ac6d962590d9b31d7459dfbc5 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>