From d789e40c58c1ce8441d3bb4d6ca8d01fe02ad1a7 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 5 Jul 2011 14:06:01 +0200 Subject: Fix QScopedPointerarray default constructor Since the compiler cannod find the template argument if there is no argument passed to the constructor, this effectively means there is no default constructor. Add a default constructor Task-number: QTBUG-20256 Change-Id: I310d5e1f3f94a8fe69fd3a5c46f2f51bca60facd Reviewed-on: http://codereview.qt.nokia.com/1165 Reviewed-by: Qt Sanity Bot Reviewed-by: Denis Dzyubenko --- tests/auto/qscopedpointer/tst_qscopedpointer.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'tests') diff --git a/tests/auto/qscopedpointer/tst_qscopedpointer.cpp b/tests/auto/qscopedpointer/tst_qscopedpointer.cpp index 1a6f944965..06c0ecbafd 100644 --- a/tests/auto/qscopedpointer/tst_qscopedpointer.cpp +++ b/tests/auto/qscopedpointer/tst_qscopedpointer.cpp @@ -72,6 +72,7 @@ private Q_SLOTS: void isNullSignature(); void objectSize(); void comparison(); + void array(); // TODO instanciate on const object }; @@ -437,5 +438,26 @@ void tst_QScopedPointer::comparison() QCOMPARE( int(RefCounted::instanceCount), 0 ); } +void tst_QScopedPointer::array() +{ + int instCount = RefCounted::instanceCount; + { + QScopedArrayPointer array; + array.reset(new RefCounted[42]); + QCOMPARE(instCount + 42, int(RefCounted::instanceCount)); + } + QCOMPARE(instCount, int(RefCounted::instanceCount)); + { + QScopedArrayPointer array(new RefCounted[42]); + QCOMPARE(instCount + 42, int(RefCounted::instanceCount)); + array.reset(new RefCounted[28]); + QCOMPARE(instCount + 28, int(RefCounted::instanceCount)); + array.reset(0); + QCOMPARE(instCount, int(RefCounted::instanceCount)); + } + QCOMPARE(instCount, int(RefCounted::instanceCount)); +} + + QTEST_MAIN(tst_QScopedPointer) #include "tst_qscopedpointer.moc" -- cgit v1.2.3