diff options
author | Marc Mutz <marc.mutz@qt.io> | 2021-12-07 11:53:57 +0100 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2021-12-07 22:53:14 +0100 |
commit | cb00db5a7e644d381ec58f7b715e0312c57f282a (patch) | |
tree | 35d5055c1123a13c778ccade9b54f5ece84b670d /tests/auto | |
parent | adcc68fd599d976dd79ad034b93e150138039681 (diff) |
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>
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp b/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp index 1d30ca3d03..3631f4f977 100644 --- a/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp +++ b/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp @@ -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; |