summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp')
-rw-r--r--tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp
index d5a628889c..346ce6fcf9 100644
--- a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp
+++ b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp
@@ -2355,6 +2355,24 @@ void tst_QSharedPointer::sharedFromThis()
QCOMPARE(Data::generationCounter, generations + 4);
QCOMPARE(Data::destructorCounter, destructions + 4);
+ {
+ QSharedPointer<SomeClass> scp2 = QSharedPointer<SomeClass>::create();
+ QVERIFY(!scp2.isNull());
+
+ scp = scp2->sharedFromThis();
+ QVERIFY(!scp.isNull());
+
+ QVERIFY(scp == scp2);
+ QCOMPARE(Data::generationCounter, generations + 5);
+ QCOMPARE(Data::destructorCounter, destructions + 4);
+ }
+ QCOMPARE(Data::generationCounter, generations + 5);
+ QCOMPARE(Data::destructorCounter, destructions + 4);
+
+ scp.clear();
+
+ QCOMPARE(Data::generationCounter, generations + 5);
+ QCOMPARE(Data::destructorCounter, destructions + 5);
}
namespace ReentrancyWhileDestructing {