diff options
Diffstat (limited to 'tests/auto/corelib/tools/qvector/tst_qvector.cpp')
-rw-r--r-- | tests/auto/corelib/tools/qvector/tst_qvector.cpp | 606 |
1 files changed, 192 insertions, 414 deletions
diff --git a/tests/auto/corelib/tools/qvector/tst_qvector.cpp b/tests/auto/corelib/tools/qvector/tst_qvector.cpp index 08d5a8cd50..6ae312fb8d 100644 --- a/tests/auto/corelib/tools/qvector/tst_qvector.cpp +++ b/tests/auto/corelib/tools/qvector/tst_qvector.cpp @@ -104,7 +104,7 @@ private: static void check(const State state1, const State state2) { - QCOMPARE(state1, state2); + QCOMPARE(int(state1), int(state2)); } }; @@ -174,7 +174,7 @@ private: { // check if c object has been moved QCOMPARE(c, c->that); - QCOMPARE(c->state, Constructed); + QCOMPARE(int(c->state), int(Constructed)); } }; QAtomicInt Custom::counter = 0; @@ -307,22 +307,11 @@ private slots: void reserve(); void reserveZero(); - void reallocAfterCopy_data(); - void reallocAfterCopy(); void initializeListInt(); void initializeListMovable(); void initializeListCustom(); void const_shared_null(); -#if 1 - // ### Qt6 remove this section - void setSharableInt_data(); - void setSharableInt(); - void setSharableMovable_data(); - void setSharableMovable(); - void setSharableCustom_data(); - void setSharableCustom(); -#endif void detachInt() const; void detachMovable() const; @@ -335,6 +324,18 @@ private slots: void swapItemsAt() const; + void emplaceInt(); + void emplaceCustom(); + void emplaceMovable(); + void emplaceConsistentWithStdVectorInt(); + void emplaceConsistentWithStdVectorCustom(); + void emplaceConsistentWithStdVectorMovable(); + void emplaceReturnsIterator(); + void emplaceBack(); + void emplaceBackReturnsRef(); + void emplaceWithElementFromTheSameContainer(); + void emplaceWithElementFromTheSameContainer_data(); + private: template<typename T> void copyConstructor() const; template<typename T> void add() const; @@ -358,10 +359,10 @@ private: template<typename T> void size() const; template<typename T> void swap() const; template<typename T> void initializeList(); - template<typename T> void setSharable_data() const; - template<typename T> void setSharable() const; template<typename T> void detach() const; template<typename T> void detachThreadSafety() const; + template<typename T> void emplaceImpl() const; + template<typename T> void emplaceConsistentWithStdVectorImpl() const; }; @@ -467,24 +468,6 @@ void tst_QVector::copyConstructor() const QVector<T> v2(v1); QCOMPARE(v1, v2); } -#if !defined(QT_NO_UNSHARABLE_CONTAINERS) - // ### Qt6 remove this section - { - QVector<T> v1; - v1.setSharable(false); - QVector<T> v2(v1); - QVERIFY(!v1.isSharedWith(v2)); - QCOMPARE(v1, v2); - } - { - QVector<T> v1; - v1 << value1 << value2 << value3 << value4; - v1.setSharable(false); - QVector<T> v2(v1); - QVERIFY(!v1.isSharedWith(v2)); - QCOMPARE(v1, v2); - } -#endif } void tst_QVector::copyConstructorInt() const @@ -665,17 +648,6 @@ void tst_QVector::append() const QVERIFY(v.size() == 3); QCOMPARE(v.at(v.size() - 1), SimpleValue<T>::at(0)); } -#if !defined(QT_NO_UNSHARABLE_CONTAINERS) - // ### Qt6 remove this section - { - QVector<T> v(2); - v.reserve(12); - v.setSharable(false); - v.append(SimpleValue<T>::at(0)); - QVERIFY(v.size() == 3); - QCOMPARE(v.last(), SimpleValue<T>::at(0)); - } -#endif { QVector<int> v; v << 1 << 2 << 3; @@ -766,16 +738,12 @@ void tst_QVector::capacity() const myvec.remove(3); myvec.remove(3); myvec.remove(3); - // TODO: is this a safe assumption? presumably it won't release memory until shrink(), but can we asser that is true? - QVERIFY(myvec.capacity() >= 6); myvec.squeeze(); QVERIFY(myvec.capacity() >= 3); myvec.remove(0); myvec.remove(0); myvec.remove(0); - // TODO: as above note - QVERIFY(myvec.capacity() >= 3); myvec.squeeze(); QVERIFY(myvec.capacity() == 0); } @@ -1019,20 +987,9 @@ void tst_QVector::endsWith() const template<typename T> void tst_QVector::eraseEmpty() const { - { - QVector<T> v; - v.erase(v.begin(), v.end()); - QCOMPARE(v.size(), 0); - } -#if !defined(QT_NO_UNSHARABLE_CONTAINERS) - // ### Qt6 remove this section - { - QVector<T> v; - v.setSharable(false); - v.erase(v.begin(), v.end()); - QCOMPARE(v.size(), 0); - } -#endif + QVector<T> v; + v.erase(v.begin(), v.end()); + QCOMPARE(v.size(), 0); } void tst_QVector::eraseEmptyInt() const @@ -1057,22 +1014,10 @@ void tst_QVector::eraseEmptyCustom() const template<typename T> void tst_QVector::eraseEmptyReserved() const { - { - QVector<T> v; - v.reserve(10); - v.erase(v.begin(), v.end()); - QCOMPARE(v.size(), 0); - } -#if !defined(QT_NO_UNSHARABLE_CONTAINERS) - // ### Qt6 remove this section - { - QVector<T> v; - v.reserve(10); - v.setSharable(false); - v.erase(v.begin(), v.end()); - QCOMPARE(v.size(), 0); - } -#endif + QVector<T> v; + v.reserve(10); + v.erase(v.begin(), v.end()); + QCOMPARE(v.size(), 0); } void tst_QVector::eraseEmptyReservedInt() const @@ -1179,21 +1124,6 @@ void tst_QVector::erase(bool shared) const if (shared) QCOMPARE(SimpleValue<T>::vector(12), *svc.copy); } -#if !defined(QT_NO_UNSHARABLE_CONTAINERS) - // ### Qt6 remove this section - { - QVector<T> v = SimpleValue<T>::vector(10); - SharedVectorChecker<T> svc(v, shared); - v.setSharable(false); - SharedVectorChecker<T> svc2(v, shared); - v.erase(v.begin() + 3); - QCOMPARE(v.size(), 9); - v.erase(v.begin(), v.end() - 1); - QCOMPARE(v.size(), 1); - if (shared) - QCOMPARE(SimpleValue<T>::vector(10), *svc.copy); - } -#endif } void tst_QVector::eraseInt() const @@ -1266,18 +1196,6 @@ template<typename T> void tst_QVector::eraseReserved() const v.erase(v.begin() + 1, v.end() - 1); QCOMPARE(v.size(), 2); } -#if !defined(QT_NO_UNSHARABLE_CONTAINERS) - // ### Qt6 remove this section - { - QVector<T> v(10); - v.reserve(16); - v.setSharable(false); - v.erase(v.begin() + 3); - QCOMPARE(v.size(), 9); - v.erase(v.begin(), v.end() - 1); - QCOMPARE(v.size(), 1); - } -#endif } void tst_QVector::eraseReservedInt() const @@ -2019,33 +1937,6 @@ void tst_QVector::resizePOD_data() const QTest::newRow("emptyReserved") << emptyReserved << 10; QTest::newRow("nonEmpty") << nonEmpty << 10; QTest::newRow("nonEmptyReserved") << nonEmptyReserved << 10; - -#if !defined(QT_NO_UNSHARABLE_CONTAINERS) - // ### Qt6 remove this section - QVector<int> nullNotShared; - QVector<int> emptyNotShared(0, 5); - QVector<int> emptyReservedNotShared; - QVector<int> nonEmptyNotShared; - QVector<int> nonEmptyReservedNotShared; - - emptyReservedNotShared.reserve(10); - nonEmptyReservedNotShared.reserve(15); - nonEmptyNotShared << 0 << 1 << 2 << 3 << 4; - nonEmptyReservedNotShared << 0 << 1 << 2 << 3 << 4 << 5 << 6; - QVERIFY(emptyReservedNotShared.capacity() >= 10); - QVERIFY(nonEmptyReservedNotShared.capacity() >= 15); - - emptyNotShared.setSharable(false); - emptyReservedNotShared.setSharable(false); - nonEmptyNotShared.setSharable(false); - nonEmptyReservedNotShared.setSharable(false); - - QTest::newRow("nullNotShared") << nullNotShared << 10; - QTest::newRow("emptyNotShared") << emptyNotShared << 10; - QTest::newRow("emptyReservedNotShared") << emptyReservedNotShared << 10; - QTest::newRow("nonEmptyNotShared") << nonEmptyNotShared << 10; - QTest::newRow("nonEmptyReservedNotShared") << nonEmptyReservedNotShared << 10; -#endif } void tst_QVector::resizePOD() const @@ -2094,33 +1985,6 @@ void tst_QVector::resizeComplexMovable_data() const QTest::newRow("emptyReserved") << emptyReserved << 10; QTest::newRow("nonEmpty") << nonEmpty << 10; QTest::newRow("nonEmptyReserved") << nonEmptyReserved << 10; - -#if !defined(QT_NO_UNSHARABLE_CONTAINERS) - // ### Qt6 remove this section - QVector<Movable> nullNotShared; - QVector<Movable> emptyNotShared(0, 'Q'); - QVector<Movable> emptyReservedNotShared; - QVector<Movable> nonEmptyNotShared; - QVector<Movable> nonEmptyReservedNotShared; - - emptyReservedNotShared.reserve(10); - nonEmptyReservedNotShared.reserve(15); - nonEmptyNotShared << '0' << '1' << '2' << '3' << '4'; - nonEmptyReservedNotShared << '0' << '1' << '2' << '3' << '4' << '5' << '6'; - QVERIFY(emptyReservedNotShared.capacity() >= 10); - QVERIFY(nonEmptyReservedNotShared.capacity() >= 15); - - emptyNotShared.setSharable(false); - emptyReservedNotShared.setSharable(false); - nonEmptyNotShared.setSharable(false); - nonEmptyReservedNotShared.setSharable(false); - - QTest::newRow("nullNotShared") << nullNotShared << 10; - QTest::newRow("emptyNotShared") << emptyNotShared << 10; - QTest::newRow("emptyReservedNotShared") << emptyReservedNotShared << 10; - QTest::newRow("nonEmptyNotShared") << nonEmptyNotShared << 10; - QTest::newRow("nonEmptyReservedNotShared") << nonEmptyReservedNotShared << 10; -#endif } void tst_QVector::resizeComplexMovable() const @@ -2173,33 +2037,6 @@ void tst_QVector::resizeComplex_data() const QTest::newRow("emptyReserved") << emptyReserved << 10; QTest::newRow("nonEmpty") << nonEmpty << 10; QTest::newRow("nonEmptyReserved") << nonEmptyReserved << 10; - -#if !defined(QT_NO_UNSHARABLE_CONTAINERS) - // ### Qt6 remove this section - QVector<Custom> nullNotShared; - QVector<Custom> emptyNotShared(0, '0'); - QVector<Custom> emptyReservedNotShared; - QVector<Custom> nonEmptyNotShared; - QVector<Custom> nonEmptyReservedNotShared; - - emptyReservedNotShared.reserve(10); - nonEmptyReservedNotShared.reserve(15); - nonEmptyNotShared << '0' << '1' << '2' << '3' << '4'; - nonEmptyReservedNotShared << '0' << '1' << '2' << '3' << '4' << '5' << '6'; - QVERIFY(emptyReservedNotShared.capacity() >= 10); - QVERIFY(nonEmptyReservedNotShared.capacity() >= 15); - - emptyNotShared.setSharable(false); - emptyReservedNotShared.setSharable(false); - nonEmptyNotShared.setSharable(false); - nonEmptyReservedNotShared.setSharable(false); - - QTest::newRow("nullNotShared") << nullNotShared << 10; - QTest::newRow("emptyNotShared") << emptyNotShared << 10; - QTest::newRow("emptyReservedNotShared") << emptyReservedNotShared << 10; - QTest::newRow("nonEmptyNotShared") << nonEmptyNotShared << 10; - QTest::newRow("nonEmptyReservedNotShared") << nonEmptyReservedNotShared << 10; -#endif } void tst_QVector::resizeComplex() const @@ -2512,87 +2349,6 @@ void tst_QVector::reserveZero() QVERIFY(vec.capacity() >= 1); } -// This is a regression test for QTBUG-11763, where memory would be reallocated -// soon after copying a QVector. -void tst_QVector::reallocAfterCopy_data() -{ - QTest::addColumn<int>("capacity"); - QTest::addColumn<int>("fill_size"); - QTest::addColumn<int>("func_id"); - QTest::addColumn<int>("result1"); - QTest::addColumn<int>("result2"); - QTest::addColumn<int>("result3"); - QTest::addColumn<int>("result4"); - - int result1, result2, result3, result4; - int fill_size; - for (int i = 70; i <= 100; i += 10) { - const QByteArray prefix = "reallocAfterCopy:" + QByteArray::number(i) + ','; - fill_size = i - 20; - for (int j = 0; j <= 3; j++) { - if (j == 0) { // append - result1 = i; - result2 = i; - result3 = i - 19; - result4 = i - 20; - } else if (j == 1) { // insert(0) - result1 = i; - result2 = i; - result3 = i - 19; - result4 = i - 20; - } else if (j == 2) { // insert(20) - result1 = i; - result2 = i; - result3 = i - 19; - result4 = i - 20; - } else if (j == 3) { // insert(0, 10) - result1 = i; - result2 = i; - result3 = i - 10; - result4 = i - 20; - } - QTest::newRow((prefix + QByteArray::number(j)).constData()) - << i << fill_size << j << result1 << result2 << result3 << result4; - } - } -} - -void tst_QVector::reallocAfterCopy() -{ - QFETCH(int, capacity); - QFETCH(int, fill_size); - QFETCH(int, func_id); - QFETCH(int, result1); - QFETCH(int, result2); - QFETCH(int, result3); - QFETCH(int, result4); - - QVector<qreal> v1; - QVector<qreal> v2; - - v1.reserve(capacity); - v1.resize(0); - v1.fill(qreal(1.0), fill_size); - - v2 = v1; - - // no need to test begin() and end(), there is a detach() in them - if (func_id == 0) { - v1.append(qreal(1.0)); //push_back is same as append - } else if (func_id == 1) { - v1.insert(0, qreal(1.0)); //push_front is same as prepend, insert(0) - } else if (func_id == 2) { - v1.insert(20, qreal(1.0)); - } else if (func_id == 3) { - v1.insert(0, 10, qreal(1.0)); - } - - QCOMPARE(v1.capacity(), result1); - QCOMPARE(v2.capacity(), result2); - QCOMPARE(v1.size(), result3); - QCOMPARE(v2.size(), result4); -} - template<typename T> void tst_QVector::initializeList() { @@ -2636,154 +2392,9 @@ void tst_QVector::initializeListCustom() void tst_QVector::const_shared_null() { QVector<int> v2; -#if !defined(QT_NO_UNSHARABLE_CONTAINERS) - // ### Qt6 remove this section - QVector<int> v1; - v1.setSharable(false); - QVERIFY(v1.isDetached()); - - v2.setSharable(true); -#endif QVERIFY(!v2.isDetached()); } -#if !defined(QT_NO_UNSHARABLE_CONTAINERS) -// ### Qt6 remove this section -template<typename T> -void tst_QVector::setSharable_data() const -{ - QTest::addColumn<QVector<T> >("vector"); - QTest::addColumn<int>("size"); - QTest::addColumn<int>("capacity"); - QTest::addColumn<bool>("isCapacityReserved"); - - QVector<T> null; - QVector<T> empty(0, SimpleValue<T>::at(1)); - QVector<T> emptyReserved; - QVector<T> nonEmpty; - QVector<T> nonEmptyReserved; - - emptyReserved.reserve(10); - nonEmptyReserved.reserve(15); - - nonEmpty << SimpleValue<T>::at(0) << SimpleValue<T>::at(1) << SimpleValue<T>::at(2) << SimpleValue<T>::at(3) << SimpleValue<T>::at(4); - nonEmptyReserved << SimpleValue<T>::at(0) << SimpleValue<T>::at(1) << SimpleValue<T>::at(2) << SimpleValue<T>::at(3) << SimpleValue<T>::at(4) << SimpleValue<T>::at(5) << SimpleValue<T>::at(6); - - QVERIFY(emptyReserved.capacity() >= 10); - QVERIFY(nonEmptyReserved.capacity() >= 15); - - QTest::newRow("null") << null << 0 << 0 << false; - QTest::newRow("empty") << empty << 0 << 0 << false; - QTest::newRow("empty, Reserved") << emptyReserved << 0 << 10 << true; - QTest::newRow("non-empty") << nonEmpty << 5 << 0 << false; - QTest::newRow("non-empty, Reserved") << nonEmptyReserved << 7 << 15 << true; -} - -template<typename T> -void tst_QVector::setSharable() const -{ - QFETCH(QVector<T>, vector); - QFETCH(int, size); - QFETCH(int, capacity); - QFETCH(bool, isCapacityReserved); - - QVERIFY(!vector.isDetached()); // Shared with QTest - - vector.setSharable(true); - - QCOMPARE(vector.size(), size); - if (isCapacityReserved) - QVERIFY2(vector.capacity() >= capacity, - qPrintable(QString("Capacity is %1, expected at least %2.") - .arg(vector.capacity()) - .arg(capacity))); - - { - QVector<T> copy(vector); - - QVERIFY(!copy.isDetached()); - QVERIFY(copy.isSharedWith(vector)); - } - - vector.setSharable(false); - QVERIFY(vector.isDetached() || vector.isSharedWith(QVector<T>())); - - { - QVector<T> copy(vector); - - QVERIFY(copy.isDetached() || copy.isEmpty() || copy.isSharedWith(QVector<T>())); - QCOMPARE(copy.size(), size); - if (isCapacityReserved) - QVERIFY2(copy.capacity() >= capacity, - qPrintable(QString("Capacity is %1, expected at least %2.") - .arg(copy.capacity()) - .arg(capacity))); - QCOMPARE(copy, vector); - } - - vector.setSharable(true); - - { - QVector<T> copy(vector); - - QVERIFY(!copy.isDetached()); - QVERIFY(copy.isSharedWith(vector)); - } - - for (int i = 0; i < vector.size(); ++i) - QCOMPARE(vector[i], SimpleValue<T>::at(i)); - - QCOMPARE(vector.size(), size); - if (isCapacityReserved) - QVERIFY2(vector.capacity() >= capacity, - qPrintable(QString("Capacity is %1, expected at least %2.") - .arg(vector.capacity()) - .arg(capacity))); -} -#else -template<typename T> void tst_QVector::setSharable_data() const -{ -} - -template<typename T> void tst_QVector::setSharable() const -{ -} -#endif - -void tst_QVector::setSharableInt_data() -{ - setSharable_data<int>(); -} - -void tst_QVector::setSharableMovable_data() -{ - setSharable_data<Movable>(); -} - -void tst_QVector::setSharableCustom_data() -{ - setSharable_data<Custom>(); -} - -void tst_QVector::setSharableInt() -{ - setSharable<int>(); -} - -void tst_QVector::setSharableMovable() -{ - const int instancesCount = Movable::counter.loadAcquire(); - setSharable<Movable>(); - QCOMPARE(instancesCount, Movable::counter.loadAcquire()); -} - -void tst_QVector::setSharableCustom() -{ - const int instancesCount = Custom::counter.loadAcquire(); - setSharable<Custom>(); - QCOMPARE(instancesCount, Custom::counter.loadAcquire()); -} - template<typename T> void tst_QVector::detach() const { @@ -2791,7 +2402,7 @@ void tst_QVector::detach() const // detach an empty vector QVector<T> v; v.detach(); - QVERIFY(v.isDetached()); + QVERIFY(!v.isDetached()); QCOMPARE(v.size(), 0); QCOMPARE(v.capacity(), 0); } @@ -2801,7 +2412,7 @@ void tst_QVector::detach() const QVector<T> ref(v); QVERIFY(!v.isDetached()); v.detach(); - QVERIFY(v.isDetached()); + QVERIFY(!v.isDetached()); QCOMPARE(v.size(), 0); QCOMPARE(v.capacity(), 0); } @@ -3048,5 +2659,172 @@ void tst_QVector::swapItemsAt() const QCOMPARE(copy.at(2), 2); } +void tst_QVector::emplaceInt() +{ + emplaceImpl<int>(); +} + +void tst_QVector::emplaceCustom() +{ + emplaceImpl<Custom>(); +} + +void tst_QVector::emplaceMovable() +{ + emplaceImpl<Movable>(); +} + +void tst_QVector::emplaceConsistentWithStdVectorInt() +{ + emplaceConsistentWithStdVectorImpl<int>(); +} + +void tst_QVector::emplaceConsistentWithStdVectorCustom() +{ + emplaceConsistentWithStdVectorImpl<Custom>(); +} + +void tst_QVector::emplaceConsistentWithStdVectorMovable() +{ + emplaceConsistentWithStdVectorImpl<Movable>(); +} + +void tst_QVector::emplaceReturnsIterator() +{ + QVector<Movable> vec; + + vec.emplace(0, 'k')->i = 'p'; + + QCOMPARE(vec[0].i, 'p'); +} + +void tst_QVector::emplaceBack() +{ + QScopedValueRollback<QAtomicInt> rollback(Movable::counter, 0); + + QVector<Movable> vec; + + vec.emplaceBack('k'); + + QCOMPARE(Movable::counter, 1); +} + +void tst_QVector::emplaceBackReturnsRef() +{ + QVector<Movable> vec; + + vec.emplaceBack('k').i = 'p'; + + QCOMPARE(vec.at(0).i, 'p'); +} + +void tst_QVector::emplaceWithElementFromTheSameContainer() +{ + QFETCH(int, elementPos); + QFETCH(int, insertPos); + QFETCH(bool, doCopy); + + QVector<QString> vec {"a", "b", "c", "d", "e"}; + const QString e = vec[elementPos]; + + if (doCopy) + vec.emplace(insertPos, vec[elementPos]); + else + vec.emplace(insertPos, std::move(vec[elementPos])); + + QCOMPARE(vec[insertPos], e); +} + +void tst_QVector::emplaceWithElementFromTheSameContainer_data() +{ + QTest::addColumn<int>("elementPos"); + QTest::addColumn<int>("insertPos"); + QTest::addColumn<bool>("doCopy"); + + for (int i = 0; i < 2; ++i) { + const bool doCopy = i == 0; + const char *opName = doCopy ? "copy" : "move"; + + QTest::addRow("%s: begin -> end" , opName) << 0 << 5 << doCopy; + QTest::addRow("%s: begin -> middle", opName) << 0 << 2 << doCopy; + QTest::addRow("%s: middle -> begin" , opName) << 2 << 0 << doCopy; + QTest::addRow("%s: middle -> end" , opName) << 2 << 5 << doCopy; + QTest::addRow("%s: end -> middle", opName) << 4 << 2 << doCopy; + QTest::addRow("%s: end -> begin" , opName) << 4 << 0 << doCopy; + } +} + +template<typename T> +void tst_QVector::emplaceImpl() const +{ + QVector<T> vec {'a', 'b', 'c', 'd'}; + + vec.emplace(2, 'k'); + + QCOMPARE(vec[2], T('k')); +} + +template <class T> +static void vecEq(const QVector<T> &qVec, const std::vector<T> &stdVec) +{ + QCOMPARE(std::size_t(qVec.size()), stdVec.size()); + QVERIFY(std::equal(qVec.begin(), qVec.end(), stdVec.begin(), stdVec.end())); +} + +template <class T> +static void squeezeVec(QVector<T> &qVec, std::vector<T> &stdVec) +{ + qVec.squeeze(); + stdVec.shrink_to_fit(); +} + +template<typename T> +void tst_QVector::emplaceConsistentWithStdVectorImpl() const +{ + QVector<T> qVec {'a', 'b', 'c', 'd', 'e'}; + std::vector<T> stdVec {'a', 'b', 'c', 'd', 'e'}; + vecEq(qVec, stdVec); + + qVec.emplaceBack('f'); + stdVec.emplace_back('f'); + vecEq(qVec, stdVec); + + qVec.emplace(3, 'g'); + stdVec.emplace(stdVec.begin() + 3, 'g'); + vecEq(qVec, stdVec); + + qVec.emplaceBack(std::move(qVec[0])); + stdVec.emplace_back(std::move(stdVec[0])); + vecEq(qVec, stdVec); + + squeezeVec(qVec, stdVec); + + qVec.emplaceBack(std::move(qVec[1])); + stdVec.emplace_back(std::move(stdVec[1])); + vecEq(qVec, stdVec); + + squeezeVec(qVec, stdVec); + + qVec.emplace(3, std::move(qVec[5])); + stdVec.emplace(stdVec.begin() + 3, std::move(stdVec[5])); + vecEq(qVec, stdVec); + + qVec.emplaceBack(qVec[3]); + stdVec.emplace_back(stdVec[3]); + vecEq(qVec, stdVec); + + squeezeVec(qVec, stdVec); + + qVec.emplaceBack(qVec[4]); + stdVec.emplace_back(stdVec[4]); + vecEq(qVec, stdVec); + + squeezeVec(qVec, stdVec); + + qVec.emplace(5, qVec[7]); + stdVec.emplace(stdVec.begin() + 5, stdVec[7]); + vecEq(qVec, stdVec); +} + QTEST_MAIN(tst_QVector) #include "tst_qvector.moc" |