diff options
author | Marc Mutz <marc.mutz@qt.io> | 2022-11-11 15:53:00 +0100 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2022-11-12 08:42:21 +0100 |
commit | cad49b3be482b41f1ae43b5c9ce4d009a810240b (patch) | |
tree | f4a779e779ef2283aec135db61c74035d1e74d82 | |
parent | cdabf47eb780628908db393bbb76e3a0faf32ddd (diff) | |
download | qtconnectivity-cad49b3be482b41f1ae43b5c9ce4d009a810240b.tar.gz |
Port from container::count() and length() to size() - V5
This is a the same semantic patch (qt-port-to-std-compatible-api V5
with config Scope: 'Container') as in dev. I've re-ran it in 6.4 to
avoid cherry-pick conflicts.
Change-Id: I9621dee5ed328b47e78919a34c307105e4311903
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
-rw-r--r-- | src/nfc/qndefmessage.cpp | 10 | ||||
-rw-r--r-- | src/nfc/qndefnfcsmartposterrecord.cpp | 32 | ||||
-rw-r--r-- | src/nfc/qndefnfctextrecord.cpp | 4 | ||||
-rw-r--r-- | tests/auto/nfccommons/qnearfieldtagtype1.cpp | 4 | ||||
-rw-r--r-- | tests/auto/nfccommons/qnearfieldtagtype2.cpp | 2 | ||||
-rw-r--r-- | tests/auto/nfccommons/qnearfieldtarget_emulator.cpp | 10 | ||||
-rw-r--r-- | tests/auto/nfccommons/qtlv.cpp | 22 | ||||
-rw-r--r-- | tests/auto/nfccommons/targetemulator.cpp | 24 | ||||
-rw-r--r-- | tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp | 20 | ||||
-rw-r--r-- | tests/auto/qndefmessage/tst_qndefmessage.cpp | 92 | ||||
-rw-r--r-- | tests/auto/qndefnfcsmartposterrecord/tst_qndefnfcsmartposterrecord.cpp | 2 | ||||
-rw-r--r-- | tests/auto/qnearfieldtagtype1/tst_qnearfieldtagtype1.cpp | 4 | ||||
-rw-r--r-- | tests/bttestui/btlocaldevice.cpp | 6 |
13 files changed, 116 insertions, 116 deletions
diff --git a/src/nfc/qndefmessage.cpp b/src/nfc/qndefmessage.cpp index 0c92db38..443d43e6 100644 --- a/src/nfc/qndefmessage.cpp +++ b/src/nfc/qndefmessage.cpp @@ -287,19 +287,19 @@ QByteArray QNdefMessage::toByteArray() const // cf (chunked records) not supported yet - if (record.payload().length() < 255) + if (record.payload().size() < 255) flags |= 0x10; if (!record.id().isEmpty()) flags |= 0x08; m.append(flags); - m.append(record.type().length()); + m.append(record.type().size()); if (flags & 0x10) { - m.append(quint8(record.payload().length())); + m.append(quint8(record.payload().size())); } else { - quint32 length = record.payload().length(); + quint32 length = record.payload().size(); m.append(length >> 24); m.append(length >> 16); m.append(length >> 8); @@ -307,7 +307,7 @@ QByteArray QNdefMessage::toByteArray() const } if (flags & 0x08) - m.append(record.id().length()); + m.append(record.id().size()); if (!record.type().isEmpty()) m.append(record.type()); diff --git a/src/nfc/qndefnfcsmartposterrecord.cpp b/src/nfc/qndefnfcsmartposterrecord.cpp index 4eace860..866abeed 100644 --- a/src/nfc/qndefnfcsmartposterrecord.cpp +++ b/src/nfc/qndefnfcsmartposterrecord.cpp @@ -207,7 +207,7 @@ void QNdefNfcSmartPosterRecord::convertToPayload() */ bool QNdefNfcSmartPosterRecord::hasTitle(const QString &locale) const { - for (qsizetype i = 0; i < d->m_titleList.length(); ++i) { + for (qsizetype i = 0; i < d->m_titleList.size(); ++i) { const QNdefNfcTextRecord &text = d->m_titleList[i]; if (locale.isEmpty() || text.locale() == locale) @@ -234,7 +234,7 @@ bool QNdefNfcSmartPosterRecord::hasAction() const */ bool QNdefNfcSmartPosterRecord::hasIcon(const QByteArray &mimetype) const { - for (qsizetype i = 0; i < d->m_iconList.length(); ++i) { + for (qsizetype i = 0; i < d->m_iconList.size(); ++i) { const QNdefNfcIconRecord &icon = d->m_iconList[i]; if (mimetype.isEmpty() || icon.type() == mimetype) @@ -267,7 +267,7 @@ bool QNdefNfcSmartPosterRecord::hasTypeInfo() const */ qsizetype QNdefNfcSmartPosterRecord::titleCount() const { - return d->m_titleList.length(); + return d->m_titleList.size(); } /*! @@ -277,7 +277,7 @@ qsizetype QNdefNfcSmartPosterRecord::titleCount() const */ QNdefNfcTextRecord QNdefNfcSmartPosterRecord::titleRecord(qsizetype index) const { - if (index >= 0 && index < d->m_titleList.length()) + if (index >= 0 && index < d->m_titleList.size()) return d->m_titleList[index]; return QNdefNfcTextRecord(); @@ -290,7 +290,7 @@ QNdefNfcTextRecord QNdefNfcSmartPosterRecord::titleRecord(qsizetype index) const */ QString QNdefNfcSmartPosterRecord::title(const QString &locale) const { - for (qsizetype i = 0; i < d->m_titleList.length(); ++i) { + for (qsizetype i = 0; i < d->m_titleList.size(); ++i) { const QNdefNfcTextRecord &text = d->m_titleList[i]; if (locale.isEmpty() || text.locale() == locale) @@ -326,7 +326,7 @@ bool QNdefNfcSmartPosterRecord::addTitle(const QNdefNfcTextRecord &text) bool QNdefNfcSmartPosterRecord::addTitleInternal(const QNdefNfcTextRecord &text) { - for (qsizetype i = 0; i < d->m_titleList.length(); ++i) { + for (qsizetype i = 0; i < d->m_titleList.size(); ++i) { const QNdefNfcTextRecord &rec = d->m_titleList[i]; if (rec.locale() == text.locale()) @@ -361,7 +361,7 @@ bool QNdefNfcSmartPosterRecord::removeTitle(const QNdefNfcTextRecord &text) { bool status = false; - for (qsizetype i = 0; i < d->m_titleList.length(); ++i) { + for (qsizetype i = 0; i < d->m_titleList.size(); ++i) { const QNdefNfcTextRecord &rec = d->m_titleList[i]; if (rec.text() == text.text() && rec.locale() == text.locale() && rec.encoding() == text.encoding()) { @@ -387,7 +387,7 @@ bool QNdefNfcSmartPosterRecord::removeTitle(const QString &locale) { bool status = false; - for (qsizetype i = 0; i < d->m_titleList.length(); ++i) { + for (qsizetype i = 0; i < d->m_titleList.size(); ++i) { const QNdefNfcTextRecord &rec = d->m_titleList[i]; if (rec.locale() == locale) { @@ -411,7 +411,7 @@ void QNdefNfcSmartPosterRecord::setTitles(const QList<QNdefNfcTextRecord> &title { d->m_titleList.clear(); - for (qsizetype i = 0; i < titles.length(); ++i) { + for (qsizetype i = 0; i < titles.size(); ++i) { d->m_titleList.append(titles[i]); } @@ -496,7 +496,7 @@ void QNdefNfcSmartPosterRecord::setAction(Action act) */ qsizetype QNdefNfcSmartPosterRecord::iconCount() const { - return d->m_iconList.length(); + return d->m_iconList.size(); } /*! @@ -506,7 +506,7 @@ qsizetype QNdefNfcSmartPosterRecord::iconCount() const */ QNdefNfcIconRecord QNdefNfcSmartPosterRecord::iconRecord(qsizetype index) const { - if (index >= 0 && index < d->m_iconList.length()) + if (index >= 0 && index < d->m_iconList.size()) return d->m_iconList[index]; return QNdefNfcIconRecord(); @@ -518,7 +518,7 @@ QNdefNfcIconRecord QNdefNfcSmartPosterRecord::iconRecord(qsizetype index) const */ QByteArray QNdefNfcSmartPosterRecord::icon(const QByteArray& mimetype) const { - for (qsizetype i = 0; i < d->m_iconList.length(); ++i) { + for (qsizetype i = 0; i < d->m_iconList.size(); ++i) { const QNdefNfcIconRecord &icon = d->m_iconList[i]; if (mimetype.isEmpty() || icon.type() == mimetype) @@ -550,7 +550,7 @@ void QNdefNfcSmartPosterRecord::addIcon(const QNdefNfcIconRecord &icon) void QNdefNfcSmartPosterRecord::addIconInternal(const QNdefNfcIconRecord &icon) { - for (qsizetype i = 0; i < d->m_iconList.length(); ++i) { + for (qsizetype i = 0; i < d->m_iconList.size(); ++i) { const QNdefNfcIconRecord &rec = d->m_iconList[i]; if (rec.type() == icon.type()) @@ -582,7 +582,7 @@ bool QNdefNfcSmartPosterRecord::removeIcon(const QNdefNfcIconRecord &icon) { bool status = false; - for (qsizetype i = 0; i < d->m_iconList.length(); ++i) { + for (qsizetype i = 0; i < d->m_iconList.size(); ++i) { const QNdefNfcIconRecord &rec = d->m_iconList[i]; if (rec.type() == icon.type() && rec.data() == icon.data()) { @@ -608,7 +608,7 @@ bool QNdefNfcSmartPosterRecord::removeIcon(const QByteArray &type) { bool status = false; - for (qsizetype i = 0; i < d->m_iconList.length(); ++i) { + for (qsizetype i = 0; i < d->m_iconList.size(); ++i) { const QNdefNfcIconRecord &rec = d->m_iconList[i]; if (rec.type() == type) { @@ -635,7 +635,7 @@ void QNdefNfcSmartPosterRecord::setIcons(const QList<QNdefNfcIconRecord> &icons) { d->m_iconList.clear(); - for (qsizetype i = 0; i < icons.length(); ++i) { + for (qsizetype i = 0; i < icons.size(); ++i) { d->m_iconList.append(icons[i]); } diff --git a/src/nfc/qndefnfctextrecord.cpp b/src/nfc/qndefnfctextrecord.cpp index 9c84eab3..a8d9b091 100644 --- a/src/nfc/qndefnfctextrecord.cpp +++ b/src/nfc/qndefnfctextrecord.cpp @@ -68,7 +68,7 @@ void QNdefNfcTextRecord::setLocale(const QString &locale) quint8 codeLength = status & 0x3f; - quint8 newStatus = (status & 0xd0) | locale.length(); + quint8 newStatus = (status & 0xd0) | locale.size(); p[0] = newStatus; p.replace(1, codeLength, locale.toLatin1()); @@ -94,7 +94,7 @@ QString QNdefNfcTextRecord::text() const utf16 ? QStringDecoder::Encoding::Utf16BE : QStringDecoder::Encoding::Utf8, QStringDecoder::Flag::Stateless); - return toUnicode(QByteArrayView(p.constData() + 1 + codeLength, p.length() - 1 - codeLength)); + return toUnicode(QByteArrayView(p.constData() + 1 + codeLength, p.size() - 1 - codeLength)); } /*! diff --git a/tests/auto/nfccommons/qnearfieldtagtype1.cpp b/tests/auto/nfccommons/qnearfieldtagtype1.cpp index b12000ad..11e9ea71 100644 --- a/tests/auto/nfccommons/qnearfieldtagtype1.cpp +++ b/tests/auto/nfccommons/qnearfieldtagtype1.cpp @@ -335,7 +335,7 @@ static QVariant decodeResponse(const QByteArray &command, const QByteArray &resp if (writeBlockAddress != blockAddress) return false; - for (int i = 0; i < writeData.length(); ++i) { + for (int i = 0; i < writeData.size(); ++i) { if ((writeData.at(i) & data.at(i)) != data.at(i)) return false; } @@ -642,7 +642,7 @@ QNearFieldTarget::RequestId QNearFieldTagType1::writeBlock(quint8 blockAddress, const QByteArray &data, WriteMode mode) { - if (data.length() != 8) + if (data.size() != 8) return QNearFieldTarget::RequestId(); QByteArray command; diff --git a/tests/auto/nfccommons/qnearfieldtagtype2.cpp b/tests/auto/nfccommons/qnearfieldtagtype2.cpp index 049567cf..62ddf5b1 100644 --- a/tests/auto/nfccommons/qnearfieldtagtype2.cpp +++ b/tests/auto/nfccommons/qnearfieldtagtype2.cpp @@ -171,7 +171,7 @@ QNearFieldTarget::RequestId QNearFieldTagType2::readBlock(quint8 blockAddress) QNearFieldTarget::RequestId QNearFieldTagType2::writeBlock(quint8 blockAddress, const QByteArray &data) { - if (data.length() != 4) + if (data.size() != 4) return QNearFieldTarget::RequestId(); QByteArray command; diff --git a/tests/auto/nfccommons/qnearfieldtarget_emulator.cpp b/tests/auto/nfccommons/qnearfieldtarget_emulator.cpp index 9c151c43..5359d366 100644 --- a/tests/auto/nfccommons/qnearfieldtarget_emulator.cpp +++ b/tests/auto/nfccommons/qnearfieldtarget_emulator.cpp @@ -52,7 +52,7 @@ QNearFieldTarget::RequestId TagType1::sendCommand(const QByteArray &command) return id; } - quint16 crc = qChecksum(QByteArrayView(command.constData(), command.length()), Qt::ChecksumItuV41); + quint16 crc = qChecksum(QByteArrayView(command.constData(), command.size()), Qt::ChecksumItuV41); QByteArray response = tag->processCommand(command + char(crc & 0xff) + char(crc >> 8)); @@ -62,7 +62,7 @@ QNearFieldTarget::RequestId TagType1::sendCommand(const QByteArray &command) } // check crc - if (qChecksum(QByteArrayView(response.constData(), response.length()), Qt::ChecksumItuV41) != 0) { + if (qChecksum(QByteArrayView(response.constData(), response.size()), Qt::ChecksumItuV41) != 0) { reportError(QNearFieldTarget::ChecksumMismatchError, id); return id; } @@ -117,16 +117,16 @@ QNearFieldTarget::RequestId TagType2::sendCommand(const QByteArray &command) return id; } - quint16 crc = qChecksum(QByteArrayView(command.constData(), command.length()), Qt::ChecksumItuV41); + quint16 crc = qChecksum(QByteArrayView(command.constData(), command.size()), Qt::ChecksumItuV41); QByteArray response = tag->processCommand(command + char(crc & 0xff) + char(crc >> 8)); if (response.isEmpty()) return id; - if (response.length() > 1) { + if (response.size() > 1) { // check crc - if (qChecksum(QByteArrayView(response.constData(), response.length()), Qt::ChecksumItuV41) != 0) { + if (qChecksum(QByteArrayView(response.constData(), response.size()), Qt::ChecksumItuV41) != 0) { reportError(QNearFieldTarget::ChecksumMismatchError, id); return id; } diff --git a/tests/auto/nfccommons/qtlv.cpp b/tests/auto/nfccommons/qtlv.cpp index b74365e9..46c19553 100644 --- a/tests/auto/nfccommons/qtlv.cpp +++ b/tests/auto/nfccommons/qtlv.cpp @@ -104,7 +104,7 @@ bool QTlvReader::atEnd() const if (m_requestId.isValid()) return false; - return (m_index == m_tlvData.length()) || (tag() == 0xfe); + return (m_index == m_tlvData.size()) || (tag() == 0xfe); } /*! @@ -204,8 +204,8 @@ QByteArray QTlvReader::data() bool QTlvReader::readMoreData(int sparseOffset) { - while (sparseOffset >= m_tlvData.length()) { - int absOffset = absoluteOffset(m_tlvData.length()); + while (sparseOffset >= m_tlvData.size()) { + int absOffset = absoluteOffset(m_tlvData.size()); QByteArray data; @@ -236,7 +236,7 @@ bool QTlvReader::readMoreData(int sparseOffset) } } - if (data.isEmpty() && sparseOffset >= m_tlvData.length()) + if (data.isEmpty() && sparseOffset >= m_tlvData.size()) return false; m_tlvData.append(data); @@ -307,7 +307,7 @@ void QTlvWriter::writeTlv(quint8 tagType, const QByteArray &data) m_buffer.append(tagType); if (tagType != 0x00 && tagType != 0xfe) { - int length = data.length(); + int length = data.size(); if (length < 0xff) { m_buffer.append(quint8(length)); } else { @@ -353,7 +353,7 @@ bool QTlvWriter::process(bool all) if (m_tagMemorySize == -1) { if (m_rawData) - m_tagMemorySize = m_rawData->length(); + m_tagMemorySize = m_rawData->size(); else if (QNearFieldTagType1 *tag = qobject_cast<QNearFieldTagType1 *>(m_target)) { if (m_requestId.isValid()) { m_tagMemorySize = 8 * (tag->requestResponse(m_requestId).toUInt() + 1); @@ -370,7 +370,7 @@ bool QTlvWriter::process(bool all) if (spaceRemaining < 1) return false; - int length = qMin(spaceRemaining, m_buffer.length()); + int length = qMin(spaceRemaining, m_buffer.size()); if (m_rawData) { m_rawData->replace(m_index, length, m_buffer); @@ -422,8 +422,8 @@ bool QTlvWriter::process(bool all) int fillLength = qMin(nextBlockStart - m_index, spaceRemaining - bufferIndex); - if (fillLength && (all || m_buffer.length() - bufferIndex >= fillLength) && - (m_buffer.length() != bufferIndex)) { + if (fillLength && (all || m_buffer.size() - bufferIndex >= fillLength) && + (m_buffer.size() != bufferIndex)) { // sufficient data available if (m_requestId.isValid()) { const QVariant v = tag->requestResponse(m_requestId); @@ -431,7 +431,7 @@ bool QTlvWriter::process(bool all) // read in block QByteArray block = v.toByteArray(); - int fill = qMin(fillLength, m_buffer.length() - bufferIndex); + int fill = qMin(fillLength, m_buffer.size() - bufferIndex); for (int i = m_index - currentBlockStart; i < fill; ++i) block[i] = m_buffer.at(bufferIndex++); @@ -441,7 +441,7 @@ bool QTlvWriter::process(bool all) return false; } else if (v.typeId() == QMetaType::Bool) { m_requestId = QNearFieldTarget::RequestId(); - int fill = qMin(fillLength, m_buffer.length() - bufferIndex); + int fill = qMin(fillLength, m_buffer.size() - bufferIndex); bufferIndex = fill - (m_index - currentBlockStart); // write complete diff --git a/tests/auto/nfccommons/targetemulator.cpp b/tests/auto/nfccommons/targetemulator.cpp index 49ea8a72..8a77989b 100644 --- a/tests/auto/nfccommons/targetemulator.cpp +++ b/tests/auto/nfccommons/targetemulator.cpp @@ -53,7 +53,7 @@ void NfcTagType1::load(QSettings *settings) qWarning("Only NFC TagType1 v1.0 behavior is supported."); quint8 tms = memory.at(10); - if (memory.length() != 8 * (tms + 1)) + if (memory.size() != 8 * (tms + 1)) qWarning("Static memory size does not match TMS value."); quint8 rwa = memory.at(11); @@ -102,7 +102,7 @@ QByteArray NfcTagType1::processCommand(const QByteArray &command) bool tagType1 = (hr0 & 0xf0) == 0x10; bool dynamic = (hr0 & 0x0f) != 0x01; - if (command.length() == 9) { + if (command.size() == 9) { // static memory model command quint8 opcode = command.at(0); quint8 address = command.at(1); @@ -110,7 +110,7 @@ QByteArray NfcTagType1::processCommand(const QByteArray &command) QByteArray uid = command.mid(3, 4); // check checksum - if (qChecksum(QByteArrayView(command.constData(), command.length()), Qt::ChecksumItuV41) != 0) + if (qChecksum(QByteArrayView(command.constData(), command.size()), Qt::ChecksumItuV41) != 0) return QByteArray(); // check UID @@ -171,7 +171,7 @@ QByteArray NfcTagType1::processCommand(const QByteArray &command) response.append(memory.left(4)); break; } - } else if (tagType1 && dynamic && command.length() == 16) { + } else if (tagType1 && dynamic && command.size() == 16) { // dynamic memory model command quint8 opcode = command.at(0); quint8 address = command.at(1); @@ -179,7 +179,7 @@ QByteArray NfcTagType1::processCommand(const QByteArray &command) QByteArray uid = command.mid(10, 4); // check checksum - if (qChecksum(QByteArrayView(command.constData(), command.length()), Qt::ChecksumItuV41) != 0) + if (qChecksum(QByteArrayView(command.constData(), command.size()), Qt::ChecksumItuV41) != 0) return QByteArray(); // check UID @@ -233,7 +233,7 @@ QByteArray NfcTagType1::processCommand(const QByteArray &command) } if (!response.isEmpty()) { - quint16 crc = qChecksum(QByteArrayView(response.constData(), response.length()), Qt::ChecksumItuV41); + quint16 crc = qChecksum(QByteArrayView(response.constData(), response.size()), Qt::ChecksumItuV41); response.append(quint8(crc & 0xff)); response.append(quint8(crc >> 8)); } @@ -277,13 +277,13 @@ QByteArray NfcTagType2::processCommand(const QByteArray &command) QByteArray response; // check checksum - if (qChecksum(QByteArrayView(command.constData(), command.length()), Qt::ChecksumItuV41) != 0) + if (qChecksum(QByteArrayView(command.constData(), command.size()), Qt::ChecksumItuV41) != 0) return QByteArray(); if (expectPacket2) { expectPacket2 = false; quint8 sector = command.at(0); - if (sector * 1024 > memory.length()) + if (sector * 1024 > memory.size()) return NACK; else { currentSector = sector; @@ -299,8 +299,8 @@ QByteArray NfcTagType2::processCommand(const QByteArray &command) int absoluteBlock = currentSector * 256 + block; response.append(memory.mid(absoluteBlock * 4, 16)); - if (response.length() != 16) - response.append(QByteArray(16 - response.length(), '\0')); + if (response.size() != 16) + response.append(QByteArray(16 - response.size(), '\0')); break; } @@ -319,7 +319,7 @@ QByteArray NfcTagType2::processCommand(const QByteArray &command) return ACK; } case 0xc2: // SECTOR SELECT - Packet 1 - if (memory.length() > 1024) { + if (memory.size() > 1024) { expectPacket2 = true; return ACK; } @@ -334,7 +334,7 @@ QByteArray NfcTagType2::processCommand(const QByteArray &command) } if (!response.isEmpty()) { - quint16 crc = qChecksum(QByteArrayView(response.constData(), response.length()), Qt::ChecksumItuV41); + quint16 crc = qChecksum(QByteArrayView(response.constData(), response.size()), Qt::ChecksumItuV41); response.append(quint8(crc & 0xff)); response.append(quint8(crc >> 8)); } diff --git a/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp b/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp index c1f2782b..6dbc0359 100644 --- a/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp +++ b/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp @@ -371,9 +371,9 @@ void tst_QBluetoothSocket::tst_clientCommunication() if (socket.openMode() & QIODevice::Unbuffered) QCOMPARE(socket.bytesToWrite(), qint64(0)); else - QCOMPARE(socket.bytesToWrite(), qint64(line.length())); + QCOMPARE(socket.bytesToWrite(), qint64(line.size())); - QCOMPARE(dataWritten, qint64(line.length())); + QCOMPARE(dataWritten, qint64(line.size())); int readWriteTime = MaxReadWriteTime; while ((bytesWrittenSpy.isEmpty() || readyReadSpy.isEmpty()) && readWriteTime > 0) { @@ -382,7 +382,7 @@ void tst_QBluetoothSocket::tst_clientCommunication() } QCOMPARE(bytesWrittenSpy.size(), 1); - QCOMPARE(bytesWrittenSpy.at(0).at(0).toLongLong(), qint64(line.length())); + QCOMPARE(bytesWrittenSpy.at(0).at(0).toLongLong(), qint64(line.size())); readWriteTime = MaxReadWriteTime; while (readyReadSpy.isEmpty() && readWriteTime > 0) { @@ -393,9 +393,9 @@ void tst_QBluetoothSocket::tst_clientCommunication() QCOMPARE(readyReadSpy.size(), 1); if (socket.openMode() & QIODevice::Unbuffered) - QVERIFY(socket.bytesAvailable() <= qint64(line.length())); + QVERIFY(socket.bytesAvailable() <= qint64(line.size())); else - QCOMPARE(socket.bytesAvailable(), qint64(line.length())); + QCOMPARE(socket.bytesAvailable(), qint64(line.size())); QVERIFY(socket.canReadLine()); @@ -420,9 +420,9 @@ void tst_QBluetoothSocket::tst_clientCommunication() if (socket.openMode() & QIODevice::Unbuffered) QCOMPARE(socket.bytesToWrite(), qint64(0)); else - QCOMPARE(socket.bytesToWrite(), qint64(joined.length())); + QCOMPARE(socket.bytesToWrite(), qint64(joined.size())); - QCOMPARE(dataWritten, qint64(joined.length())); + QCOMPARE(dataWritten, qint64(joined.size())); int readWriteTime = MaxReadWriteTime; while ((bytesWrittenSpy.isEmpty() || readyReadSpy.isEmpty()) && readWriteTime > 0) { @@ -431,13 +431,13 @@ void tst_QBluetoothSocket::tst_clientCommunication() } QCOMPARE(bytesWrittenSpy.size(), 1); - QCOMPARE(bytesWrittenSpy.at(0).at(0).toLongLong(), qint64(joined.length())); + QCOMPARE(bytesWrittenSpy.at(0).at(0).toLongLong(), qint64(joined.size())); QVERIFY(!readyReadSpy.isEmpty()); if (socket.openMode() & QIODevice::Unbuffered) - QVERIFY(socket.bytesAvailable() <= qint64(joined.length())); + QVERIFY(socket.bytesAvailable() <= qint64(joined.size())); else - QCOMPARE(socket.bytesAvailable(), qint64(joined.length())); + QCOMPARE(socket.bytesAvailable(), qint64(joined.size())); QVERIFY(socket.canReadLine()); diff --git a/tests/auto/qndefmessage/tst_qndefmessage.cpp b/tests/auto/qndefmessage/tst_qndefmessage.cpp index 738be927..8c4e8525 100644 --- a/tests/auto/qndefmessage/tst_qndefmessage.cpp +++ b/tests/auto/qndefmessage/tst_qndefmessage.cpp @@ -160,12 +160,12 @@ void tst_QNdefMessage::parseSingleRecordMessage_data() QByteArray data; data.append(char(0xcd)); // MB=1, ME=1, IL=1, TNF=5 - data.append(char(type.length())); // TYPE LENGTH - data.append(char((payload.length() >> 24) & 0xff)); // PAYLOAD LENGTH 3 - data.append(char((payload.length() >> 16) & 0xff)); // PAYLOAD LENGTH 2 - data.append(char((payload.length() >> 8) & 0xff)); // PAYLOAD LENGTH 1 - data.append(char((payload.length() >> 0) & 0xff)); // PAYLOAD LENGTH 0 - data.append(char(id.length())); // ID LENGTH + data.append(char(type.size())); // TYPE LENGTH + data.append(char((payload.size() >> 24) & 0xff)); // PAYLOAD LENGTH 3 + data.append(char((payload.size() >> 16) & 0xff)); // PAYLOAD LENGTH 2 + data.append(char((payload.size() >> 8) & 0xff)); // PAYLOAD LENGTH 1 + data.append(char((payload.size() >> 0) & 0xff)); // PAYLOAD LENGTH 0 + data.append(char(id.size())); // ID LENGTH data.append(type); data.append(id); data.append(payload); @@ -188,14 +188,14 @@ void tst_QNdefMessage::parseSingleRecordMessage_data() QByteArray data; data.append(char(0xbd)); // MB=1, CF=1, SR=1, IL=1, TNF=5 - data.append(char(type.length())); // TYPE LENGTH + data.append(char(type.size())); // TYPE LENGTH data.append(char(1)); // PAYLOAD LENGTH - data.append(char(id.length())); // ID LENGTH + data.append(char(id.size())); // ID LENGTH data.append(type); // TYPE data.append(id); // ID data.append(payload.at(0)); // PAYLOAD[0] - for (int i = 1; i < payload.length() - 1; ++i) { + for (int i = 1; i < payload.size() - 1; ++i) { data.append(char(0x36)); // CF=1, SR=1, TNF=6 data.append(char(0)); // TYPE LENGTH data.append(char(1)); // PAYLOAD LENGTH @@ -205,7 +205,7 @@ void tst_QNdefMessage::parseSingleRecordMessage_data() data.append(char(0x56)); // ME=1, SR=1, TNF=6 data.append(char(0)); // TYPE LENGTH data.append(char(1)); // PAYLOAD LENGTH - data.append(payload.at(payload.length() - 1)); // PAYLOAD[length - 1] + data.append(payload.at(payload.size() - 1)); // PAYLOAD[length - 1] QNdefRecord record; record.setTypeNameFormat(QNdefRecord::Unknown); @@ -231,11 +231,11 @@ void tst_QNdefMessage::parseSingleRecordMessage_data() QByteArray data; data.append(char(0xc1)); // MB=1, ME=1, IL=0, TNF=1 - data.append(char(type.length())); // TYPE LENGTH - data.append(char((payload.length() >> 24) & 0xff)); // PAYLOAD LENGTH 3 - data.append(char((payload.length() >> 16) & 0xff)); // PAYLOAD LENGTH 2 - data.append(char((payload.length() >> 8) & 0xff)); // PAYLOAD LENGTH 1 - data.append(char((payload.length() >> 0) & 0xff)); // PAYLOAD LENGTH 0 + data.append(char(type.size())); // TYPE LENGTH + data.append(char((payload.size() >> 24) & 0xff)); // PAYLOAD LENGTH 3 + data.append(char((payload.size() >> 16) & 0xff)); // PAYLOAD LENGTH 2 + data.append(char((payload.size() >> 8) & 0xff)); // PAYLOAD LENGTH 1 + data.append(char((payload.size() >> 0) & 0xff)); // PAYLOAD LENGTH 0 data.append(type); data.append(payload); @@ -265,11 +265,11 @@ void tst_QNdefMessage::parseSingleRecordMessage_data() QByteArray data; data.append(char(0xc1)); // MB=1, ME=1, IL=0, TNF=1 - data.append(char(type.length())); // TYPE LENGTH - data.append(char((payload.length() >> 24) & 0xff)); // PAYLOAD LENGTH 3 - data.append(char((payload.length() >> 16) & 0xff)); // PAYLOAD LENGTH 2 - data.append(char((payload.length() >> 8) & 0xff)); // PAYLOAD LENGTH 1 - data.append(char((payload.length() >> 0) & 0xff)); // PAYLOAD LENGTH 0 + data.append(char(type.size())); // TYPE LENGTH + data.append(char((payload.size() >> 24) & 0xff)); // PAYLOAD LENGTH 3 + data.append(char((payload.size() >> 16) & 0xff)); // PAYLOAD LENGTH 2 + data.append(char((payload.size() >> 8) & 0xff)); // PAYLOAD LENGTH 1 + data.append(char((payload.size() >> 0) & 0xff)); // PAYLOAD LENGTH 0 data.append(type); data.append(payload); @@ -300,11 +300,11 @@ void tst_QNdefMessage::parseSingleRecordMessage_data() QByteArray data; data.append(char(0xc1)); - data.append(char(type.length())); - data.append(char((payload.length() >> 24) & 0xff)); // PAYLOAD LENGTH 3 - data.append(char((payload.length() >> 16) & 0xff)); // PAYLOAD LENGTH 2 - data.append(char((payload.length() >> 8) & 0xff)); // PAYLOAD LENGTH 1 - data.append(char((payload.length() >> 0) & 0xff)); // PAYLOAD LENGTH 0 + data.append(char(type.size())); + data.append(char((payload.size() >> 24) & 0xff)); // PAYLOAD LENGTH 3 + data.append(char((payload.size() >> 16) & 0xff)); // PAYLOAD LENGTH 2 + data.append(char((payload.size() >> 8) & 0xff)); // PAYLOAD LENGTH 1 + data.append(char((payload.size() >> 0) & 0xff)); // PAYLOAD LENGTH 0 data.append(type); data.append(payload); @@ -333,11 +333,11 @@ void tst_QNdefMessage::parseSingleRecordMessage_data() QByteArray data; data.append(char(0xc1)); - data.append(char(type.length())); - data.append(char((payload.length() >> 24) & 0xff)); // PAYLOAD LENGTH 3 - data.append(char((payload.length() >> 16) & 0xff)); // PAYLOAD LENGTH 2 - data.append(char((payload.length() >> 8) & 0xff)); // PAYLOAD LENGTH 1 - data.append(char((payload.length() >> 0) & 0xff)); // PAYLOAD LENGTH 0 + data.append(char(type.size())); + data.append(char((payload.size() >> 24) & 0xff)); // PAYLOAD LENGTH 3 + data.append(char((payload.size() >> 16) & 0xff)); // PAYLOAD LENGTH 2 + data.append(char((payload.size() >> 8) & 0xff)); // PAYLOAD LENGTH 1 + data.append(char((payload.size() >> 0) & 0xff)); // PAYLOAD LENGTH 0 data.append(type); data.append(payload); @@ -366,11 +366,11 @@ void tst_QNdefMessage::parseSingleRecordMessage_data() QByteArray data; data.append(char(0xc1)); - data.append(char(type.length())); - data.append(char((payload.length() >> 24) & 0xff)); // PAYLOAD LENGTH 3 - data.append(char((payload.length() >> 16) & 0xff)); // PAYLOAD LENGTH 2 - data.append(char((payload.length() >> 8) & 0xff)); // PAYLOAD LENGTH 1 - data.append(char((payload.length() >> 0) & 0xff)); // PAYLOAD LENGTH 0 + data.append(char(type.size())); + data.append(char((payload.size() >> 24) & 0xff)); // PAYLOAD LENGTH 3 + data.append(char((payload.size() >> 16) & 0xff)); // PAYLOAD LENGTH 2 + data.append(char((payload.size() >> 8) & 0xff)); // PAYLOAD LENGTH 1 + data.append(char((payload.size() >> 0) & 0xff)); // PAYLOAD LENGTH 0 data.append(type); data.append(payload); @@ -403,19 +403,19 @@ void tst_QNdefMessage::parseSingleRecordMessage_data() QByteArray data; data.append(char(0xB9)); // MB=1, ME=0, CF=1, SR=1, IL=1, TNF=1 (NFC-RTD) - data.append(type.length()); - data.append(payload1.length() & 0xff); // length fits into 1 byte - data.append(id.length()); + data.append(type.size()); + data.append(payload1.size() & 0xff); // length fits into 1 byte + data.append(id.size()); data.append(type); data.append(id); data.append(payload1); data.append(char(0x36)); // MB=0, ME=0, CF=1, SR=1, IL=0, TNF=6 (Unchanged) data.append(char(0x00)); - data.append(payload2.length()); + data.append(payload2.size()); data.append(payload2); data.append(char(0x56)); // MB=0, ME=1, CF=0, SR=1, IL=0, TNF=6 (Unchanged) data.append(char(0x00)); - data.append(payload3.length()); + data.append(payload3.size()); data.append(payload3); QNdefRecord record; @@ -442,22 +442,22 @@ void tst_QNdefMessage::parseSingleRecordMessage_data() QTest::newRow("truncated 1") << data << QNdefMessage() << QVariantList(); - data.append(char(type.length())); // TYPE LENGTH + data.append(char(type.size())); // TYPE LENGTH QTest::newRow("truncated 2") << data << QNdefMessage() << QVariantList(); - data.append(char((payload.length() >> 24) & 0xff)); // PAYLOAD LENGTH 3 + data.append(char((payload.size() >> 24) & 0xff)); // PAYLOAD LENGTH 3 QTest::newRow("truncated 3") << data << QNdefMessage() << QVariantList(); - data.append(char((payload.length() >> 16) & 0xff)); // PAYLOAD LENGTH 2 + data.append(char((payload.size() >> 16) & 0xff)); // PAYLOAD LENGTH 2 QTest::newRow("truncated 4") << data << QNdefMessage() << QVariantList(); - data.append(char((payload.length() >> 8) & 0xff)); // PAYLOAD LENGTH 1 + data.append(char((payload.size() >> 8) & 0xff)); // PAYLOAD LENGTH 1 QTest::newRow("truncated 5") << data << QNdefMessage() << QVariantList(); - data.append(char((payload.length() >> 0) & 0xff)); // PAYLOAD LENGTH 0 + data.append(char((payload.size() >> 0) & 0xff)); // PAYLOAD LENGTH 0 QTest::newRow("truncated 6") << data << QNdefMessage() << QVariantList(); - data.append(char(id.length())); // ID LENGTH + data.append(char(id.size())); // ID LENGTH QTest::newRow("truncated 7") << data << QNdefMessage() << QVariantList(); data.append(type); diff --git a/tests/auto/qndefnfcsmartposterrecord/tst_qndefnfcsmartposterrecord.cpp b/tests/auto/qndefnfcsmartposterrecord/tst_qndefnfcsmartposterrecord.cpp index 37ee9ff9..f3ec7c2a 100644 --- a/tests/auto/qndefnfcsmartposterrecord/tst_qndefnfcsmartposterrecord.cpp +++ b/tests/auto/qndefnfcsmartposterrecord/tst_qndefnfcsmartposterrecord.cpp @@ -532,7 +532,7 @@ void tst_QNdefNfcSmartPosterRecord::tst_downcast() QByteArray spPayload = sprecord.payload(); // Check length is longer on the base - QVERIFY(basePayload.length() > record.payload().length()); + QVERIFY(basePayload.size() > record.payload().size()); // Check the payloads are the same QCOMPARE(basePayload, spPayload); diff --git a/tests/auto/qnearfieldtagtype1/tst_qnearfieldtagtype1.cpp b/tests/auto/qnearfieldtagtype1/tst_qnearfieldtagtype1.cpp index 87e37db2..6e2bea6b 100644 --- a/tests/auto/qnearfieldtagtype1/tst_qnearfieldtagtype1.cpp +++ b/tests/auto/qnearfieldtagtype1/tst_qnearfieldtagtype1.cpp @@ -94,7 +94,7 @@ void tst_QNearFieldTagType1::staticMemoryModel() const QByteArray data = target->requestResponse(id).toByteArray(); - QCOMPARE(data.length(), 6); + QCOMPARE(data.size(), 6); quint8 hr0 = data.at(0); //quint8 hr1 = data.at(1); @@ -113,7 +113,7 @@ void tst_QNearFieldTagType1::staticMemoryModel() QVERIFY(target->waitForRequestCompleted(id)); const QByteArray data = target->requestResponse(id).toByteArray(); - QCOMPARE(data.length(), 122); + QCOMPARE(data.size(), 122); // verify NfcTagType1. QVERIFY(data.at(0) & 0x10); diff --git a/tests/bttestui/btlocaldevice.cpp b/tests/bttestui/btlocaldevice.cpp index e708da51..16f5bc98 100644 --- a/tests/bttestui/btlocaldevice.cpp +++ b/tests/bttestui/btlocaldevice.cpp @@ -198,7 +198,7 @@ void BtLocalDevice::deviceDiscovered(const QBluetoothDeviceInfo &info) if (info.serviceClasses() & QBluetoothDeviceInfo::InformationService) services += "Information|"; - services.truncate(services.length()-1); //cut last '/' + services.truncate(services.size()-1); //cut last '/' qDebug() << "Found new device: " << info.name() << info.isValid() << info.address().toString() << info.rssi() << info.majorDeviceClass() @@ -493,7 +493,7 @@ void BtLocalDevice::readData() qDebug() << ">> peer(" << socket->peerName() << socket->peerAddress() << socket->peerPort() << ") local(" << socket->localName() << socket->localAddress() << socket->localPort() - << ")>>" << QString::fromUtf8(line.constData(), line.length()); + << ")>>" << QString::fromUtf8(line.constData(), line.size()); } } } @@ -655,7 +655,7 @@ void BtLocalDevice::clientSocketReadyRead() while (socket->canReadLine()) { const QByteArray line = socket->readLine().trimmed(); - QString lineString = QString::fromUtf8(line.constData(), line.length()); + QString lineString = QString::fromUtf8(line.constData(), line.size()); qDebug() << ">>(" << server->serverAddress() << server->serverPort() <<")>>" << lineString; |