summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2022-10-06 11:15:43 +0200
committerMarc Mutz <marc.mutz@qt.io>2022-10-06 13:19:37 +0200
commit4814ec0069a11a0e21cd3ac8c956c5a8ec7a0c5b (patch)
tree71002a95b6d07bb39a348ef19f31586a7535e8ce /tests
parent9aa00a81fd54b2d1d7b3e9e20c407e2d43571d41 (diff)
downloadqtconnectivity-4814ec0069a11a0e21cd3ac8c956c5a8ec7a0c5b.tar.gz
Port from qAsConst() to std::as_const()
We've been requiring C++17 since Qt 6.0, and our qAsConst use finally starts to bother us (QTBUG-99313), so time to port away from it now. Since qAsConst has exactly the same semantics as std::as_const (down to rvalue treatment, constexpr'ness and noexcept'ness), there's really nothing more to it than a global search-and-replace. Task-number: QTBUG-99313 Change-Id: I9ace956ba9ee596ddf820623957f2d476036c5ed Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/nfccommons/qnearfieldtagtype1.cpp4
-rw-r--r--tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp2
-rw-r--r--tests/auto/qbluetoothserviceinfo/tst_qbluetoothserviceinfo.cpp6
-rw-r--r--tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp2
-rw-r--r--tests/auto/qlowenergycharacteristic/tst_qlowenergycharacteristic.cpp2
-rw-r--r--tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp8
-rw-r--r--tests/auto/qlowenergydescriptor/tst_qlowenergydescriptor.cpp2
-rw-r--r--tests/bttestui/btlocaldevice.cpp6
8 files changed, 16 insertions, 16 deletions
diff --git a/tests/auto/nfccommons/qnearfieldtagtype1.cpp b/tests/auto/nfccommons/qnearfieldtagtype1.cpp
index 11e9ea71..55e25001 100644
--- a/tests/auto/nfccommons/qnearfieldtagtype1.cpp
+++ b/tests/auto/nfccommons/qnearfieldtagtype1.cpp
@@ -244,11 +244,11 @@ void QNearFieldTagType1Private::progressToNextNdefWriteMessageState()
m_tlvWriter = new QTlvWriter(q);
// write old TLVs
- for (const Tlv &tlv : qAsConst(m_tlvs))
+ for (const Tlv &tlv : std::as_const(m_tlvs))
m_tlvWriter->writeTlv(tlv.first, tlv.second);
// write new NDEF message TLVs
- for (const QNdefMessage &message : qAsConst(m_ndefWriteMessages))
+ for (const QNdefMessage &message : std::as_const(m_ndefWriteMessages))
m_tlvWriter->writeTlv(0x03, message.toByteArray());
// write terminator TLV
diff --git a/tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp b/tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp
index b9e0dfb3..262fac02 100644
--- a/tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp
+++ b/tests/auto/qbluetoothservicediscoveryagent/tst_qbluetoothservicediscoveryagent.cpp
@@ -257,7 +257,7 @@ void tst_QBluetoothServiceDiscoveryAgent::tst_serviceDiscovery_data()
// Only need to test the first 5 live devices
int max = 5;
- for (const QBluetoothDeviceInfo &info : qAsConst(devices)) {
+ for (const QBluetoothDeviceInfo &info : std::as_const(devices)) {
if (info.isCached())
continue;
QTest::newRow("default filter") << info << QList<QBluetoothUuid>()
diff --git a/tests/auto/qbluetoothserviceinfo/tst_qbluetoothserviceinfo.cpp b/tests/auto/qbluetoothserviceinfo/tst_qbluetoothserviceinfo.cpp
index f26b9053..fb8b5c4d 100644
--- a/tests/auto/qbluetoothserviceinfo/tst_qbluetoothserviceinfo.cpp
+++ b/tests/auto/qbluetoothserviceinfo/tst_qbluetoothserviceinfo.cpp
@@ -107,7 +107,7 @@ void tst_QBluetoothServiceInfo::tst_construction()
QCOMPARE(serviceInfo.serverChannel(), -1);
QCOMPARE(serviceInfo.protocolServiceMultiplexer(), -1);
- for (QBluetoothUuid::ProtocolUuid u : qAsConst(protUuids))
+ for (QBluetoothUuid::ProtocolUuid u : std::as_const(protUuids))
QCOMPARE(serviceInfo.protocolDescriptor(u).size(), 0);
}
@@ -141,9 +141,9 @@ void tst_QBluetoothServiceInfo::tst_construction()
QCOMPARE(copyInfo.device().address(), alternatedeviceInfo.address());
QCOMPARE(serviceInfo.device().address(), alternatedeviceInfo.address());
- for (QBluetoothUuid::ProtocolUuid u : qAsConst(protUuids))
+ for (QBluetoothUuid::ProtocolUuid u : std::as_const(protUuids))
QCOMPARE(serviceInfo.protocolDescriptor(u).size(), 0);
- for (QBluetoothUuid::ProtocolUuid u : qAsConst(protUuids))
+ for (QBluetoothUuid::ProtocolUuid u : std::as_const(protUuids))
QCOMPARE(copyInfo.protocolDescriptor(u).size(), 0);
}
}
diff --git a/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp b/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
index 6dbc0359..2784c98c 100644
--- a/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
+++ b/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
@@ -362,7 +362,7 @@ void tst_QBluetoothSocket::tst_clientCommunication()
{
/* Send line by line with event loop */
- for (const QString &line : qAsConst(data)) {
+ for (const QString &line : std::as_const(data)) {
QSignalSpy readyReadSpy(&socket, SIGNAL(readyRead()));
QSignalSpy bytesWrittenSpy(&socket, SIGNAL(bytesWritten(qint64)));
diff --git a/tests/auto/qlowenergycharacteristic/tst_qlowenergycharacteristic.cpp b/tests/auto/qlowenergycharacteristic/tst_qlowenergycharacteristic.cpp
index 64bdee2a..32e10b03 100644
--- a/tests/auto/qlowenergycharacteristic/tst_qlowenergycharacteristic.cpp
+++ b/tests/auto/qlowenergycharacteristic/tst_qlowenergycharacteristic.cpp
@@ -99,7 +99,7 @@ void tst_QLowEnergyCharacteristic::initTestCase()
// find first service with descriptor
QLowEnergyController *controller = 0;
- for (const QBluetoothDeviceInfo &remoteDevice : qAsConst(remoteLeDevices)) {
+ for (const QBluetoothDeviceInfo &remoteDevice : std::as_const(remoteLeDevices)) {
controller = QLowEnergyController::createCentral(remoteDevice, this);
qDebug() << "Connecting to" << remoteDevice.name()
<< remoteDevice.address() << remoteDevice.deviceUuid();
diff --git a/tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp b/tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp
index 926cf8d8..c83f4bc5 100644
--- a/tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp
+++ b/tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp
@@ -324,7 +324,7 @@ void tst_QLowEnergyController::tst_connect()
listing.append(v.value<QBluetoothUuid>());
}
- for (const QBluetoothUuid &uuid : qAsConst(foundServices)) {
+ for (const QBluetoothUuid &uuid : std::as_const(foundServices)) {
QVERIFY2(listing.contains(uuid),
uuid.toString().toLatin1());
@@ -343,7 +343,7 @@ void tst_QLowEnergyController::tst_connect()
QBluetoothUuid(QBluetoothUuid::CharacteristicType::DeviceName)));
// initiate characteristic discovery
- for (QLowEnergyService *service : qAsConst(savedReferences)) {
+ for (QLowEnergyService *service : std::as_const(savedReferences)) {
qDebug() << "Discovering" << service->serviceUuid();
QSignalSpy stateSpy(service,
SIGNAL(stateChanged(QLowEnergyService::ServiceState)));
@@ -360,7 +360,7 @@ void tst_QLowEnergyController::tst_connect()
}
// ensure that related service objects share same state
- for (QLowEnergyService* originalService : qAsConst(savedReferences)) {
+ for (QLowEnergyService* originalService : std::as_const(savedReferences)) {
QLowEnergyService *newService = control->createServiceObject(
originalService->serviceUuid());
QVERIFY(newService);
@@ -380,7 +380,7 @@ void tst_QLowEnergyController::tst_connect()
} else {
QCOMPARE(disconnectedSpy.size(), 1);
// after disconnect all service references must be invalid
- for (const QLowEnergyService *entry : qAsConst(savedReferences)) {
+ for (const QLowEnergyService *entry : std::as_const(savedReferences)) {
const QBluetoothUuid &uuid = entry->serviceUuid();
QVERIFY2(entry->state() == QLowEnergyService::InvalidService,
uuid.toString().toLatin1());
diff --git a/tests/auto/qlowenergydescriptor/tst_qlowenergydescriptor.cpp b/tests/auto/qlowenergydescriptor/tst_qlowenergydescriptor.cpp
index 535bf89a..b3046a52 100644
--- a/tests/auto/qlowenergydescriptor/tst_qlowenergydescriptor.cpp
+++ b/tests/auto/qlowenergydescriptor/tst_qlowenergydescriptor.cpp
@@ -86,7 +86,7 @@ void tst_QLowEnergyDescriptor::initTestCase()
// find first service with descriptor
QLowEnergyController *controller = nullptr;
- for (const QBluetoothDeviceInfo& remoteDeviceInfo : qAsConst(remoteLeDeviceInfos)) {
+ for (const QBluetoothDeviceInfo& remoteDeviceInfo : std::as_const(remoteLeDeviceInfos)) {
controller = QLowEnergyController::createCentral(remoteDeviceInfo, this);
qDebug() << "Connecting to" << remoteDeviceInfo.address();
controller->connectToDevice();
diff --git a/tests/bttestui/btlocaldevice.cpp b/tests/bttestui/btlocaldevice.cpp
index 2e30a311..cff7851f 100644
--- a/tests/bttestui/btlocaldevice.cpp
+++ b/tests/bttestui/btlocaldevice.cpp
@@ -379,7 +379,7 @@ void BtLocalDevice::serviceDiscovered(const QBluetoothServiceInfo &info)
{
//This is here to detect the test server for SPP testing later on
bool alreadyKnown = false;
- for (const QBluetoothServiceInfo& found : qAsConst(foundTestServers)) {
+ for (const QBluetoothServiceInfo& found : std::as_const(foundTestServers)) {
if (found.device().address() == info.device().address()) {
alreadyKnown = true;
break;
@@ -433,7 +433,7 @@ void BtLocalDevice::dumpServiceDiscovery()
}
qDebug() << "###### TestServer offered by:";
- for (const QBluetoothServiceInfo& found : qAsConst(foundTestServers)) {
+ for (const QBluetoothServiceInfo& found : std::as_const(foundTestServers)) {
qDebug() << found.device().name() << found.device().address().toString();
}
}
@@ -769,7 +769,7 @@ void BtLocalDevice::dumpServerInformation()
//server->setSecurityFlags(secFlag);
- for (const QBluetoothSocket *client : qAsConst(serverSockets)) {
+ for (const QBluetoothSocket *client : std::as_const(serverSockets)) {
qDebug() << "##" << client->localAddress().toString()
<< client->localName() << client->localPort();
qDebug() << "##" << client->peerAddress().toString()