Commit 9a0b00a9 authored by Alex Blasche's avatar Alex Blasche
Browse files

Fix QLEServiceData comparison operator inconsistency


The comparison operators usually have const& parameters.

Change-Id: Ibd8e7d1fe5704b4de3a0bfabe1bbc991411eecba
Reviewed-by: default avatarTimur Pocheptsov <timur.pocheptsov@theqtcompany.com>
Reviewed-by: default avatarChristian Kandeler <christian.kandeler@theqtcompany.com>
Showing with 18 additions and 4 deletions
...@@ -201,7 +201,7 @@ bool QLowEnergyServiceData::isValid() const ...@@ -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, Returns \c true if \a sd1 and \a sd2 are equal with respect to their public state,
otherwise returns \c false. 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() return sd1.d == sd2.d || (sd1.type() == sd2.type() && sd1.uuid() == sd2.uuid()
&& sd1.includedServices() == sd2.includedServices() && sd1.includedServices() == sd2.includedServices()
......
...@@ -52,7 +52,7 @@ struct QLowEnergyServiceDataPrivate; ...@@ -52,7 +52,7 @@ struct QLowEnergyServiceDataPrivate;
class Q_BLUETOOTH_EXPORT QLowEnergyServiceData 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); const QLowEnergyServiceData &sd2);
public: public:
QLowEnergyServiceData(); QLowEnergyServiceData();
...@@ -84,9 +84,9 @@ private: ...@@ -84,9 +84,9 @@ private:
QSharedDataPointer<QLowEnergyServiceDataPrivate> d; QSharedDataPointer<QLowEnergyServiceDataPrivate> d;
}; };
Q_BLUETOOTH_EXPORT bool operator==(const QLowEnergyServiceData sd1, Q_BLUETOOTH_EXPORT bool operator==(const QLowEnergyServiceData &sd1,
const QLowEnergyServiceData &sd2); const QLowEnergyServiceData &sd2);
inline bool operator!=(const QLowEnergyServiceData sd1, const QLowEnergyServiceData &sd2) inline bool operator!=(const QLowEnergyServiceData &sd1, const QLowEnergyServiceData &sd2)
{ {
return !(sd1 == sd2); return !(sd1 == sd2);
} }
......
...@@ -575,6 +575,20 @@ void TestQLowEnergyControllerGattServer::serviceData() ...@@ -575,6 +575,20 @@ void TestQLowEnergyControllerGattServer::serviceData()
<< charData << QLowEnergyCharacteristicData()); << charData << QLowEnergyCharacteristicData());
QCOMPARE(secondaryData.characteristics(), QList<QLowEnergyCharacteristicData>() << charData); 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 #ifdef Q_OS_DARWIN
QSKIP("GATT server functionality not implemented for Apple platforms"); QSKIP("GATT server functionality not implemented for Apple platforms");
#endif #endif
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment