summaryrefslogtreecommitdiffstats
path: root/tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp
diff options
context:
space:
mode:
authorOliver Wolff <oliver.wolff@qt.io>2018-08-14 11:08:18 +0200
committerOliver Wolff <oliver.wolff@qt.io>2018-08-15 07:56:46 +0000
commita0ade068004ad869d6235ae8d6cd5e2050bf765d (patch)
tree42c949ba2fa7fcd4ab5356293d1ef3cad1c436f6 /tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp
parent84f0e76c647e7f09529b79525b2d4fbc698576d8 (diff)
Replace foreach with for loop and set QT_NO_FOREACH
To avoid unnecessary copies, const is used wherever possible. Change-Id: Ic743716512751cfd24fad5bd37c244b115dd26fe Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp')
-rw-r--r--tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp b/tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp
index 7ef78800..a0ff581c 100644
--- a/tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp
+++ b/tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp
@@ -186,12 +186,12 @@ static void dumpAttributeVariant(const QVariant &var, const QString indent)
if (var.userType() == qMetaTypeId<QBluetoothServiceInfo::Sequence>()) {
qDebug("%sSequence", indent.toLocal8Bit().constData());
const QBluetoothServiceInfo::Sequence *sequence = static_cast<const QBluetoothServiceInfo::Sequence *>(var.data());
- foreach (const QVariant &v, *sequence)
+ for (const QVariant &v : *sequence)
dumpAttributeVariant(v, indent + '\t');
} else if (var.userType() == qMetaTypeId<QBluetoothServiceInfo::Alternative>()) {
qDebug("%sAlternative", indent.toLocal8Bit().constData());
const QBluetoothServiceInfo::Alternative *alternative = static_cast<const QBluetoothServiceInfo::Alternative *>(var.data());
- foreach (const QVariant &v, *alternative)
+ for (const QVariant &v : *alternative)
dumpAttributeVariant(v, indent + '\t');
} else if (var.userType() == qMetaTypeId<QBluetoothUuid>()) {
QBluetoothUuid uuid = var.value<QBluetoothUuid>();
@@ -237,7 +237,8 @@ static void dumpAttributeVariant(const QVariant &var, const QString indent)
static inline void dumpServiceInfoAttributes(const QBluetoothServiceInfo &info)
{
- foreach (quint16 id, info.attributes()) {
+ const QList<quint16> attributes = info.attributes();
+ for (quint16 id : attributes) {
dumpAttributeVariant(info.attribute(id), QString("\t"));
}
}
@@ -254,7 +255,7 @@ void tst_QBluetoothServiceDiscoveryAgent::tst_serviceDiscovery_data()
// Only need to test the first 5 live devices
int max = 5;
- foreach (const QBluetoothDeviceInfo &info, devices) {
+ for (const QBluetoothDeviceInfo &info : qAsConst(devices)) {
if (info.isCached())
continue;
QTest::newRow("default filter") << info << QList<QBluetoothUuid>()