diff options
author | Alex Blasche <alexander.blasche@theqtcompany.com> | 2016-03-09 09:34:07 +0100 |
---|---|---|
committer | Alex Blasche <alexander.blasche@theqtcompany.com> | 2016-03-09 13:53:44 +0000 |
commit | 9a0b00a9fb7ce843a47bc931cc4e58e43a5d3bdf (patch) | |
tree | 6c84ab5cb478b1bf17e609a9a9e00cd6d1206a99 | |
parent | f15b2e266094edac11c3825c1df42396b6a76a6c (diff) |
Fix QLEServiceData comparison operator inconsistency
The comparison operators usually have const& parameters.
Change-Id: Ibd8e7d1fe5704b4de3a0bfabe1bbc991411eecba
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@theqtcompany.com>
Reviewed-by: Christian Kandeler <christian.kandeler@theqtcompany.com>
-rw-r--r-- | src/bluetooth/qlowenergyservicedata.cpp | 2 | ||||
-rw-r--r-- | src/bluetooth/qlowenergyservicedata.h | 6 | ||||
-rw-r--r-- | tests/auto/qlowenergycontroller-gattserver/test/tst_qlowenergycontroller-gattserver.cpp | 14 |
3 files changed, 18 insertions, 4 deletions
diff --git a/src/bluetooth/qlowenergyservicedata.cpp b/src/bluetooth/qlowenergyservicedata.cpp index 3073f4f5..f40addd2 100644 --- a/src/bluetooth/qlowenergyservicedata.cpp +++ b/src/bluetooth/qlowenergyservicedata.cpp @@ -201,7 +201,7 @@ bool QLowEnergyServiceData::isValid() const Returns \c true if \a sd1 and \a sd2 are equal with respect to their public state, otherwise returns \c false. */ -bool operator==(const QLowEnergyServiceData sd1, const QLowEnergyServiceData &sd2) +bool operator==(const QLowEnergyServiceData &sd1, const QLowEnergyServiceData &sd2) { return sd1.d == sd2.d || (sd1.type() == sd2.type() && sd1.uuid() == sd2.uuid() && sd1.includedServices() == sd2.includedServices() diff --git a/src/bluetooth/qlowenergyservicedata.h b/src/bluetooth/qlowenergyservicedata.h index 9a5a6448..48f7fe89 100644 --- a/src/bluetooth/qlowenergyservicedata.h +++ b/src/bluetooth/qlowenergyservicedata.h @@ -52,7 +52,7 @@ struct QLowEnergyServiceDataPrivate; class Q_BLUETOOTH_EXPORT QLowEnergyServiceData { - friend Q_BLUETOOTH_EXPORT bool operator==(const QLowEnergyServiceData sd1, + friend Q_BLUETOOTH_EXPORT bool operator==(const QLowEnergyServiceData &sd1, const QLowEnergyServiceData &sd2); public: QLowEnergyServiceData(); @@ -84,9 +84,9 @@ private: QSharedDataPointer<QLowEnergyServiceDataPrivate> d; }; -Q_BLUETOOTH_EXPORT bool operator==(const QLowEnergyServiceData sd1, +Q_BLUETOOTH_EXPORT bool operator==(const QLowEnergyServiceData &sd1, const QLowEnergyServiceData &sd2); -inline bool operator!=(const QLowEnergyServiceData sd1, const QLowEnergyServiceData &sd2) +inline bool operator!=(const QLowEnergyServiceData &sd1, const QLowEnergyServiceData &sd2) { return !(sd1 == sd2); } diff --git a/tests/auto/qlowenergycontroller-gattserver/test/tst_qlowenergycontroller-gattserver.cpp b/tests/auto/qlowenergycontroller-gattserver/test/tst_qlowenergycontroller-gattserver.cpp index ac2060e9..937b9b5c 100644 --- a/tests/auto/qlowenergycontroller-gattserver/test/tst_qlowenergycontroller-gattserver.cpp +++ b/tests/auto/qlowenergycontroller-gattserver/test/tst_qlowenergycontroller-gattserver.cpp @@ -575,6 +575,20 @@ void TestQLowEnergyControllerGattServer::serviceData() << charData << QLowEnergyCharacteristicData()); QCOMPARE(secondaryData.characteristics(), QList<QLowEnergyCharacteristicData>() << charData); + QLowEnergyServiceData backupData; + backupData.setUuid(QBluetoothUuid::SerialPort); + QCOMPARE(backupData.uuid(), QBluetoothUuid(QBluetoothUuid::SerialPort)); + QVERIFY(backupData.isValid()); + QVERIFY(backupData != QLowEnergyServiceData()); + + backupData.setType(QLowEnergyServiceData::ServiceTypeSecondary); + QCOMPARE(backupData.type(), QLowEnergyServiceData::ServiceTypeSecondary); + + backupData.setCharacteristics(QList<QLowEnergyCharacteristicData>() + << charData << QLowEnergyCharacteristicData()); + QCOMPARE(backupData.characteristics(), QList<QLowEnergyCharacteristicData>() << charData); + QVERIFY(backupData == secondaryData); + #ifdef Q_OS_DARWIN QSKIP("GATT server functionality not implemented for Apple platforms"); #endif |