aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorSemih Yavuz <semih.yavuz@qt.io>2023-01-31 14:00:04 +0100
committerSemih Yavuz <semih.yavuz@qt.io>2023-01-31 19:12:21 +0100
commitdb71a35b1e20b028e4e07c8229551fea8ac0eafb (patch)
treef2e57af0d9de0dba006c4a71a229e1d67f4d2724 /tests/auto
parente23ea6cf3ce1565fa2265e7985257a4d69526f59 (diff)
qmlcachegen: Improve QObject comparison code generation test
The code generated for QObject comparisons holds for both weak and strong comparisons. Improve tst_qmlcppcodegen by adding missing weak comparison tests. Amends afc7928d1a1e47ecbc9d101c4e5d5fb1c5b78326. Pick-to: 6.5 Change-Id: Ib6176a39b329e792b81b3d8e8a288dcea074320b Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/equalityQObjects.qml8
-rw-r--r--tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp7
2 files changed, 15 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/data/equalityQObjects.qml b/tests/auto/qml/qmlcppcodegen/data/equalityQObjects.qml
index ce2da605d7..199f80884f 100644
--- a/tests/auto/qml/qmlcppcodegen/data/equalityQObjects.qml
+++ b/tests/auto/qml/qmlcppcodegen/data/equalityQObjects.qml
@@ -16,4 +16,12 @@ QtObject {
property bool compareSameObjects: sameNonNullObject === nonNullObject
property bool compareDifferentObjects: derivedObject !== nonNullObject
property bool compareObjectWithNullObject: nullObject !== nonNullObject
+
+ // Above tests should hold true for the weak comparisons
+ property bool nonStrict_derivedIsNotNull: derivedObject != null
+ property bool nonStrict_nullObjectIsNull: nullObject == null
+ property bool nonStrict_nonNullObjectIsNotNull: null != nonNullObject
+ property bool nonStrict_compareSameObjects: sameNonNullObject == nonNullObject
+ property bool nonStrict_compareDifferentObjects: derivedObject != nonNullObject
+ property bool nonStrict_compareObjectWithNullObject: nullObject != nonNullObject
}
diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
index dd30931868..3db83ee884 100644
--- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
+++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
@@ -3112,6 +3112,13 @@ void tst_QmlCppCodegen::equalityQObjects()
QVERIFY(object->property("compareSameObjects").toBool());
QVERIFY(object->property("compareDifferentObjects").toBool());
QVERIFY(object->property("compareObjectWithNullObject").toBool());
+
+ QVERIFY(object->property("nonStrict_derivedIsNotNull").toBool());
+ QVERIFY(object->property("nonStrict_nullObjectIsNull").toBool());
+ QVERIFY(object->property("nonStrict_nonNullObjectIsNotNull").toBool());
+ QVERIFY(object->property("nonStrict_compareSameObjects").toBool());
+ QVERIFY(object->property("nonStrict_compareDifferentObjects").toBool());
+ QVERIFY(object->property("nonStrict_compareObjectWithNullObject").toBool());
}
void tst_QmlCppCodegen::dateConversions()