diff options
author | Marc Mutz <marc.mutz@qt.io> | 2022-10-05 07:55:09 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2022-10-07 14:39:14 +0200 |
commit | e544b849cfc09b07d2e71766b7671b3fb9933eae (patch) | |
tree | 0a813decb2ca8d2717ce31906448bb63d554ffdd /tests | |
parent | 9be25ac715ebf882bf1679abd81ad9c58f0bd20b (diff) |
Port from container::count() and length() to size()
This is a semantic patch using ClangTidyTransformator as in
qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8:
auto QtContainerClass = anyOf(
expr(hasType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes))))).bind(o),
expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o));
makeRule(cxxMemberCallExpr(on(QtContainerClass),
callee(cxxMethodDecl(hasAnyName({"count", "length"),
parameterCountIs(0))))),
changeTo(cat(access(o, cat("size"), "()"))),
cat("use 'size()' instead of 'count()/length()'"))
a.k.a qt-port-to-std-compatible-api with config Scope: 'Container',
with the extended set of container classes recognized.
Change-Id: I126d264a62c9db96ed1b3b37781d2eeea4e2acab
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/oauth1/tst_oauth1.cpp | 16 | ||||
-rw-r--r-- | tests/auto/oauth2/tst_oauth2.cpp | 10 | ||||
-rw-r--r-- | tests/auto/oauthhttpserverreplyhandler/tst_oauthhttpserverreplyhandler.cpp | 2 |
3 files changed, 14 insertions, 14 deletions
diff --git a/tests/auto/oauth1/tst_oauth1.cpp b/tests/auto/oauth1/tst_oauth1.cpp index f8d8c2e..4dbbf76 100644 --- a/tests/auto/oauth1/tst_oauth1.cpp +++ b/tests/auto/oauth1/tst_oauth1.cpp @@ -80,7 +80,7 @@ public: setter(&expectedValue, &obj); QVERIFY(previous != expectedValue); // To check if the value was modified } - QCOMPARE(spy.count(), setters.size()); // The signal should be emitted + QCOMPARE(spy.size(), setters.size()); // The signal should be emitted } public: @@ -180,11 +180,11 @@ int tst_OAuth1::waitForFinish(QNetworkReplyPtr &reply) QSignalSpy spy(reply.data(), SIGNAL(downloadProgress(qint64,qint64))); while (!reply->isFinished()) { QTimer::singleShot(5000, loop, SLOT(quit())); - if (loop->exec() == Timeout && count == spy.count() && !reply->isFinished()) { + if (loop->exec() == Timeout && count == spy.size() && !reply->isFinished()) { returnCode = Timeout; break; } - count = spy.count(); + count = spy.size(); } delete loop; loop = nullptr; @@ -639,18 +639,18 @@ void tst_OAuth1::grant() QSignalSpy clientIdentifierSpy(&o1, &QOAuth1::clientIdentifierChanged); QSignalSpy clientSharedSecretSpy(&o1, &QOAuth1::clientSharedSecretChanged); o1.setClientCredentials(consumerKey, consumerSecret); - QCOMPARE(clientIdentifierSpy.count(), 1); - QCOMPARE(clientSharedSecretSpy.count(), 1); + QCOMPARE(clientIdentifierSpy.size(), 1); + QCOMPARE(clientSharedSecretSpy.size(), 1); } { QSignalSpy spy(&o1, &QOAuth1::temporaryCredentialsUrlChanged); o1.setTemporaryCredentialsUrl(requestTokenUrl); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); } { QSignalSpy spy(&o1, &QOAuth1::tokenCredentialsUrlChanged); o1.setTokenCredentialsUrl(accessTokenUrl); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); } connect(&o1, &QAbstractOAuth::statusChanged, [&](QAbstractOAuth::Status status) { if (status == QAbstractOAuth::Status::TemporaryCredentialsReceived) { @@ -676,7 +676,7 @@ void tst_OAuth1::grant() o1.grant(); eventLoop.exec(); QVERIFY(tokenReceived); - QCOMPARE(grantSignalSpy.count(), 1); + QCOMPARE(grantSignalSpy.size(), 1); QCOMPARE(o1.status(), QAbstractOAuth::Status::Granted); } diff --git a/tests/auto/oauth2/tst_oauth2.cpp b/tests/auto/oauth2/tst_oauth2.cpp index d61a06d..4aa4f66 100644 --- a/tests/auto/oauth2/tst_oauth2.cpp +++ b/tests/auto/oauth2/tst_oauth2.cpp @@ -92,7 +92,7 @@ void tst_OAuth2::getToken() }); QSignalSpy grantedSpy(&oauth2, &QOAuth2AuthorizationCodeFlow::granted); oauth2.grant(); - QTRY_COMPARE(grantedSpy.count(), 1); + QTRY_COMPARE(grantedSpy.size(), 1); QCOMPARE(oauth2.token(), QLatin1String("token")); } @@ -117,7 +117,7 @@ void tst_OAuth2::refreshToken() oauth2.setRefreshToken(QLatin1String("refresh_token")); QSignalSpy grantedSpy(&oauth2, &QOAuth2AuthorizationCodeFlow::granted); oauth2.refreshAccessToken(); - QTRY_COMPARE(grantedSpy.count(), 1); + QTRY_COMPARE(grantedSpy.size(), 1); QCOMPARE(oauth2.token(), QLatin1String("token")); } @@ -155,11 +155,11 @@ void tst_OAuth2::getAndRefreshToken() }); QSignalSpy grantedSpy(&oauth2, &QOAuth2AuthorizationCodeFlow::granted); oauth2.grant(); - QTRY_COMPARE(grantedSpy.count(), 1); + QTRY_COMPARE(grantedSpy.size(), 1); QCOMPARE(oauth2.token(), QLatin1String("authorization_code")); grantedSpy.clear(); oauth2.refreshAccessToken(); - QTRY_COMPARE(grantedSpy.count(), 1); + QTRY_COMPARE(grantedSpy.size(), 1); QCOMPARE(oauth2.token(), QLatin1String("refresh_token")); } @@ -282,7 +282,7 @@ void tst_OAuth2::tlsAuthentication() QSignalSpy grantedSpy(&oauth2, &QOAuth2AuthorizationCodeFlow::granted); oauth2.grant(); - QTRY_COMPARE(grantedSpy.count(), 1); + QTRY_COMPARE(grantedSpy.size(), 1); QCOMPARE(oauth2.token(), QLatin1String("token")); } #endif // !QT_NO_SSL diff --git a/tests/auto/oauthhttpserverreplyhandler/tst_oauthhttpserverreplyhandler.cpp b/tests/auto/oauthhttpserverreplyhandler/tst_oauthhttpserverreplyhandler.cpp index b0b7c27..92ae153 100644 --- a/tests/auto/oauthhttpserverreplyhandler/tst_oauthhttpserverreplyhandler.cpp +++ b/tests/auto/oauthhttpserverreplyhandler/tst_oauthhttpserverreplyhandler.cpp @@ -43,7 +43,7 @@ void tst_QOAuthHttpServerReplyHandler::callback() QNetworkReplyPtr reply; reply.reset(networkAccessManager.get(request)); eventLoop.exec(); - QCOMPARE(count, query.queryItems().count()); + QCOMPARE(count, query.queryItems().size()); } QTEST_MAIN(tst_QOAuthHttpServerReplyHandler) |