QVarLengthArray: add some basic checks for default-ctor
There seems to have been no-one that checked a simple empty()/isEmpty()... Pick-to: 6.2 5.15 Change-Id: I7fa567f556532dfa21db759719f1303a768a9732 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
parent
adcc68fd59
commit
cb00db5a7e
@ -68,6 +68,8 @@ class tst_QVarLengthArray : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
private slots:
|
||||
void defaultConstructor_int() { defaultConstructor<int>(); }
|
||||
void defaultConstructor_QString() { defaultConstructor<QString>(); }
|
||||
void append();
|
||||
void prepend();
|
||||
void emplace();
|
||||
@ -112,6 +114,8 @@ private slots:
|
||||
void erase();
|
||||
|
||||
private:
|
||||
template <typename T>
|
||||
void defaultConstructor();
|
||||
template <qsizetype N, typename T>
|
||||
void move(T t1, T t2);
|
||||
template <qsizetype N>
|
||||
@ -124,6 +128,23 @@ private:
|
||||
void initializeList();
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
void tst_QVarLengthArray::defaultConstructor()
|
||||
{
|
||||
{
|
||||
QVarLengthArray<T, 123> vla;
|
||||
QCOMPARE(vla.size(), 0);
|
||||
QVERIFY(vla.empty());
|
||||
QVERIFY(vla.isEmpty());
|
||||
QCOMPARE(vla.begin(), vla.end());
|
||||
QCOMPARE(vla.capacity(), 123);
|
||||
}
|
||||
{
|
||||
QVarLengthArray<T> vla;
|
||||
QCOMPARE(vla.capacity(), 256); // notice, should we change the default
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QVarLengthArray::append()
|
||||
{
|
||||
QVarLengthArray<QString, 2> v;
|
||||
|
Loading…
x
Reference in New Issue
Block a user