class QScopedArrayPointer : public QScopedPointer<T, Cleanup>
{
public:
+ inline QScopedArrayPointer() : QScopedPointer<T, Cleanup>(0) {}
+
template <typename D>
- explicit inline QScopedArrayPointer(D *p = 0, typename QtPrivate::QScopedArrayEnsureSameType<T,D>::Type = 0)
+ explicit inline QScopedArrayPointer(D *p, typename QtPrivate::QScopedArrayEnsureSameType<T,D>::Type = 0)
: QScopedPointer<T, Cleanup>(p)
{
}
void isNullSignature();
void objectSize();
void comparison();
+ void array();
// TODO instanciate on const object
};
QCOMPARE( int(RefCounted::instanceCount), 0 );
}
+void tst_QScopedPointer::array()
+{
+ int instCount = RefCounted::instanceCount;
+ {
+ QScopedArrayPointer<RefCounted> array;
+ array.reset(new RefCounted[42]);
+ QCOMPARE(instCount + 42, int(RefCounted::instanceCount));
+ }
+ QCOMPARE(instCount, int(RefCounted::instanceCount));
+ {
+ QScopedArrayPointer<RefCounted> 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"