diff options
author | Tatiana Borisova <tatiana.borisova@qt.io> | 2024-03-27 18:48:53 +0100 |
---|---|---|
committer | Tatiana Borisova <tatiana.borisova@qt.io> | 2024-04-17 20:30:37 +0200 |
commit | 3059f14524ce7d0abec562af5e96510f488ee525 (patch) | |
tree | f5848f212bd132c2642767aaa63843f8734d1e80 /tests/auto | |
parent | 7f3e43b32c28fc84c465ec2fd6f3f5e188bbf5fb (diff) |
QNativeIpcKey: use new comparison helper macros
Replace public friend operators operator==(), operator!=() of
QNativeIpcKey to friend methods comparesEqual() and
Q_DECLARE_EQUALITY_COMPARABLE macro.
Task-number: QTBUG-120304
Change-Id: If18d86fb18e44f8d2210cba7ca93e4ac478a2a48
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/corelib/ipc/qnativeipckey/CMakeLists.txt | 2 | ||||
-rw-r--r-- | tests/auto/corelib/ipc/qnativeipckey/tst_qnativeipckey.cpp | 16 |
2 files changed, 18 insertions, 0 deletions
diff --git a/tests/auto/corelib/ipc/qnativeipckey/CMakeLists.txt b/tests/auto/corelib/ipc/qnativeipckey/CMakeLists.txt index aba8946002..0cc6a7b18b 100644 --- a/tests/auto/corelib/ipc/qnativeipckey/CMakeLists.txt +++ b/tests/auto/corelib/ipc/qnativeipckey/CMakeLists.txt @@ -10,4 +10,6 @@ endif() qt_internal_add_test(tst_qnativeipckey SOURCES tst_qnativeipckey.cpp + LIBRARIES + Qt::TestPrivate ) diff --git a/tests/auto/corelib/ipc/qnativeipckey/tst_qnativeipckey.cpp b/tests/auto/corelib/ipc/qnativeipckey/tst_qnativeipckey.cpp index cd1a07a4d0..a01a108591 100644 --- a/tests/auto/corelib/ipc/qnativeipckey/tst_qnativeipckey.cpp +++ b/tests/auto/corelib/ipc/qnativeipckey/tst_qnativeipckey.cpp @@ -3,6 +3,7 @@ #include <QtCore/QNativeIpcKey> #include <QtTest/QTest> +#include <QtTest/private/qcomparisontesthelper_p.h> #include "../ipctestcommon.h" @@ -25,6 +26,7 @@ class tst_QNativeIpcKey : public QObject { Q_OBJECT private slots: + void compareCompiles(); void defaultTypes(); void construct(); void getSetCheck(); @@ -39,6 +41,11 @@ private slots: void legacyKeys(); }; +void tst_QNativeIpcKey::compareCompiles() +{ + QTestPrivate::testEqualityOperatorsCompile<QNativeIpcKey>(); +} + void tst_QNativeIpcKey::defaultTypes() { auto isKnown = [](QNativeIpcKey::Type t) { @@ -180,35 +187,43 @@ void tst_QNativeIpcKey::equality() QNativeIpcKey key1, key2; QCOMPARE(key1, key2); QVERIFY(!(key1 != key2)); + QT_TEST_EQUALITY_OPS(key1, key2, true); key1.setNativeKey("key1"); QCOMPARE_NE(key1, key2); QVERIFY(!(key1 == key2)); + QT_TEST_EQUALITY_OPS(key1, key2, false); key2.setType({}); QCOMPARE_NE(key1, key2); QVERIFY(!(key1 == key2)); + QT_TEST_EQUALITY_OPS(key1, key2, false); key2.setNativeKey(key1.nativeKey()); QCOMPARE_NE(key1, key2); QVERIFY(!(key1 == key2)); + QT_TEST_EQUALITY_OPS(key1, key2, false); key2.setType(QNativeIpcKey::DefaultTypeForOs); QCOMPARE(key1, key2); QVERIFY(!(key1 != key2)); + QT_TEST_EQUALITY_OPS(key1, key2, true); key1 = makeLegacyKey("key1", QNativeIpcKey::DefaultTypeForOs); QCOMPARE_NE(key1, key2); QVERIFY(!(key1 == key2)); + QT_TEST_EQUALITY_OPS(key1, key2, false); key2 = key1; QCOMPARE(key1, key2); QVERIFY(!(key1 != key2)); + QT_TEST_EQUALITY_OPS(key1, key2, true); // just setting the native key won't make them equal again! key2.setNativeKey(key1.nativeKey()); QCOMPARE_NE(key1, key2); QVERIFY(!(key1 == key2)); + QT_TEST_EQUALITY_OPS(key1, key2, false); } void tst_QNativeIpcKey::hash() @@ -410,6 +425,7 @@ void tst_QNativeIpcKey::legacyKeys() QString string = key.toString(); QNativeIpcKey key2 = QNativeIpcKey::fromString(string); QCOMPARE(key2, key); + QT_TEST_EQUALITY_OPS(key, key2, true); if (!legacyKey.isEmpty()) { // confirm it shows up in the encoded form |