From 84c10500b1730e8d947732728d190fde612fc840 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 8 Oct 2013 13:17:52 +0200 Subject: QVector: add removeOne(), removeAll() for QList compatibility Eases migration from QList to QVector. [ChangeLog][QtCore][QVector] Added removeOne(), removeAll() for QList compatibility. Change-Id: I4211afb2e077c187d0a39f0ac4528f0c66721fb3 Reviewed-by: Olivier Goffart --- tests/auto/corelib/tools/qvector/tst_qvector.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'tests/auto/corelib/tools') diff --git a/tests/auto/corelib/tools/qvector/tst_qvector.cpp b/tests/auto/corelib/tools/qvector/tst_qvector.cpp index e1e65a77c8..bd0ed06382 100644 --- a/tests/auto/corelib/tools/qvector/tst_qvector.cpp +++ b/tests/auto/corelib/tools/qvector/tst_qvector.cpp @@ -1423,13 +1423,28 @@ void tst_QVector::remove() const T val1 = SimpleValue::at(1); T val2 = SimpleValue::at(2); T val3 = SimpleValue::at(3); + T val4 = SimpleValue::at(4); + myvec << val1 << val2 << val3; + myvec << val1 << val2 << val3; myvec << val1 << val2 << val3; // remove middle myvec.remove(1); - QCOMPARE(myvec, QVector() << val1 << val3); + QCOMPARE(myvec, QVector() << val1 << val3 << val1 << val2 << val3 << val1 << val2 << val3); + + // removeOne() + QVERIFY(!myvec.removeOne(val4)); + QVERIFY(myvec.removeOne(val2)); + QCOMPARE(myvec, QVector() << val1 << val3 << val1 << val3 << val1 << val2 << val3); + + // removeAll() + QCOMPARE(myvec.removeAll(val4), 0); + QCOMPARE(myvec.removeAll(val1), 3); + QCOMPARE(myvec, QVector() << val3 << val3 << val2 << val3); + QCOMPARE(myvec.removeAll(val2), 1); + QCOMPARE(myvec, QVector() << val3 << val3 << val3); // remove rest - myvec.remove(0, 2); + myvec.remove(0, 3); QCOMPARE(myvec, QVector()); } -- cgit v1.2.3