diff options
author | Thorbjørn Martsum <tmartsum@gmail.com> | 2013-02-16 20:20:35 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-03-07 06:13:06 +0100 |
commit | ab52e722926d495e29263e59a466ad5ff0106275 (patch) | |
tree | 75bb1f0b3e408b20f944b325b6c55141eb2829cd /tests | |
parent | 510660080de6fab87e117de2663c33eff5ae451b (diff) |
QVector - add functions takeFirst and takeLast
This patch adds takeFirst and takeLast which are functions
that QList also has.
Change-Id: I761f90b529774edc8fa96e07c6fcf76226123b20
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/corelib/tools/qvector/tst_qvector.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/tests/auto/corelib/tools/qvector/tst_qvector.cpp b/tests/auto/corelib/tools/qvector/tst_qvector.cpp index 3acd5ddb10..99fbb9cf98 100644 --- a/tests/auto/corelib/tools/qvector/tst_qvector.cpp +++ b/tests/auto/corelib/tools/qvector/tst_qvector.cpp @@ -1410,11 +1410,12 @@ struct RemoveLastTestClass void tst_QVector::removeFirstLast() const { // pop_pack - pop_front - QVector<int> t; + QVector<int> t, t2; t.append(1); t.append(2); t.append(3); t.append(4); + t2 = t; t.pop_front(); QCOMPARE(t.size(), 3); QCOMPARE(t.at(0), 2); @@ -1423,6 +1424,18 @@ void tst_QVector::removeFirstLast() const QCOMPARE(t.at(0), 2); QCOMPARE(t.at(1), 3); + // takefirst - takeLast + int n1 = t2.takeLast(); + QCOMPARE(t2.size(), 3); + QCOMPARE(n1, 4); + QCOMPARE(t2.at(0), 1); + QCOMPARE(t2.at(2), 3); + n1 = t2.takeFirst(); + QCOMPARE(t2.size(), 2); + QCOMPARE(n1, 1); + QCOMPARE(t2.at(0), 2); + QCOMPARE(t2.at(1), 3); + // remove first QVector<int> x, y; x.append(1); |