diff --git a/tests/src/core/AutomatableModelTest.cpp b/tests/src/core/AutomatableModelTest.cpp index 9bc19d7e8..6717da12d 100644 --- a/tests/src/core/AutomatableModelTest.cpp +++ b/tests/src/core/AutomatableModelTest.cpp @@ -32,21 +32,23 @@ class AutomatableModelTest : QTestSuite Q_OBJECT private slots: + //! Test that upcast and exact casts work, + //! but no downcast or any other casts void CastTests() { ComboBoxModel comboModel; AutomatableModel* amPtr = &comboModel; - QCOMPARE(nullptr, amPtr->dynamicCast()); - QVERIFY(nullptr != amPtr->dynamicCast()); - QVERIFY(nullptr != amPtr->dynamicCast()); - QVERIFY(nullptr != amPtr->dynamicCast()); + QCOMPARE(nullptr, amPtr->dynamicCast()); // not a parent class + QCOMPARE(&comboModel, amPtr->dynamicCast()); // parent class + QCOMPARE(&comboModel, amPtr->dynamicCast()); // parent class + QCOMPARE(&comboModel, amPtr->dynamicCast()); // same class IntModel intModel; IntModel* imPtr = &intModel; - QCOMPARE(nullptr, imPtr->dynamicCast()); - QVERIFY(nullptr != imPtr->dynamicCast()); - QVERIFY(nullptr != imPtr->dynamicCast()); - QCOMPARE(nullptr, imPtr->dynamicCast()); + QCOMPARE(nullptr, imPtr->dynamicCast()); // not a parent class + QCOMPARE(&intModel, imPtr->dynamicCast()); // parent class + QCOMPARE(&intModel, imPtr->dynamicCast()); // same class + QCOMPARE(nullptr, imPtr->dynamicCast()); // child class } } AutomatableModelTests;