From cb00db5a7e644d381ec58f7b715e0312c57f282a Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 7 Dec 2021 11:53:57 +0100 Subject: QVarLengthArray: add some basic checks for default-ctor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: MÃ¥rten Nordheim --- .../tools/qvarlengtharray/tst_qvarlengtharray.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'tests/auto') 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(); } + void defaultConstructor_QString() { defaultConstructor(); } void append(); void prepend(); void emplace(); @@ -112,6 +114,8 @@ private slots: void erase(); private: + template + void defaultConstructor(); template void move(T t1, T t2); template @@ -124,6 +128,23 @@ private: void initializeList(); }; +template +void tst_QVarLengthArray::defaultConstructor() +{ + { + QVarLengthArray vla; + QCOMPARE(vla.size(), 0); + QVERIFY(vla.empty()); + QVERIFY(vla.isEmpty()); + QCOMPARE(vla.begin(), vla.end()); + QCOMPARE(vla.capacity(), 123); + } + { + QVarLengthArray vla; + QCOMPARE(vla.capacity(), 256); // notice, should we change the default + } +} + void tst_QVarLengthArray::append() { QVarLengthArray v; -- cgit v1.2.3