From 982ef5b494319bfaaa585cf0620a821dc3b7c642 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Tue, 3 May 2016 23:19:49 +0200 Subject: QSharedPointer/QWeakPointer/QScopedPointer: add comparison against nullptr Some constructors were added, but the comparison operators were missing. The STL has them, so we ought have them too. Change-Id: I030c14a3b355988f509716b4b1b1a835b3ab9481 Reviewed-by: Marc Mutz --- .../tools/qsharedpointer/tst_qsharedpointer.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'tests/auto/corelib/tools/qsharedpointer') diff --git a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp index 7998f7b7fd..1bba41816b 100644 --- a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp +++ b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp @@ -371,12 +371,22 @@ void tst_QSharedPointer::nullptrOps() QSharedPointer null; QVERIFY(p1 == null); - QVERIFY(p2 == null); + QVERIFY(p1 == nullptr); + QVERIFY(nullptr == p1); + QVERIFY(!p1); QVERIFY(!p1.data()); + QVERIFY(p2 == null); + QVERIFY(p2 == nullptr); + QVERIFY(nullptr == p2); + QVERIFY(!p2); QVERIFY(!p2.data()); + QVERIFY(p1 == p2); QSharedPointer p3 = p1; + QVERIFY(p3 == p1); QVERIFY(p3 == null); + QVERIFY(p3 == nullptr); + QVERIFY(nullptr == p3); QVERIFY(!p3.data()); p3 = nullptr; @@ -386,6 +396,16 @@ void tst_QSharedPointer::nullptrOps() QSharedPointer p2_zero = 0; p3 = 0; + + QSharedPointer p4(new char); + QVERIFY(p4); + QVERIFY(p4.data()); + QVERIFY(p4 != nullptr); + QVERIFY(nullptr != p4); + QVERIFY(p4 != p1); + QVERIFY(p4 != p2); + QVERIFY(p4 != null); + QVERIFY(p4 != p3); } void tst_QSharedPointer::swap() -- cgit v1.2.3