aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2022-10-08 19:56:03 +0200
committerMarc Mutz <marc.mutz@qt.io>2022-10-13 00:18:35 +0200
commit5eb52b725526c26d0efa3856b6aba1919010f8fd (patch)
tree64d1bde7a2cc624e586228c9768c7eb1ea360e6c /tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
parente1a0596924766d62459740ed0271114a7bb99851 (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/qmlcppcodegen/tst_qmlcppcodegen.cpp')
-rw-r--r--tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
index 23939e73fb..1b61451322 100644
--- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
+++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
@@ -193,7 +193,7 @@ void tst_QmlCppCodegen::anchorsFill()
QVERIFY2(!object.isNull(), component.errorString().toUtf8().constData());
QCOMPARE(object->property("width").toInt(), 234);
- QCOMPARE(object->children().length(), 2);
+ QCOMPARE(object->children().size(), 2);
QObject *child = object->children().front();
QVERIFY(child);
@@ -625,7 +625,7 @@ void tst_QmlCppCodegen::conversions()
QCOMPARE(object->property("doneStuff").toInt(), 19);
QVariantList modulos = object->property("modulos").toList();
- QCOMPARE(modulos.length(), 7);
+ QCOMPARE(modulos.size(), 7);
QCOMPARE(modulos[0].userType(), QMetaType::Double);
QCOMPARE(modulos[0].toDouble(), 0.0);
@@ -649,7 +649,7 @@ void tst_QmlCppCodegen::conversions()
QVERIFY(qIsNaN(modulos[6].toDouble()));
QVariantList unaryOps = object->property("unaryOps").toList();
- QCOMPARE(unaryOps.length(), 6);
+ QCOMPARE(unaryOps.size(), 6);
QCOMPARE(unaryOps[0].userType(), QMetaType::Double);
QCOMPARE(unaryOps[0].toDouble(), 1221);
@@ -1790,7 +1790,7 @@ void tst_QmlCppCodegen::variantlist()
QVERIFY(o);
const QVariantList things = qvariant_cast<QVariantList>(o->property("things"));
- QCOMPARE(things.length(), 2);
+ QCOMPARE(things.size(), 2);
QCOMPARE(things[0].toString(), u"thing"_s);
QCOMPARE(things[1].toInt(), 30);
}