diff options
author | Sérgio Martins <sergio.martins@kdab.com> | 2015-06-15 20:02:20 +0100 |
---|---|---|
committer | Sérgio Martins <sergio.martins@kdab.com> | 2015-07-08 14:22:44 +0000 |
commit | f61de80e1f11cea088faf946fc59999936090661 (patch) | |
tree | 0f01b3592389ca35cdc3b7baada6a3d06f229758 /tests | |
parent | 61a0656eb4149fe793854d703521bf2df48f8f7a (diff) |
QVarLengthArray: Unit-test that clear() preserves capacity
Change-Id: Ib2b798b93ce9a1b77bca09b2a8c27a568ebf8670
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp b/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp index 5d12cd9804..94d81e0a5a 100644 --- a/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp +++ b/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp @@ -54,6 +54,7 @@ private slots: void indexOf(); void lastIndexOf(); void contains(); + void clear(); void initializeListInt(); void initializeListMovable(); void initializeListComplex(); @@ -752,6 +753,21 @@ void tst_QVarLengthArray::contains() QVERIFY(myvec.contains(QLatin1String("I don't exist"))); } +void tst_QVarLengthArray::clear() +{ + QVarLengthArray<QString, 5> myvec; + + for (int i = 0; i < 10; ++i) + myvec << "aaa"; + + QCOMPARE(myvec.size(), 10); + QVERIFY(myvec.capacity() >= myvec.size()); + const int oldCapacity = myvec.capacity(); + myvec.clear(); + QCOMPARE(myvec.size(), 0); + QCOMPARE(myvec.capacity(), oldCapacity); +} + void tst_QVarLengthArray::initializeListInt() { initializeList<int>(); |