From 65859635830b1476ce5c3e22f86438a08d4894cf Mon Sep 17 00:00:00 2001 From: Sona Kurazyan Date: Fri, 4 Mar 2022 15:56:34 +0100 Subject: Deprecate {QString, QByteArray}::count() And remove their uses. [ChangeLog][QtCore][Deprecation Notice] Deprecated QString::count() and QByteArray::count() that take no parameters, to avoid confusion with the algorithm overloads of the same name. They can be replaced by size() or length() methods. Change-Id: I6541e3235ab58cf750d89568d66d3b1d9bbd4a04 Reviewed-by: Thiago Macieira --- tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp | 5 +++++ tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp | 2 +- .../network/access/qnetworkreply/tst_qnetworkreply.cpp | 18 +++++++++--------- tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp | 6 +++--- tests/auto/tools/moc/tst_moc.cpp | 4 ++-- .../widgets/dialogs/qfiledialog/tst_qfiledialog.cpp | 2 +- .../widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp | 2 +- tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp | 2 +- 8 files changed, 23 insertions(+), 18 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp b/tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp index 37b9c90ab4..91611dd0b0 100644 --- a/tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp +++ b/tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp @@ -2515,7 +2515,12 @@ void tst_QByteArray::length() QCOMPARE(src.length(), res); QCOMPARE(src.size(), res); +#if QT_DEPRECATED_SINCE(6, 4) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED QCOMPARE(src.count(), res); +QT_WARNING_POP +#endif } void tst_QByteArray::length_data() diff --git a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp index 32a0374fcd..921c6d46f2 100644 --- a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp +++ b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp @@ -1084,7 +1084,7 @@ void tst_QTextLayout::defaultWordSeparators_data() QString separators(".,:;-<>[](){}=/+%&^*"); separators += QLatin1String("!?"); - for (int i = 0; i < separators.count(); ++i) { + for (int i = 0; i < separators.size(); ++i) { QTest::newRow(QString::number(i).toLatin1().data()) << QString::fromLatin1("abcd") + separators.at(i) + QString::fromLatin1("efgh") << 0 << 4; diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp index 23c4ed8772..a39e04e58e 100644 --- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp @@ -2724,8 +2724,8 @@ void tst_QNetworkReply::postToHttpMultipart() QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200); // 200 Ok - QVERIFY(multiPart->boundary().count() > 20); // check that there is randomness after the "boundary_.oOo._" string - QVERIFY(multiPart->boundary().count() < 70); + QVERIFY(multiPart->boundary().size() > 20); // check that there is randomness after the "boundary_.oOo._" string + QVERIFY(multiPart->boundary().size() < 70); QByteArray replyData = reply->readAll(); expectedReplyData.prepend("content type: multipart/" + contentType + "; boundary=\"" + multiPart->boundary() + "\"\n"); @@ -2812,8 +2812,8 @@ void tst_QNetworkReply::putToHttpMultipart() QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200); // 200 Ok - QVERIFY(multiPart->boundary().count() > 20); // check that there is randomness after the "boundary_.oOo._" string - QVERIFY(multiPart->boundary().count() < 70); + QVERIFY(multiPart->boundary().size() > 20); // check that there is randomness after the "boundary_.oOo._" string + QVERIFY(multiPart->boundary().size() < 70); QByteArray replyData = reply->readAll(); expectedReplyData.prepend("content type: multipart/" + contentType + "; boundary=\"" + multiPart->boundary() + "\"\n"); @@ -3030,8 +3030,8 @@ void tst_QNetworkReply::postToHttpsMultipart() QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200); // 200 Ok - QVERIFY(multiPart->boundary().count() > 20); // check that there is randomness after the "boundary_.oOo._" string - QVERIFY(multiPart->boundary().count() < 70); + QVERIFY(multiPart->boundary().size() > 20); // check that there is randomness after the "boundary_.oOo._" string + QVERIFY(multiPart->boundary().size() < 70); QByteArray replyData = reply->readAll(); expectedReplyData.prepend("content type: multipart/" + contentType + "; boundary=\"" + multiPart->boundary() + "\"\n"); @@ -9013,8 +9013,8 @@ void tst_QNetworkReply::ioHttpRedirectMultipartPost() QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200); // 200 OK - QVERIFY(multiPart->boundary().count() > 20); // check that there is randomness after the "boundary_.oOo._" string - QVERIFY(multiPart->boundary().count() < 70); + QVERIFY(multiPart->boundary().size() > 20); // check that there is randomness after the "boundary_.oOo._" string + QVERIFY(multiPart->boundary().size() < 70); QByteArray replyData = reply->readAll(); expectedReplyData.prepend("content type: multipart/" + contentType + "; boundary=\"" + multiPart->boundary() + "\"\n"); @@ -9179,7 +9179,7 @@ public slots: } if (m_receivedData.length() > 0 && !m_expectedData.startsWith(m_receivedData)) { // We had received some data but it is corrupt! - qDebug() << "CORRUPT" << m_receivedData.count(); + qDebug() << "CORRUPT" << m_receivedData.size(); #if 0 // Use this to track down the pattern of the corruption and conclude the source QFile a("/tmp/corrupt"); diff --git a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp index 5b7b8f312b..d10396b941 100644 --- a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp +++ b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp @@ -844,9 +844,9 @@ void tst_QSqlQuery::oraClob() QVERIFY_SQL(q, exec(QLatin1String("select bl, cl from %1 where id = 3").arg(clobby))); QVERIFY(q.next()); - QCOMPARE(q.value(0).toString().count(), loong.count()); + QCOMPARE(q.value(0).toString().size(), loong.size()); QVERIFY(q.value(0).toString() == loong); // Deliberately not QCOMPARE() as too long - QCOMPARE(q.value(1).toByteArray().count(), loong.toLatin1().count()); + QCOMPARE(q.value(1).toByteArray().size(), loong.toLatin1().size()); QVERIFY(q.value(1).toByteArray() == loong.toLatin1()); // ditto } @@ -868,7 +868,7 @@ void tst_QSqlQuery::oraClobBatch() QVERIFY_SQL(q, exec("select cl from " + clobBatch)); QVERIFY(q.next()); - QCOMPARE(q.value(0).toString().count(), longString.size()); + QCOMPARE(q.value(0).toString().size(), longString.size()); QVERIFY(q.value(0).toString() == longString); // As above. deliberately not QCOMPARE(). } diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp index 7f4b431c81..5a129e78eb 100644 --- a/tests/auto/tools/moc/tst_moc.cpp +++ b/tests/auto/tools/moc/tst_moc.cpp @@ -1288,9 +1288,9 @@ void tst_Moc::winNewline() QVERIFY(f.open(QIODevice::ReadOnly)); // no QIODevice::Text! QByteArray data = f.readAll(); f.close(); - for (int i = 0; i < data.count(); ++i) { + for (int i = 0; i < data.size(); ++i) { if (data.at(i) == QLatin1Char('\r')) { - QVERIFY(i < data.count() - 1); + QVERIFY(i < data.size() - 1); ++i; QCOMPARE(data.at(i), '\n'); } else { diff --git a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp index 877c61fb64..e1833a3716 100644 --- a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp +++ b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp @@ -530,7 +530,7 @@ void tst_QFiledialog::completer() } // press 'keys' for the input - for (int i = 0; i < input.count(); ++i) + for (int i = 0; i < input.size(); ++i) QTest::keyPress(lineEdit, input[i].toLatin1()); QStringList expectedFiles; diff --git a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp index 8261bd85d6..3c6c80a1e3 100644 --- a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp +++ b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp @@ -825,7 +825,7 @@ void tst_QFileDialog2::task203703_returnProperSeparator() QVERIFY(button); QTest::keyClick(button, Qt::Key_Return); QString result = fd.selectedFiles().first(); - QVERIFY(result.at(result.count() - 1) != '/'); + QVERIFY(result.at(result.size() - 1) != '/'); QVERIFY(!result.contains('\\')); current.rmdir("aaaaaaaaaaaaaaaaaa"); } diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index b9675b1c0d..ea0d5e8871 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -4019,7 +4019,7 @@ void tst_QWidget::restoreVersion1Geometry() QVERIFY(f.exists()); f.open(QIODevice::ReadOnly); const QByteArray savedGeometry = f.readAll(); - QCOMPARE(savedGeometry.count(), 46); + QCOMPARE(savedGeometry.size(), 46); f.close(); QWidget widget; -- cgit v1.2.3