summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/global
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2022-09-30 14:09:04 +0200
committerMarc Mutz <marc.mutz@qt.io>2022-10-04 07:40:08 +0200
commitdf9d882d41b741fef7c5beeddb0abe9d904443d8 (patch)
tree6f3e90dacad4581b7f1cabe235cca298833a3da4 /tests/auto/corelib/global
parent109e088c7c5d0c9325966e88d55fd9f7a58f67ea (diff)
Port from container.count()/length() to size()
This is semantic patch using ClangTidyTransformator: auto QtContainerClass = 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'. <classes> are: // sequential: "QByteArray", "QList", "QQueue", "QStack", "QString", "QVarLengthArray", "QVector", // associative: "QHash", "QMultiHash", "QMap", "QMultiMap", "QSet", // Qt has no QMultiSet Change-Id: Ibe8837be96e8d30d1846881ecd65180c1bc459af Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'tests/auto/corelib/global')
-rw-r--r--tests/auto/corelib/global/qgetputenv/tst_qgetputenv.cpp2
-rw-r--r--tests/auto/corelib/global/qglobal/tst_qglobal.cpp14
2 files changed, 8 insertions, 8 deletions
diff --git a/tests/auto/corelib/global/qgetputenv/tst_qgetputenv.cpp b/tests/auto/corelib/global/qgetputenv/tst_qgetputenv.cpp
index f914ee5f23..832319a652 100644
--- a/tests/auto/corelib/global/qgetputenv/tst_qgetputenv.cpp
+++ b/tests/auto/corelib/global/qgetputenv/tst_qgetputenv.cpp
@@ -191,7 +191,7 @@ void tst_QGetPutEnv::intValue()
bool actualOk = !ok;
// Self-test: confirm that it was like the docs said it should be
- if (value.length() < maxlen) {
+ if (value.size() < maxlen) {
QCOMPARE(value.toInt(&actualOk, 0), expected);
QCOMPARE(actualOk, ok);
}
diff --git a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp
index 3923b6d6ac..4b0b97de0b 100644
--- a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp
+++ b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp
@@ -85,7 +85,7 @@ void tst_QGlobal::for_each()
foreach(int i, list) {
QCOMPARE(i, counter++);
}
- QCOMPARE(counter, list.count());
+ QCOMPARE(counter, list.size());
// do it again, to make sure we don't have any for-scoping
// problems with older compilers
@@ -93,21 +93,21 @@ void tst_QGlobal::for_each()
foreach(int i, list) {
QCOMPARE(i, counter++);
}
- QCOMPARE(counter, list.count());
+ QCOMPARE(counter, list.size());
// check whether we can pass a constructor as container argument
counter = 0;
foreach (int i, QList<int>(list)) {
QCOMPARE(i, counter++);
}
- QCOMPARE(counter, list.count());
+ QCOMPARE(counter, list.size());
// check whether we can use a lambda
counter = 0;
foreach (int i, [&](){ return list; }()) {
QCOMPARE(i, counter++);
}
- QCOMPARE(counter, list.count());
+ QCOMPARE(counter, list.size());
// Should also work with an existing variable
int local = 0;
@@ -115,7 +115,7 @@ void tst_QGlobal::for_each()
foreach (local, list) {
QCOMPARE(local, counter++);
}
- QCOMPARE(counter, list.count());
+ QCOMPARE(counter, list.size());
QCOMPARE(local, counter - 1);
// Test the macro does not mess if/else conditions
@@ -125,7 +125,7 @@ void tst_QGlobal::for_each()
QCOMPARE(i, counter++);
else
QFAIL("If/Else mismatch");
- QCOMPARE(counter, list.count());
+ QCOMPARE(counter, list.size());
counter = 0;
if (false)
@@ -136,7 +136,7 @@ void tst_QGlobal::for_each()
foreach (int i, list)
if (false) { }
else QCOMPARE(i, counter++);
- QCOMPARE(counter, list.count());
+ QCOMPARE(counter, list.size());
// break and continue
counter = 0;