diff options
author | Marc Mutz <marc.mutz@qt.io> | 2022-10-05 07:29:16 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2022-10-07 23:38:48 +0200 |
commit | 958cd3ee1094a068b6d0ff27c73a4b3caff088ad (patch) | |
tree | 6d3816fedf5dab2307675fd6ef70d39758e246f5 /tests/auto/qml/qmlcppcodegen | |
parent | e8e03215654ca730243336a80453cf9396cbdf58 (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: Idb1f75dfe2323bd1d9e8b4d58d54f1b4b80c7ed7
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/qml/qmlcppcodegen')
-rw-r--r-- | tests/auto/qml/qmlcppcodegen/data/birthdayparty.cpp | 2 | ||||
-rw-r--r-- | tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp | 12 |
2 files changed, 7 insertions, 7 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/data/birthdayparty.cpp b/tests/auto/qml/qmlcppcodegen/data/birthdayparty.cpp index 4ba76d882d..048459f03a 100644 --- a/tests/auto/qml/qmlcppcodegen/data/birthdayparty.cpp +++ b/tests/auto/qml/qmlcppcodegen/data/birthdayparty.cpp @@ -28,7 +28,7 @@ QQmlListProperty<Person> BirthdayParty::guests() int BirthdayParty::guestCount() const { - return m_guests.count(); + return m_guests.size(); } Person *BirthdayParty::guest(int index) const diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp index 011b496383..19acf4fc78 100644 --- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp +++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp @@ -247,7 +247,7 @@ void tst_QmlCppCodegen::idAccess() static QByteArray arg1() { const QStringList args = QCoreApplication::instance()->arguments(); - return args.length() > 1 ? args[1].toUtf8() : QByteArray("undefined"); + return args.size() > 1 ? args[1].toUtf8() : QByteArray("undefined"); } void tst_QmlCppCodegen::globals() @@ -299,7 +299,7 @@ void tst_QmlCppCodegen::multiLookup() QSignalSpy quitSpy(&engine, &QQmlEngine::quit); QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); - QCOMPARE(quitSpy.count(), 1); + QCOMPARE(quitSpy.size(), 1); } void tst_QmlCppCodegen::enums() @@ -393,7 +393,7 @@ void tst_QmlCppCodegen::compositeTypeMethod() QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); QSignalSpy spy(object.data(), SIGNAL(foo())); - QTRY_VERIFY(spy.count() > 0); + QTRY_VERIFY(spy.size() > 0); } void tst_QmlCppCodegen::excessiveParameters() @@ -404,7 +404,7 @@ void tst_QmlCppCodegen::excessiveParameters() QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); QSignalSpy spy(object.data(), SIGNAL(foo())); - QTRY_VERIFY(spy.count() > 0); + QTRY_VERIFY(spy.size() > 0); } void tst_QmlCppCodegen::jsImport() @@ -1010,7 +1010,7 @@ void tst_QmlCppCodegen::lotsOfRegisters() }; for (int i = 0; i < 100; ++i) { - QVERIFY(object->setProperty(props[i % props.length()], (i * 17) % 512)); + QVERIFY(object->setProperty(props[i % props.size()], (i * 17) % 512)); compare(); } } @@ -2655,7 +2655,7 @@ void tst_QmlCppCodegen::mathOperations() const QMetaProperty prop = metaObject->property(i); const QByteArray propName = prop.name(); - if (propName.length() < 3 || propName == "objectName") + if (propName.size() < 3 || propName == "objectName") continue; t1 = propName[0]; |