QVarLengthArray: Unit-test that clear() preserves capacity

Change-Id: Ib2b798b93ce9a1b77bca09b2a8c27a568ebf8670
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
This commit is contained in:
Sérgio Martins 2015-06-15 20:02:20 +01:00
parent 61a0656eb4
commit f61de80e1f

View File

@ -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>();