diff options
author | Jason McDonald <jason.mcdonald@nokia.com> | 2011-04-06 02:12:45 (GMT) |
---|---|---|
committer | Jason McDonald <jason.mcdonald@nokia.com> | 2011-04-06 02:12:45 (GMT) |
commit | d894a4720d652f11cdc791b5f556bd8b29845667 (patch) | |
tree | ce20d19e9e31b9fad80e05bac1d79e31220db060 | |
parent | fca618cb287a312a1159ce785947f19db4bc5fba (diff) | |
download | Qt-d894a4720d652f11cdc791b5f556bd8b29845667.zip Qt-d894a4720d652f11cdc791b5f556bd8b29845667.tar.gz Qt-d894a4720d652f11cdc791b5f556bd8b29845667.tar.bz2 |
Refactor qpointer dereference tests
The data method is just another way of dereferencing a QPointer, so test
it in the same place as the other dereference operators.
Reviewed-by: Rohan McGovern
-rw-r--r-- | tests/auto/qpointer/tst_qpointer.cpp | 29 |
1 files changed, 10 insertions, 19 deletions
diff --git a/tests/auto/qpointer/tst_qpointer.cpp b/tests/auto/qpointer/tst_qpointer.cpp index 9f2c0da..0fb4610 100644 --- a/tests/auto/qpointer/tst_qpointer.cpp +++ b/tests/auto/qpointer/tst_qpointer.cpp @@ -60,7 +60,6 @@ private slots: void dereference_operators(); void disconnect(); void castDuringDestruction(); - void data() const; void dataSignature() const; void threadSafety(); }; @@ -183,15 +182,23 @@ void tst_QPointer::isNull() void tst_QPointer::dereference_operators() { QPointer<tst_QPointer> p1 = this; + QPointer<tst_QPointer> p2; + // operator->() -- only makes sense if not null QObject *object = p1->me(); QCOMPARE(object, this); + // operator*() -- only makes sense if not null QObject &ref = *p1; QCOMPARE(&ref, this); - object = static_cast<QObject *>(p1); - QCOMPARE(object, this); + // operator T*() + QCOMPARE(static_cast<QObject *>(p1), this); + QCOMPARE(static_cast<QObject *>(p2), static_cast<QObject *>(0)); + + // data() + QCOMPARE(p1.data(), this); + QCOMPARE(p2.data(), static_cast<QObject *>(0)); } void tst_QPointer::disconnect() @@ -302,22 +309,6 @@ void tst_QPointer::castDuringDestruction() } } -void tst_QPointer::data() const -{ - /* Check value of a default constructed object. */ - { - QPointer<QObject> p; - QCOMPARE(p.data(), static_cast<QObject *>(0)); - } - - /* Check value of a default constructed object. */ - { - QObject *const object = new QObject(); - QPointer<QObject> p(object); - QCOMPARE(p.data(), object); - } -} - void tst_QPointer::dataSignature() const { /* data() should be const. */ |