summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qscopedpointer/tst_qscopedpointer.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/auto/qscopedpointer/tst_qscopedpointer.cpp b/tests/auto/qscopedpointer/tst_qscopedpointer.cpp
index e9b1cce..b8e0f0a 100644
--- a/tests/auto/qscopedpointer/tst_qscopedpointer.cpp
+++ b/tests/auto/qscopedpointer/tst_qscopedpointer.cpp
@@ -71,6 +71,7 @@ private Q_SLOTS:
void isNull() const;
void isNullSignature() const;
void objectSize() const;
+ void comparison() const;
// TODO instansiate on const object
};
@@ -312,5 +313,31 @@ void tst_QScopedPointer::objectSize() const
QCOMPARE(sizeof(QScopedPointer<int>), sizeof(void *));
}
+void tst_QScopedPointer::comparison() const
+{
+ int *a = new int(42);
+ int *b = new int(43);
+
+ QScopedPointer<int> pa(a);
+ QScopedPointer<int> pa2(a);
+ QScopedPointer<int> pb(b);
+
+ // test equality on equal pointers
+ QVERIFY(pa == pa2);
+ QVERIFY(pa2 == pa);
+
+ // test unequality on equal pointers
+ QVERIFY(!(pa != pa2));
+ QVERIFY(!(pa2 != pa));
+
+ // test on unequal pointers
+ QVERIFY(!(pa == pb));
+ QVERIFY(!(pb == pa));
+ QVERIFY(pb != pa);
+ QVERIFY(pa != pb);
+
+ pa2.take();
+}
+
QTEST_MAIN(tst_QScopedPointer)
#include "tst_qscopedpointer.moc"