summaryrefslogtreecommitdiffstats
path: root/tests
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-10 21:03:48 +0200
commit4146e5734686a9dd569946ac3e4b5e7eef1e2b02 (patch)
treefc2e957fa0aedb2563dc52ec377513684f970459 /tests
parent3ecd6ad4cd0bcec11e17f69e9e5d25057634b048 (diff)
Port from container::count() and length() to size() - V4
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"); a.k.a qt-port-to-std-compatible-api V4 with config Scope: 'Container'. Change-Id: I58e1b41b91c34d2e860dbb5847b3752edbfc6fc9 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/scxmlqmlcpp/tst_scxmlqmlcpp.cpp8
-rw-r--r--tests/auto/shared/bindableqmlutils.h20
2 files changed, 14 insertions, 14 deletions
diff --git a/tests/auto/qml/scxmlqmlcpp/tst_scxmlqmlcpp.cpp b/tests/auto/qml/scxmlqmlcpp/tst_scxmlqmlcpp.cpp
index 3916010..c3c3501 100644
--- a/tests/auto/qml/scxmlqmlcpp/tst_scxmlqmlcpp.cpp
+++ b/tests/auto/qml/scxmlqmlcpp/tst_scxmlqmlcpp.cpp
@@ -79,20 +79,20 @@ void tst_scxmlqmlcpp::invokedServicesChildrenBinding()
TopMachine topSm;
QScxmlInvokedServices invokedServices;
invokedServices.setStateMachine(&topSm);
- QCOMPARE(invokedServices.children().count(), 0);
+ QCOMPARE(invokedServices.children().size(), 0);
QCOMPARE(topSm.invokedServices().size(), 0);
// at some point during the topSm execution there are 3 invoked services
// of the same name ('3' filters out as '1' at QML binding)
topSm.start();
QTRY_COMPARE(topSm.invokedServices().size(), 3);
- QCOMPARE(invokedServices.children().count(), 1);
+ QCOMPARE(invokedServices.children().size(), 1);
// after completion invoked services drop back to 0
QTRY_COMPARE(topSm.invokedServices().size(), 0);
- QCOMPARE(invokedServices.children().count(), 0);
+ QCOMPARE(invokedServices.children().size(), 0);
// bind *to* the invokedservices property and check that we observe same changes
// during the topSm execution
QProperty<qsizetype> serviceCounter;
- serviceCounter.setBinding([&](){ return invokedServices.children().count(); });
+ serviceCounter.setBinding([&](){ return invokedServices.children().size(); });
QCOMPARE(serviceCounter, 0);
topSm.start();
QTRY_COMPARE(serviceCounter, 1);
diff --git a/tests/auto/shared/bindableqmlutils.h b/tests/auto/shared/bindableqmlutils.h
index de80f44..1ce94ca 100644
--- a/tests/auto/shared/bindableqmlutils.h
+++ b/tests/auto/shared/bindableqmlutils.h
@@ -47,12 +47,12 @@ void testManipulableQmlListBasics(TestedClass& testedClass,
listRef.append(data1);
QVERIFY2(listRef.count() == 1, qPrintable(id));
if (changedSpy)
- QVERIFY2(changedSpy->count() == 1, qPrintable(id + ", actual: " + QString::number(changedSpy->count())));
+ QVERIFY2(changedSpy->size() == 1, qPrintable(id + ", actual: " + QString::number(changedSpy->size())));
QVERIFY2(listRef.at(0) == data1, qPrintable(id));
listRef.clear();
QVERIFY2(listRef.count() == 0, qPrintable(id));
if (changedSpy)
- QVERIFY2(changedSpy->count() == 2, qPrintable(id + ", actual: " + QString::number(changedSpy->count())));
+ QVERIFY2(changedSpy->size() == 2, qPrintable(id + ", actual: " + QString::number(changedSpy->size())));
// Bind to the property and verify that the bindings reflect the listproperty changes
QProperty<bool> data1InList([&](){
@@ -78,35 +78,35 @@ void testManipulableQmlListBasics(TestedClass& testedClass,
listRef.append(data1);
if (changedSpy)
- QVERIFY2(changedSpy->count() == 3, qPrintable(id + ", actual: " + QString::number(changedSpy->count())));
+ QVERIFY2(changedSpy->size() == 3, qPrintable(id + ", actual: " + QString::number(changedSpy->size())));
QVERIFY2(data1InList, qPrintable(id));
QVERIFY2(!data2InList, qPrintable(id));
listRef.append(data2);
if (changedSpy)
- QVERIFY2(changedSpy->count() == 4, qPrintable(id + ", actual: " + QString::number(changedSpy->count())));
+ QVERIFY2(changedSpy->size() == 4, qPrintable(id + ", actual: " + QString::number(changedSpy->size())));
QVERIFY2(data1InList, qPrintable(id));
QVERIFY2(data2InList, qPrintable(id));
- QVERIFY2(listRef.count() == 2, qPrintable(id + ", actual: " + QString::number(changedSpy->count())));
+ QVERIFY2(listRef.count() == 2, qPrintable(id + ", actual: " + QString::number(changedSpy->size())));
listRef.clear();
if (changedSpy)
- QVERIFY2(changedSpy->count() == 5, qPrintable(id + ", actual: " + QString::number(changedSpy->count())));
+ QVERIFY2(changedSpy->size() == 5, qPrintable(id + ", actual: " + QString::number(changedSpy->size())));
QVERIFY2(!data1InList, qPrintable(id));
QVERIFY2(!data2InList, qPrintable(id));
- QVERIFY2(listRef.count() == 0, qPrintable(id + ", actual: " + QString::number(changedSpy->count())));
+ QVERIFY2(listRef.count() == 0, qPrintable(id + ", actual: " + QString::number(changedSpy->size())));
listRef.append(data1);
listRef.replace(0, data2);
if (changedSpy)
- QVERIFY2(changedSpy->count() == 7, qPrintable(id + ", actual: " + QString::number(changedSpy->count())));
+ QVERIFY2(changedSpy->size() == 7, qPrintable(id + ", actual: " + QString::number(changedSpy->size())));
QVERIFY2(!data1InList, qPrintable(id));
QVERIFY2(data2InList, qPrintable(id));
- QVERIFY2(listRef.count() == 1, qPrintable(id + ", actual: " + QString::number(changedSpy->count())));
+ QVERIFY2(listRef.count() == 1, qPrintable(id + ", actual: " + QString::number(changedSpy->size())));
listRef.removeLast();
if (changedSpy)
- QVERIFY2(changedSpy->count() == 8, qPrintable(id + ", actual: " + QString::number(changedSpy->count())));
+ QVERIFY2(changedSpy->size() == 8, qPrintable(id + ", actual: " + QString::number(changedSpy->size())));
QVERIFY2(!data1InList, qPrintable(id));
QVERIFY2(!data2InList, qPrintable(id));