QVarLengthArray: Unit-test that clear() preserves capacity
Change-Id: Ib2b798b93ce9a1b77bca09b2a8c27a568ebf8670 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
This commit is contained in:
parent
61a0656eb4
commit
f61de80e1f
@ -54,6 +54,7 @@ private slots:
|
|||||||
void indexOf();
|
void indexOf();
|
||||||
void lastIndexOf();
|
void lastIndexOf();
|
||||||
void contains();
|
void contains();
|
||||||
|
void clear();
|
||||||
void initializeListInt();
|
void initializeListInt();
|
||||||
void initializeListMovable();
|
void initializeListMovable();
|
||||||
void initializeListComplex();
|
void initializeListComplex();
|
||||||
@ -752,6 +753,21 @@ void tst_QVarLengthArray::contains()
|
|||||||
QVERIFY(myvec.contains(QLatin1String("I don't exist")));
|
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()
|
void tst_QVarLengthArray::initializeListInt()
|
||||||
{
|
{
|
||||||
initializeList<int>();
|
initializeList<int>();
|
||||||
|
Loading…
Reference in New Issue
Block a user