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/qqmlecmascript | |
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/qqmlecmascript')
-rw-r--r-- | tests/auto/qml/qqmlecmascript/testtypes.cpp | 2 | ||||
-rw-r--r-- | tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | 32 |
2 files changed, 17 insertions, 17 deletions
diff --git a/tests/auto/qml/qqmlecmascript/testtypes.cpp b/tests/auto/qml/qqmlecmascript/testtypes.cpp index cb2dd9373a..0b26979c4d 100644 --- a/tests/auto/qml/qqmlecmascript/testtypes.cpp +++ b/tests/auto/qml/qqmlecmascript/testtypes.cpp @@ -401,7 +401,7 @@ void QObjectContainer::children_append(QQmlListProperty<QObject> *prop, QObject qsizetype QObjectContainer::children_count(QQmlListProperty<QObject> *prop) { - return static_cast<QObjectContainer*>(prop->object)->dataChildren.count(); + return static_cast<QObjectContainer*>(prop->object)->dataChildren.size(); } QObject *QObjectContainer::children_at(QQmlListProperty<QObject> *prop, qsizetype index) diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index 340b1a148d..9fa617bcc7 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -2290,9 +2290,9 @@ void tst_qqmlecmascript::scriptErrors() QQmlComponent component(&engine, testFileUrl("scriptErrors.qml")); QString url = component.url().toString(); - QString warning1 = url.left(url.length() - 3) + "js:2: Error: Invalid write to global property \"a\""; + QString warning1 = url.left(url.size() - 3) + "js:2: Error: Invalid write to global property \"a\""; QString warning2 = url + ":5: ReferenceError: a is not defined"; - QString warning3 = url.left(url.length() - 3) + "js:4: Error: Invalid write to global property \"a\""; + QString warning3 = url.left(url.size() - 3) + "js:4: Error: Invalid write to global property \"a\""; QString warning4 = url + ":13: ReferenceError: a is not defined"; QString warning5 = url + ":11: ReferenceError: a is not defined"; QString warning6 = url + ":10:5: Unable to assign [undefined] to int"; @@ -4849,7 +4849,7 @@ void tst_qqmlecmascript::importScripts() else { QVERIFY(component.isError()); QCOMPARE(warningMessages.size(), 1); - QCOMPARE(component.errors().count(), 2); + QCOMPARE(component.errors().size(), 2); QCOMPARE(component.errors().at(1).toString(), warningMessages.first()); return; } @@ -5864,22 +5864,22 @@ void tst_qqmlecmascript::sequenceConversionRead() QMetaObject::invokeMethod(object.data(), "readSequences"); QList<int> intList; intList << 1 << 2 << 3 << 4; - QCOMPARE(object->property("intListLength").toInt(), intList.length()); + QCOMPARE(object->property("intListLength").toInt(), intList.size()); QCOMPARE(object->property("intList").value<QList<int> >(), intList); QList<qreal> qrealList; qrealList << 1.1 << 2.2 << 3.3 << 4.4; - QCOMPARE(object->property("qrealListLength").toInt(), qrealList.length()); + QCOMPARE(object->property("qrealListLength").toInt(), qrealList.size()); QCOMPARE(object->property("qrealList").value<QList<qreal> >(), qrealList); QList<bool> boolList; boolList << true << false << true << false; - QCOMPARE(object->property("boolListLength").toInt(), boolList.length()); + QCOMPARE(object->property("boolListLength").toInt(), boolList.size()); QCOMPARE(object->property("boolList").value<QList<bool> >(), boolList); QList<QString> stringList; stringList << QLatin1String("first") << QLatin1String("second") << QLatin1String("third") << QLatin1String("fourth"); - QCOMPARE(object->property("stringListLength").toInt(), stringList.length()); + QCOMPARE(object->property("stringListLength").toInt(), stringList.size()); QCOMPARE(object->property("stringList").value<QList<QString> >(), stringList); QList<QUrl> urlList; urlList << QUrl("http://www.example1.com") << QUrl("http://www.example2.com") << QUrl("http://www.example3.com"); - QCOMPARE(object->property("urlListLength").toInt(), urlList.length()); + QCOMPARE(object->property("urlListLength").toInt(), urlList.size()); QCOMPARE(object->property("urlList").value<QList<QUrl> >(), urlList); QStringList qstringList; qstringList << QLatin1String("first") << QLatin1String("second") << QLatin1String("third") << QLatin1String("fourth"); - QCOMPARE(object->property("qstringListLength").toInt(), qstringList.length()); + QCOMPARE(object->property("qstringListLength").toInt(), qstringList.size()); QCOMPARE(object->property("qstringList").value<QStringList>(), qstringList); QMetaObject::invokeMethod(object.data(), "readSequenceElements"); @@ -7355,7 +7355,7 @@ void tst_qqmlecmascript::nonNotifyable() QLatin1String(object->metaObject()->className()) + QLatin1String("::value"); - QCOMPARE(messageHandler.messages().length(), 2); + QCOMPARE(messageHandler.messages().size(), 2); QCOMPARE(messageHandler.messages().at(0), expected1); QCOMPARE(messageHandler.messages().at(1), expected2); } @@ -7413,7 +7413,7 @@ void tst_qqmlecmascript::qtbug_22679() QScopedPointer<QObject> o(component.create()); QVERIFY2(o, qPrintable(component.errorString())); - QCOMPARE(warningsSpy.count(), 0); + QCOMPARE(warningsSpy.size(), 0); } void tst_qqmlecmascript::qtbug_22843_data() @@ -7437,7 +7437,7 @@ void tst_qqmlecmascript::qtbug_22843() QQmlComponent component(&engine, testFileUrl(fileName)); QString url = component.url().toString(); - QString expectedError = url.left(url.length()-3) + QLatin1String("js:4:16: Expected token `;'"); + QString expectedError = url.left(url.size()-3) + QLatin1String("js:4:16: Expected token `;'"); QVERIFY(component.isError()); QCOMPARE(component.errors().value(1).toString(), expectedError); @@ -8267,8 +8267,8 @@ void tst_qqmlecmascript::jsOwnedObjectsDeletedOnEngineDestroy() QSignalSpy spy1(object1, SIGNAL(destroyed())); QSignalSpy spy2(object2, SIGNAL(destroyed())); myEngine.reset(); - QCOMPARE(spy1.count(), 1); - QCOMPARE(spy2.count(), 1); + QCOMPARE(spy1.size(), 1); + QCOMPARE(spy2.size(), 1); deleteObject.deleteNestedObject(); } @@ -8583,14 +8583,14 @@ void tst_qqmlecmascript::garbageCollectionDuringCreation() QVERIFY2(object, qPrintable(component.errorString())); QObjectContainer *container = qobject_cast<QObjectContainer*>(object.data()); - QCOMPARE(container->dataChildren.count(), 1); + QCOMPARE(container->dataChildren.size(), 1); QObject *child = container->dataChildren.first(); QQmlData *ddata = QQmlData::get(child); QVERIFY(!ddata->jsWrapper.isNullOrUndefined()); gc(engine); - QCOMPARE(container->dataChildren.count(), 0); + QCOMPARE(container->dataChildren.size(), 0); } void tst_qqmlecmascript::qtbug_39520() |