diff options
author | Marc Mutz <marc.mutz@qt.io> | 2022-10-08 19:56:03 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2022-10-13 00:18:35 +0200 |
commit | 5eb52b725526c26d0efa3856b6aba1919010f8fd (patch) | |
tree | 64d1bde7a2cc624e586228c9768c7eb1ea360e6c /tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp | |
parent | e1a0596924766d62459740ed0271114a7bb99851 (diff) |
Port from container::count() and length() to size() - V5
This is a semantic patch using ClangTidyTransformator as in
qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8, but extended to
handle typedefs and accesses through pointers, too:
const std::string o = "object";
auto hasTypeIgnoringPointer = [](auto type) { return anyOf(hasType(type), hasType(pointsTo(type))); };
auto derivedFromAnyOfClasses = [&](ArrayRef<StringRef> classes) {
auto exprOfDeclaredType = [&](auto decl) {
return expr(hasTypeIgnoringPointer(hasUnqualifiedDesugaredType(recordType(hasDeclaration(decl))))).bind(o);
};
return exprOfDeclaredType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes))));
};
auto renameMethod = [&] (ArrayRef<StringRef> classes,
StringRef from, StringRef to) {
return makeRule(cxxMemberCallExpr(on(derivedFromAnyOfClasses(classes)),
callee(cxxMethodDecl(hasName(from), parameterCountIs(0)))),
changeTo(cat(access(o, cat(to)), "()")),
cat("use '", to, "' instead of '", from, "'"));
};
renameMethod(<classes>, "count", "size");
renameMethod(<classes>, "length", "size");
except that on() was replaced with a matcher that doesn't ignoreParens().
a.k.a qt-port-to-std-compatible-api V5 with config Scope: 'Container'.
Change-Id: I58e1b41b91c34d2e860dbb5847b3752edbfc6fc9
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp')
-rw-r--r-- | tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index 254b19c9e2..904f54912c 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -779,7 +779,7 @@ void tst_qqmllanguage::simpleContainer() VERIFY_ERRORS(0); QScopedPointer<MyContainer> container(qobject_cast<MyContainer*>(component.create())); QVERIFY(container != nullptr); - QCOMPARE(container->getChildren()->count(),2); + QCOMPARE(container->getChildren()->size(),2); } void tst_qqmllanguage::interfaceProperty() @@ -798,7 +798,7 @@ void tst_qqmllanguage::interfaceQList() VERIFY_ERRORS(0); QScopedPointer<MyContainer> container(qobject_cast<MyContainer*>(component.create())); QVERIFY(container != nullptr); - QCOMPARE(container->getQListInterfaces()->count(), 2); + QCOMPARE(container->getQListInterfaces()->size(), 2); for(int ii = 0; ii < 2; ++ii) QCOMPARE(container->getQListInterfaces()->at(ii)->id, 913); } @@ -839,7 +839,7 @@ void tst_qqmllanguage::assignQmlComponent() VERIFY_ERRORS(0); QScopedPointer<MyContainer> object(qobject_cast<MyContainer *>(component.create())); QVERIFY(object != nullptr); - QCOMPARE(object->getChildren()->count(), 1); + QCOMPARE(object->getChildren()->size(), 1); QObject *child = object->getChildren()->at(0); QCOMPARE(child->property("x"), QVariant(10)); QCOMPARE(child->property("y"), QVariant(11)); @@ -1365,7 +1365,7 @@ void tst_qqmllanguage::rootAsQmlComponent() QScopedPointer<MyContainer> object(qobject_cast<MyContainer *>(component.create())); QVERIFY(object != nullptr); QCOMPARE(object->property("x"), QVariant(11)); - QCOMPARE(object->getChildren()->count(), 2); + QCOMPARE(object->getChildren()->size(), 2); } void tst_qqmllanguage::rootItemIsComponent() @@ -1397,7 +1397,7 @@ void tst_qqmllanguage::inlineQmlComponents() VERIFY_ERRORS(0); QScopedPointer<MyContainer> object(qobject_cast<MyContainer *>(component.create())); QVERIFY(object != nullptr); - QCOMPARE(object->getChildren()->count(), 1); + QCOMPARE(object->getChildren()->size(), 1); QQmlComponent *comp = qobject_cast<QQmlComponent *>(object->getChildren()->at(0)); QVERIFY(comp != nullptr); QScopedPointer<MyQmlObject> compObject(qobject_cast<MyQmlObject *>(comp->create())); @@ -1413,7 +1413,7 @@ void tst_qqmllanguage::idProperty() VERIFY_ERRORS(0); QScopedPointer<MyContainer> object(qobject_cast<MyContainer *>(component.create())); QVERIFY(object != nullptr); - QCOMPARE(object->getChildren()->count(), 2); + QCOMPARE(object->getChildren()->size(), 2); MyTypeObject *child = qobject_cast<MyTypeObject *>(object->getChildren()->at(0)); QVERIFY(child != nullptr); @@ -2704,7 +2704,7 @@ void tst_qqmllanguage::defaultPropertyListOrder() QScopedPointer<MyContainer> container(qobject_cast<MyContainer *>(component.create())); QVERIFY(container != nullptr); - QCOMPARE(container->getChildren()->count(), 6); + QCOMPARE(container->getChildren()->size(), 6); QCOMPARE(container->getChildren()->at(0)->property("index"), QVariant(0)); QCOMPARE(container->getChildren()->at(1)->property("index"), QVariant(1)); QCOMPARE(container->getChildren()->at(2)->property("index"), QVariant(2)); @@ -5144,7 +5144,7 @@ void tst_qqmllanguage::executeDeferredPropertiesOnce() QVERIFY(innerObjsAfterFirstExecute.isEmpty()); QObjectList outerObjsAfterFirstExecute = object->findChildren<QObject *>(QStringLiteral("outerobj")); // deferredListProperty.qml - QCOMPARE(outerObjsAfterFirstExecute.count(), 1); + QCOMPARE(outerObjsAfterFirstExecute.size(), 1); QCOMPARE(outerObjsAfterFirstExecute.first()->property("wasCompleted"), QVariant(true)); groupProperty = object->property("groupProperty").value<QObject *>(); @@ -6920,7 +6920,7 @@ void tst_qqmllanguage::variantListConversion() Foo *foo = qobject_cast<Foo *>(o.data()); QVERIFY(foo); const QVariantList list = foo->getList(); - QCOMPARE(list.length(), 3); + QCOMPARE(list.size(), 3); const Large l0 = qvariant_cast<Large>(list.at(0)); QCOMPARE(l0.a, 12ull); const Large l1 = qvariant_cast<Large>(list.at(1)); |