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-08 17:16:04 +0000 |
commit | f15877d2731f94bb02738ff2fd162d0d77d96a21 (patch) | |
tree | dadd15c4f4dc34ec27c87671e423a1ff4d8dbaec | |
parent | ffbdd729358ab377e6c840e51d4ad6bb1d4d2bb5 (diff) |
QVarLengthArray: add some basic checks for default-ctor
There seems to have been no-one that checked a simple empty()/isEmpty()...
Change-Id: I7fa567f556532dfa21db759719f1303a768a9732
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
(cherry picked from commit cb00db5a7e644d381ec58f7b715e0312c57f282a)
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
-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 5443cf120b..6860fc59ee 100644 --- a/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp +++ b/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp @@ -36,6 +36,8 @@ class tst_QVarLengthArray : public QObject { Q_OBJECT private slots: + void defaultConstructor_int() { defaultConstructor<int>(); } + void defaultConstructor_QString() { defaultConstructor<QString>(); } void append(); void removeLast(); void oldTests(); @@ -61,6 +63,8 @@ private slots: void implicitDefaultCtor(); private: + template <typename T> + void defaultConstructor(); template<typename T> void initializeList(); }; @@ -80,6 +84,23 @@ struct Tracker int Tracker::count = 0; +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; |