From 5a0faa9198c6ae6e21a550159c4284d1a9c5792e Mon Sep 17 00:00:00 2001 From: Tatiana Borisova Date: Tue, 30 Apr 2024 15:27:02 +0200 Subject: QMetaType: use modern comparisons Internal QPropertyBindingPrivatePtr, QArgumentType classes also have been updated; Replace class operators operator==(), operator!=() of QRegularExpression to friend method comparesEqual() and Q_DECLARE_EQUALITY_COMPARABLE macro. Task-number: QTBUG-120304 Change-Id: I010617cbcb8bd6afb7c21ee4345398648821f72c Reviewed-by: Ivan Solovev --- tests/auto/corelib/kernel/qmetatype/CMakeLists.txt | 1 + .../auto/corelib/kernel/qmetatype/tst_qmetatype.h | 1 + .../corelib/kernel/qmetatype/tst_qmetatype2.cpp | 25 ++++++++++++---------- 3 files changed, 16 insertions(+), 11 deletions(-) (limited to 'tests/auto/corelib/kernel') diff --git a/tests/auto/corelib/kernel/qmetatype/CMakeLists.txt b/tests/auto/corelib/kernel/qmetatype/CMakeLists.txt index b93d961109..65bec3e187 100644 --- a/tests/auto/corelib/kernel/qmetatype/CMakeLists.txt +++ b/tests/auto/corelib/kernel/qmetatype/CMakeLists.txt @@ -51,6 +51,7 @@ qt_internal_add_test(tst_qmetatype ../../../other/qvariant_common LIBRARIES Qt::CorePrivate + Qt::TestPrivate Qt::Gui qmetatype_lib1 qmetatype_lib2 diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.h b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.h index 1694e49491..bcd2fe2def 100644 --- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.h +++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.h @@ -111,6 +111,7 @@ private slots: void customDebugStream(); void unknownType(); void fromType(); + void compareCompiles(); void operatorEq_data(); void operatorEq(); void operatorEq2_data(); diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype2.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype2.cpp index 68bcb53056..661c1f6072 100644 --- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype2.cpp +++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype2.cpp @@ -5,6 +5,7 @@ #include "tst_qmetatype_libs.h" #include +#include void tst_QMetaType::constRefs() { @@ -418,6 +419,11 @@ struct CharTemplate } y; }; +void tst_QMetaType::compareCompiles() +{ + QTestPrivate::testEqualityOperatorsCompile(); +} + void tst_QMetaType::operatorEq_data() { QTest::addColumn("typeA"); @@ -447,10 +453,7 @@ void tst_QMetaType::operatorEq() QFETCH(QMetaType, typeB); QFETCH(bool, eq); - QCOMPARE(typeA == typeB, eq); - QCOMPARE(typeB == typeA, eq); - QCOMPARE(typeA != typeB, !eq); - QCOMPARE(typeB != typeA, !eq); + QT_TEST_EQUALITY_OPS(typeA, typeB, eq); #if !defined(Q_OS_WIN) && !defined(Q_OS_INTEGRITY) // for built-in types or locally-defined types, this must also hold true @@ -487,10 +490,10 @@ FOR_EACH_CORE_METATYPE(GET_METATYPE_FROM_TYPE) QCOMPARE(fromId2.id(), type); // confirm that they're all equal - QCOMPARE(fromId1, fromId2); - QCOMPARE(fromType1, fromType2); - QCOMPARE(fromType1, fromId1); - QCOMPARE(fromType2, fromId2); + QT_TEST_EQUALITY_OPS(fromId1, fromId2, true); + QT_TEST_EQUALITY_OPS(fromType1, fromType2, true); + QT_TEST_EQUALITY_OPS(fromType1, fromId1, true); + QT_TEST_EQUALITY_OPS(fromType2, fromId2, true); #if !defined(Q_OS_WIN) && !defined(Q_OS_INTEGRITY) // for built-in types (other than void), this must be true @@ -541,7 +544,7 @@ void tst_QMetaType::operatorEqAcrossLibs() // DO THIS FIRST: // if this isn't a built-in type, then the QMetaTypeInterface::typeId is // initially set to 0 - QCOMPARE(lib1Type, lib2Type); + QT_TEST_EQUALITY_OPS(lib1Type, lib2Type, true); int actualTypeId = localType.id(); bool builtinTypeExpected = builtinTypeId != QMetaType::UnknownType; @@ -559,8 +562,8 @@ void tst_QMetaType::operatorEqAcrossLibs() QCOMPARE(lib2Type.id(), actualTypeId); QCOMPARE(QByteArray(lib1Type.name()), QByteArray(localType.name())); QCOMPARE(QByteArray(lib2Type.name()), QByteArray(localType.name())); - QCOMPARE(lib1Type, localType); - QCOMPARE(lib2Type, localType); + QT_TEST_EQUALITY_OPS(lib1Type, localType, true); + QT_TEST_EQUALITY_OPS(lib2Type, localType, true); #if !defined(Q_OS_WIN) && !defined(Q_OS_INTEGRITY) if (actualTypeId < QMetaType::FirstGuiType && actualTypeId != QMetaType::Void) { -- cgit v1.2.3