From 1c6bf3e09ea9722717caedcfcceaaf3d607615cf Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 30 Sep 2022 14:09:04 +0200 Subject: 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 classes) { auto exprOfDeclaredType = [&](auto decl) { return expr(hasTypeIgnoringPointer(hasUnqualifiedDesugaredType(recordType(hasDeclaration(decl))))).bind(o); }; return exprOfDeclaredType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes)))); }; auto renameMethod = [&] (ArrayRef 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(, "count", "size"); renameMethod(, "length", "size"); except that the on() matcher has been replaced by one that doesn't ignoreParens(). a.k.a qt-port-to-std-compatible-api V5 with config Scope: 'Container'. Added two NOLINTNEXTLINEs in tst_qbitarray and tst_qcontiguouscache, to avoid porting calls that explicitly test count(). Change-Id: Icfb8808c2ff4a30187e9935a51cad26987451c22 Reviewed-by: Ivan Solovev Reviewed-by: Qt CI Bot --- .../corelib/tools/collections/tst_collections.cpp | 10 ++-- .../auto/corelib/tools/qbitarray/tst_qbitarray.cpp | 5 +- .../qcommandlineparser/tst_qcommandlineparser.cpp | 4 +- .../qcontiguouscache/tst_qcontiguouscache.cpp | 26 +++++----- .../tools/qeasingcurve/tst_qeasingcurve.cpp | 8 +-- tests/auto/corelib/tools/qflatmap/tst_qflatmap.cpp | 4 +- tests/auto/corelib/tools/qhash/tst_qhash.cpp | 58 +++++++++++----------- tests/auto/corelib/tools/qmap/tst_qmap.cpp | 58 +++++++++++----------- .../auto/corelib/tools/qtimeline/tst_qtimeline.cpp | 54 ++++++++++---------- 9 files changed, 115 insertions(+), 112 deletions(-) (limited to 'tests/auto/corelib/tools') diff --git a/tests/auto/corelib/tools/collections/tst_collections.cpp b/tests/auto/corelib/tools/collections/tst_collections.cpp index 3ec49a7444..965deca33f 100644 --- a/tests/auto/corelib/tools/collections/tst_collections.cpp +++ b/tests/auto/corelib/tools/collections/tst_collections.cpp @@ -2693,7 +2693,7 @@ void tst_Collections::vector_stl() QFETCH(QStringList, elements); QList vector; - for (int i = 0; i < elements.count(); ++i) + for (int i = 0; i < elements.size(); ++i) vector << elements.at(i); #if QT_VERSION < QT_VERSION_CHECK(6,0,0) @@ -2728,7 +2728,7 @@ void tst_Collections::list_stl() QFETCH(QStringList, elements); QList list; - for (int i = 0; i < elements.count(); ++i) + for (int i = 0; i < elements.size(); ++i) list << elements.at(i); #if QT_VERSION < QT_VERSION_CHECK(6,0,0) @@ -3407,9 +3407,9 @@ void tst_Collections::foreach_2() varl5 << str; varl6 << str; } - QCOMPARE(varl4.size(), strlist.count()); - QCOMPARE(varl5.size(), strlist.count()); - QCOMPARE(varl6.size(), strlist.count()); + QCOMPARE(varl4.size(), strlist.size()); + QCOMPARE(varl5.size(), strlist.size()); + QCOMPARE(varl6.size(), strlist.size()); } struct IntOrString diff --git a/tests/auto/corelib/tools/qbitarray/tst_qbitarray.cpp b/tests/auto/corelib/tools/qbitarray/tst_qbitarray.cpp index 4344f58ec3..b205bb76ee 100644 --- a/tests/auto/corelib/tools/qbitarray/tst_qbitarray.cpp +++ b/tests/auto/corelib/tools/qbitarray/tst_qbitarray.cpp @@ -143,6 +143,7 @@ void tst_QBitArray::countBits() } QCOMPARE(bits.size(), numBits); + // NOLINTNEXTLINE(qt-port-to-std-compatible-api): We want to test count() and size() QCOMPARE(bits.count(), numBits); QCOMPARE(bits.count(true), onBits); QCOMPARE(bits.count(false), numBits - onBits); @@ -493,7 +494,7 @@ void tst_QBitArray::datastream() bits.setBit(i); } - QCOMPARE(bits.count(), numBits); + QCOMPARE(bits.size(), numBits); QCOMPARE(bits.count(true), onBits); QCOMPARE(bits.count(false), numBits - onBits); @@ -508,7 +509,7 @@ void tst_QBitArray::datastream() QBitArray array1, array2, array3; stream2 >> array1 >> array2 >> array3; - QCOMPARE(array1.count(), numBits); + QCOMPARE(array1.size(), numBits); QCOMPARE(array1.count(true), onBits); QCOMPARE(array1.count(false), numBits - onBits); diff --git a/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp b/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp index c2f6811d27..6252440232 100644 --- a/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp +++ b/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp @@ -503,7 +503,7 @@ void tst_QCommandLineParser::testSingleDashWordOptionModes() QVERIFY(parser.addOption(forceShort)); QVERIFY(parser.parse(commandLine)); QCOMPARE(parser.optionNames(), expectedOptionNames); - for (int i = 0; i < expectedOptionValues.count(); ++i) + for (int i = 0; i < expectedOptionValues.size(); ++i) QCOMPARE(parser.value(parser.optionNames().at(i)), expectedOptionValues.at(i)); QCOMPARE(parser.unknownOptionNames(), QStringList()); } @@ -762,7 +762,7 @@ void tst_QCommandLineParser::testVeryLongOptionNames() output.replace(QStringLiteral("\r\n"), QStringLiteral("\n")); #endif const QStringList lines = output.split('\n'); - const int last = lines.count() - 1; + const int last = lines.size() - 1; // Let's not compare everything, just the final parts. QCOMPARE(lines.at(last - 7), " cdefghijklmnopqrstuvwxyz"); QCOMPARE(lines.at(last - 6), " --looooooooooooong-option, --looooong-opt-alias c(10); QCOMPARE(c.capacity(), 10); QCOMPARE(c.size(), 0); + // NOLINTNEXTLINE(qt-port-to-std-compatible-api): Test both size() and count() QCOMPARE(c.count(), 0); QVERIFY(c.isEmpty()); c.append(1); + // NOLINTNEXTLINE(qt-port-to-std-compatible-api): Test both size() and count() QCOMPARE(c.count(), 1); QCOMPARE(c.size(), 1); QVERIFY(!c.isEmpty()); c.clear(); QCOMPARE(c.capacity(), 10); - QCOMPARE(c.count(), 0); + QCOMPARE(c.size(), 0); QVERIFY(c.isEmpty()); c.prepend(1); - QCOMPARE(c.count(), 1); + QCOMPARE(c.size(), 1); QVERIFY(!c.isEmpty()); c.clear(); - QCOMPARE(c.count(), 0); + QCOMPARE(c.size(), 0); QVERIFY(c.isEmpty()); QCOMPARE(c.capacity(), 10); } @@ -76,9 +78,9 @@ void tst_QContiguousCache::swap() c1.append(1); c1.swap(c2); QCOMPARE(c1.capacity(), 100); - QCOMPARE(c1.count(), 0 ); + QCOMPARE(c1.size(), 0 ); QCOMPARE(c2.capacity(), 10 ); - QCOMPARE(c2.count(), 1 ); + QCOMPARE(c2.size(), 1 ); } void tst_QContiguousCache::append_data() @@ -114,7 +116,7 @@ void tst_QContiguousCache::append() QCOMPARE(c.available(), qMax(qsizetype(0), cacheSize - i)); QCOMPARE(c.first(), qMax(qsizetype(1), i-cacheSize+1)); QCOMPARE(c.last(), i); - QCOMPARE(c.count(), qMin(i, cacheSize)); + QCOMPARE(c.size(), qMin(i, cacheSize)); QCOMPARE(c.isFull(), i >= cacheSize); i++; } @@ -127,7 +129,7 @@ void tst_QContiguousCache::append() // test taking from end until empty. for (j = 0; j < cacheSize; j++, i--) { QCOMPARE(c.takeLast(), i-1); - QCOMPARE(c.count(), cacheSize-j-1); + QCOMPARE(c.size(), cacheSize-j-1); QCOMPARE(c.available(), j+1); QVERIFY(!c.isFull()); QCOMPARE(c.isEmpty(), j==cacheSize-1); @@ -165,7 +167,7 @@ void tst_QContiguousCache::prepend() QCOMPARE(c.available(), qMax(0, cacheSize - i)); QCOMPARE(c.last(), qMax(1, i-cacheSize+1)); QCOMPARE(c.first(), i); - QCOMPARE(c.count(), qMin(i, cacheSize)); + QCOMPARE(c.size(), qMin(i, cacheSize)); QCOMPARE(c.isFull(), i >= cacheSize); i++; } @@ -178,7 +180,7 @@ void tst_QContiguousCache::prepend() // test taking from start until empty. for (j = 0; j < cacheSize; j++, i--) { QCOMPARE(c.takeFirst(), i-1); - QCOMPARE(c.count(), cacheSize-j-1); + QCOMPARE(c.size(), cacheSize-j-1); QCOMPARE(c.available(), j+1); QVERIFY(!c.isFull()); QCOMPARE(c.isEmpty(), j==cacheSize-1); @@ -298,7 +300,7 @@ void tst_QContiguousCache::setCapacity() for (i = 280; i < 310; ++i) contiguousCache.insert(i, i); QCOMPARE(contiguousCache.capacity(), 100); - QCOMPARE(contiguousCache.count(), 30); + QCOMPARE(contiguousCache.size(), 30); QCOMPARE(contiguousCache.firstIndex(), 280); QCOMPARE(contiguousCache.lastIndex(), 309); @@ -310,7 +312,7 @@ void tst_QContiguousCache::setCapacity() contiguousCache.setCapacity(150); QCOMPARE(contiguousCache.capacity(), 150); - QCOMPARE(contiguousCache.count(), 30); + QCOMPARE(contiguousCache.size(), 30); QCOMPARE(contiguousCache.firstIndex(), 280); QCOMPARE(contiguousCache.lastIndex(), 309); @@ -322,7 +324,7 @@ void tst_QContiguousCache::setCapacity() contiguousCache.setCapacity(20); QCOMPARE(contiguousCache.capacity(), 20); - QCOMPARE(contiguousCache.count(), 20); + QCOMPARE(contiguousCache.size(), 20); QCOMPARE(contiguousCache.firstIndex(), 290); QCOMPARE(contiguousCache.lastIndex(), 309); diff --git a/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp b/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp index a64e3bfcb3..4989de521f 100644 --- a/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp +++ b/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp @@ -374,7 +374,7 @@ void tst_QEasingCurve::valueForProgress() // in theory the baseline should't have an error of more than 0.00005 due to how its rounded, // but due to FP imprecision, we have to adjust the error a bit more. const qreal errorBound = 0.00006; - for (int i = 0; i < at.count(); ++i) { + for (int i = 0; i < at.size(); ++i) { const qreal ex = expected.at(i); const qreal error = qAbs(ex - curve.valueForProgress(at.at(i)/qreal(100))); QVERIFY(error <= errorBound); @@ -603,7 +603,7 @@ void tst_QEasingCurve::bezierSpline() setupBezierSpline(&bezierEasingCurve, definition); const qreal errorBound = 0.002; - for (int i = 0; i < at.count(); ++i) { + for (int i = 0; i < at.size(); ++i) { const qreal ex = expected.at(i); const qreal value = bezierEasingCurve.valueForProgress(at.at(i)/qreal(100)); const qreal error = qAbs(ex - value); @@ -646,7 +646,7 @@ static inline void setupTCBSpline(QEasingCurve *easingCurve, const QString &stri foreach (const QString &str, pointStr) { QStringList coordStr = str.split(QLatin1Char(',')); - Q_ASSERT(coordStr.count() == 5); + Q_ASSERT(coordStr.size() == 5); QPointF point(coordStr.first().toDouble(), coordStr.at(1).toDouble()); qreal t = coordStr.at(2).toDouble(); qreal c = coordStr.at(3).toDouble(); @@ -665,7 +665,7 @@ void tst_QEasingCurve::tcbSpline() setupTCBSpline(&tcbEasingCurve, definition); const qreal errorBound = 0.002; - for (int i = 0; i < at.count(); ++i) { + for (int i = 0; i < at.size(); ++i) { const qreal ex = expected.at(i); const qreal value = tcbEasingCurve.valueForProgress(at.at(i)/qreal(100)); const qreal error = qAbs(ex - value); diff --git a/tests/auto/corelib/tools/qflatmap/tst_qflatmap.cpp b/tests/auto/corelib/tools/qflatmap/tst_qflatmap.cpp index f57abbf156..112a393136 100644 --- a/tests/auto/corelib/tools/qflatmap/tst_qflatmap.cpp +++ b/tests/auto/corelib/tools/qflatmap/tst_qflatmap.cpp @@ -682,7 +682,7 @@ void tst_QFlatMap::viewIterators() }); auto it = keys.begin(); QCOMPARE(*it, "kaksi"); - QCOMPARE(it->length(), 5); + QCOMPARE(it->size(), 5); ++it; QCOMPARE(*it, "kolme"); it++; @@ -703,7 +703,7 @@ void tst_QFlatMap::viewIterators() }); auto it = values.begin(); QCOMPARE(*it, "twee"); - QCOMPARE(it->length(), 4); + QCOMPARE(it->size(), 4); ++it; QCOMPARE(*it, "dree"); it++; diff --git a/tests/auto/corelib/tools/qhash/tst_qhash.cpp b/tests/auto/corelib/tools/qhash/tst_qhash.cpp index cf0bc67761..ed21dc71b5 100644 --- a/tests/auto/corelib/tools/qhash/tst_qhash.cpp +++ b/tests/auto/corelib/tools/qhash/tst_qhash.cpp @@ -168,13 +168,13 @@ void tst_QHash::count() { MyMap map; MyMap map2( map ); - QCOMPARE( map.count(), 0 ); - QCOMPARE( map2.count(), 0 ); + QCOMPARE( map.size(), 0 ); + QCOMPARE( map2.size(), 0 ); QCOMPARE( MyClass::count, 0 ); // detach map2["Hallo"] = MyClass( "Fritz" ); - QCOMPARE( map.count(), 0 ); - QCOMPARE( map2.count(), 1 ); + QCOMPARE( map.size(), 0 ); + QCOMPARE( map2.size(), 1 ); #ifndef Q_CC_SUN QCOMPARE( MyClass::count, 1 ); #endif @@ -184,11 +184,11 @@ void tst_QHash::count() { typedef QHash Map; Map map; - QCOMPARE( map.count(), 0); + QCOMPARE( map.size(), 0); map.insert( "Torben", MyClass("Weis") ); - QCOMPARE( map.count(), 1 ); + QCOMPARE( map.size(), 1 ); map.insert( "Claudia", MyClass("Sorg") ); - QCOMPARE( map.count(), 2 ); + QCOMPARE( map.size(), 2 ); map.insert( "Lars", MyClass("Linzbach") ); map.insert( "Matthias", MyClass("Ettrich") ); map.insert( "Sue", MyClass("Paludo") ); @@ -196,7 +196,7 @@ void tst_QHash::count() map.insert( "Haavard", MyClass("Nord") ); map.insert( "Arnt", MyClass("Gulbrandsen") ); map.insert( "Paul", MyClass("Tvete") ); - QCOMPARE( map.count(), 9 ); + QCOMPARE( map.size(), 9 ); map.insert( "Paul", MyClass("Tvete 1") ); map.insert( "Paul", MyClass("Tvete 2") ); map.insert( "Paul", MyClass("Tvete 3") ); @@ -204,68 +204,68 @@ void tst_QHash::count() map.insert( "Paul", MyClass("Tvete 5") ); map.insert( "Paul", MyClass("Tvete 6") ); - QCOMPARE( map.count(), 9 ); + QCOMPARE( map.size(), 9 ); #ifndef Q_CC_SUN QCOMPARE( MyClass::count, 9 ); #endif Map map2( map ); - QVERIFY( map2.count() == 9 ); + QVERIFY( map2.size() == 9 ); #ifndef Q_CC_SUN QCOMPARE( MyClass::count, 9 ); #endif map2.insert( "Kay", MyClass("Roemer") ); - QVERIFY( map2.count() == 10 ); - QVERIFY( map.count() == 9 ); + QVERIFY( map2.size() == 10 ); + QVERIFY( map.size() == 9 ); #ifndef Q_CC_SUN QCOMPARE( MyClass::count, 19 ); #endif map2 = map; - QVERIFY( map.count() == 9 ); - QVERIFY( map2.count() == 9 ); + QVERIFY( map.size() == 9 ); + QVERIFY( map2.size() == 9 ); #ifndef Q_CC_SUN QCOMPARE( MyClass::count, 9 ); #endif map2.insert( "Kay", MyClass("Roemer") ); - QVERIFY( map2.count() == 10 ); + QVERIFY( map2.size() == 10 ); #ifndef Q_CC_SUN QCOMPARE( MyClass::count, 19 ); #endif map2.clear(); - QVERIFY( map.count() == 9 ); - QVERIFY( map2.count() == 0 ); + QVERIFY( map.size() == 9 ); + QVERIFY( map2.size() == 0 ); #ifndef Q_CC_SUN QCOMPARE( MyClass::count, 9 ); #endif map2 = map; - QVERIFY( map.count() == 9 ); - QVERIFY( map2.count() == 9 ); + QVERIFY( map.size() == 9 ); + QVERIFY( map2.size() == 9 ); #ifndef Q_CC_SUN QCOMPARE( MyClass::count, 9 ); #endif map2.clear(); - QVERIFY( map.count() == 9 ); - QVERIFY( map2.count() == 0 ); + QVERIFY( map.size() == 9 ); + QVERIFY( map2.size() == 0 ); #ifndef Q_CC_SUN QCOMPARE( MyClass::count, 9 ); #endif map.remove( "Lars" ); - QVERIFY( map.count() == 8 ); - QVERIFY( map2.count() == 0 ); + QVERIFY( map.size() == 8 ); + QVERIFY( map2.size() == 0 ); #ifndef Q_CC_SUN QCOMPARE( MyClass::count, 8 ); #endif map.remove( "Mist" ); - QVERIFY( map.count() == 8 ); - QVERIFY( map2.count() == 0 ); + QVERIFY( map.size() == 8 ); + QVERIFY( map2.size() == 0 ); #ifndef Q_CC_SUN QCOMPARE( MyClass::count, 8 ); #endif @@ -279,22 +279,22 @@ void tst_QHash::count() #ifndef Q_CC_SUN QVERIFY( MyClass::count == 1 ); #endif - QVERIFY( map.count() == 1 ); + QVERIFY( map.size() == 1 ); (void)map["Torben"].str; (void)map["Lars"].str; #ifndef Q_CC_SUN QVERIFY( MyClass::count == 2 ); #endif - QVERIFY( map.count() == 2 ); + QVERIFY( map.size() == 2 ); const Map& cmap = map; (void)cmap["Depp"].str; #ifndef Q_CC_SUN QVERIFY( MyClass::count == 2 ); #endif - QVERIFY( map.count() == 2 ); - QVERIFY( cmap.count() == 2 ); + QVERIFY( map.size() == 2 ); + QVERIFY( cmap.size() == 2 ); } QCOMPARE( MyClass::count, 0 ); { diff --git a/tests/auto/corelib/tools/qmap/tst_qmap.cpp b/tests/auto/corelib/tools/qmap/tst_qmap.cpp index 098976b228..eb7658517e 100644 --- a/tests/auto/corelib/tools/qmap/tst_qmap.cpp +++ b/tests/auto/corelib/tools/qmap/tst_qmap.cpp @@ -166,8 +166,8 @@ void tst_QMap::count() { MyMap map; MyMap map2( map ); - QCOMPARE( map.count(), 0 ); - QCOMPARE( map2.count(), 0 ); + QCOMPARE( map.size(), 0 ); + QCOMPARE( map2.size(), 0 ); QCOMPARE( MyClass::count, int(0) ); QCOMPARE(map.count("key"), 0); QCOMPARE(map.size(), 0); @@ -176,9 +176,9 @@ void tst_QMap::count() QVERIFY(!map2.isDetached()); // detach map2["Hallo"] = MyClass( "Fritz" ); - QCOMPARE( map.count(), 0 ); QCOMPARE( map.size(), 0 ); - QCOMPARE( map2.count(), 1 ); + QCOMPARE( map.size(), 0 ); + QCOMPARE( map2.size(), 1 ); QCOMPARE( map2.size(), 1 ); QVERIFY(!map.isDetached()); #ifndef Q_CC_SUN @@ -190,11 +190,11 @@ void tst_QMap::count() { typedef QMap Map; Map map; - QCOMPARE( map.count(), 0); + QCOMPARE( map.size(), 0); map.insert( "Torben", MyClass("Weis") ); - QCOMPARE( map.count(), 1 ); + QCOMPARE( map.size(), 1 ); map.insert( "Claudia", MyClass("Sorg") ); - QCOMPARE( map.count(), 2 ); + QCOMPARE( map.size(), 2 ); map.insert( "Lars", MyClass("Linzbach") ); map.insert( "Matthias", MyClass("Ettrich") ); map.insert( "Sue", MyClass("Paludo") ); @@ -202,7 +202,7 @@ void tst_QMap::count() map.insert( "Haavard", MyClass("Nord") ); map.insert( "Arnt", MyClass("Gulbrandsen") ); map.insert( "Paul", MyClass("Tvete") ); - QCOMPARE( map.count(), 9 ); + QCOMPARE( map.size(), 9 ); map.insert( "Paul", MyClass("Tvete 1") ); map.insert( "Paul", MyClass("Tvete 2") ); map.insert( "Paul", MyClass("Tvete 3") ); @@ -210,69 +210,69 @@ void tst_QMap::count() map.insert( "Paul", MyClass("Tvete 5") ); map.insert( "Paul", MyClass("Tvete 6") ); - QCOMPARE( map.count(), 9 ); + QCOMPARE( map.size(), 9 ); QCOMPARE( map.count("Paul"), 1 ); #ifndef Q_CC_SUN QCOMPARE( MyClass::count, 9 ); #endif Map map2( map ); - QVERIFY( map2.count() == 9 ); + QVERIFY( map2.size() == 9 ); #ifndef Q_CC_SUN QCOMPARE( MyClass::count, 9 ); #endif map2.insert( "Kay", MyClass("Roemer") ); - QVERIFY( map2.count() == 10 ); - QVERIFY( map.count() == 9 ); + QVERIFY( map2.size() == 10 ); + QVERIFY( map.size() == 9 ); #ifndef Q_CC_SUN QCOMPARE( MyClass::count, 19 ); #endif map2 = map; - QVERIFY( map.count() == 9 ); - QVERIFY( map2.count() == 9 ); + QVERIFY( map.size() == 9 ); + QVERIFY( map2.size() == 9 ); #ifndef Q_CC_SUN QCOMPARE( MyClass::count, 9 ); #endif map2.insert( "Kay", MyClass("Roemer") ); - QVERIFY( map2.count() == 10 ); + QVERIFY( map2.size() == 10 ); #ifndef Q_CC_SUN QCOMPARE( MyClass::count, 19 ); #endif map2.clear(); - QVERIFY( map.count() == 9 ); - QVERIFY( map2.count() == 0 ); + QVERIFY( map.size() == 9 ); + QVERIFY( map2.size() == 0 ); #ifndef Q_CC_SUN QCOMPARE( MyClass::count, 9 ); #endif map2 = map; - QVERIFY( map.count() == 9 ); - QVERIFY( map2.count() == 9 ); + QVERIFY( map.size() == 9 ); + QVERIFY( map2.size() == 9 ); #ifndef Q_CC_SUN QCOMPARE( MyClass::count, 9 ); #endif map2.clear(); - QVERIFY( map.count() == 9 ); - QVERIFY( map2.count() == 0 ); + QVERIFY( map.size() == 9 ); + QVERIFY( map2.size() == 0 ); #ifndef Q_CC_SUN QCOMPARE( MyClass::count, 9 ); #endif map.remove( "Lars" ); - QVERIFY( map.count() == 8 ); - QVERIFY( map2.count() == 0 ); + QVERIFY( map.size() == 8 ); + QVERIFY( map2.size() == 0 ); #ifndef Q_CC_SUN QCOMPARE( MyClass::count, 8 ); #endif map.remove( "Mist" ); - QVERIFY( map.count() == 8 ); - QVERIFY( map2.count() == 0 ); + QVERIFY( map.size() == 8 ); + QVERIFY( map2.size() == 0 ); #ifndef Q_CC_SUN QCOMPARE( MyClass::count, 8 ); #endif @@ -286,22 +286,22 @@ void tst_QMap::count() #ifndef Q_CC_SUN QVERIFY( MyClass::count == 1 ); #endif - QVERIFY( map.count() == 1 ); + QVERIFY( map.size() == 1 ); (void)map["Torben"].str; (void)map["Lars"].str; #ifndef Q_CC_SUN QVERIFY( MyClass::count == 2 ); #endif - QVERIFY( map.count() == 2 ); + QVERIFY( map.size() == 2 ); const Map& cmap = map; (void)cmap["Depp"].str; #ifndef Q_CC_SUN QVERIFY( MyClass::count == 2 ); #endif - QVERIFY( map.count() == 2 ); - QVERIFY( cmap.count() == 2 ); + QVERIFY( map.size() == 2 ); + QVERIFY( cmap.size() == 2 ); } QCOMPARE( MyClass::count, 0 ); { diff --git a/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp b/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp index d1a1d2c169..7d0e121b30 100644 --- a/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp +++ b/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp @@ -80,7 +80,7 @@ void tst_QTimeLine::range() timeLine.setStartFrame(5000); QVERIFY(timeLine.currentFrame() > oldValue); timeLine.setFrameRange(0, 500); - QTRY_VERIFY(spy.count() > 1); + QTRY_VERIFY(spy.size() > 1); QVERIFY(timeLine.currentFrame() < oldValue); } @@ -102,7 +102,7 @@ void tst_QTimeLine::currentTime() spy.clear(); timeLine.setCurrentTime(timeLine.duration()/2); timeLine.setCurrentTime(timeLine.duration()/2); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); spy.clear(); QCOMPARE(timeLine.currentTime(), timeLine.duration()/2); timeLine.resume(); @@ -153,10 +153,10 @@ void tst_QTimeLine::bindableCurrentTime() spy.clear(); QProperty referenceCurrentTime(timeLine.duration() / 2); timeLine.bindableCurrentTime().setBinding([&]() { return referenceCurrentTime.value(); }); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); // setting it a second time to check that valueChanged() is emitted only once referenceCurrentTime = timeLine.duration() / 2; - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); spy.clear(); QCOMPARE(timeLine.currentTime(), timeLine.duration() / 2); @@ -172,7 +172,7 @@ void tst_QTimeLine::bindableCurrentTime() spy.clear(); referenceCurrentTime = 0; QCOMPARE(currentTimeObserver.value(), timeLine.duration()); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); } void tst_QTimeLine::duration() @@ -236,7 +236,7 @@ void tst_QTimeLine::frameRate() timeLine.start(); QTest::qWait(timeLine.duration()*2); QCOMPARE(timeLine.state(), QTimeLine::NotRunning); - int slowCount = spy.count(); + int slowCount = spy.size(); // Faster!! timeLine.setUpdateInterval(1000 / 100); @@ -245,7 +245,7 @@ void tst_QTimeLine::frameRate() timeLine.start(); QTest::qWait(timeLine.duration()*2); QCOMPARE(timeLine.state(), QTimeLine::NotRunning); - QVERIFY2(slowCount < spy.count(), QByteArray::number(spy.count())); + QVERIFY2(slowCount < spy.size(), QByteArray::number(spy.size())); } void tst_QTimeLine::bindableUpdateInterval() @@ -270,7 +270,7 @@ void tst_QTimeLine::bindableUpdateInterval() timeLine.start(); QTest::qWait(timeLine.duration() * 2); QCOMPARE(timeLine.state(), QTimeLine::NotRunning); - int slowCount = spy.count(); + int slowCount = spy.size(); // Faster!! updateIntervalReference = 1000 / 100; @@ -279,7 +279,7 @@ void tst_QTimeLine::bindableUpdateInterval() timeLine.start(); QTest::qWait(timeLine.duration() * 2); QCOMPARE(timeLine.state(), QTimeLine::NotRunning); - QVERIFY2(slowCount < spy.count(), QByteArray::number(spy.count())); + QVERIFY2(slowCount < spy.size(), QByteArray::number(spy.size())); } void tst_QTimeLine::value() @@ -294,7 +294,7 @@ void tst_QTimeLine::value() QTRY_VERIFY(timeLine.currentValue() > 0); QTRY_COMPARE(timeLine.state(), QTimeLine::NotRunning); QCOMPARE(timeLine.currentValue(), 1.0); - QVERIFY(spy.count() > 0); + QVERIFY(spy.size() > 0); // Reverse should decrease the value timeLine.setCurrentTime(100); @@ -380,8 +380,8 @@ void tst_QTimeLine::loopCount() loop.exec(); - QCOMPARE(finishedSpy.count(), 1); - QCOMPARE(frameChangedSpy.count(), 11); + QCOMPARE(finishedSpy.size(), 1); + QCOMPARE(frameChangedSpy.size(), 11); for (int i = 0; i < 11; ++i) QCOMPARE(frameChangedSpy.at(i).at(0).toInt(), (i+1) % 3); } @@ -390,8 +390,8 @@ void tst_QTimeLine::loopCount() timeLine.start(); loop.exec(); - QCOMPARE(finishedSpy.count(), 2); - QCOMPARE(frameChangedSpy.count(), 22); + QCOMPARE(finishedSpy.size(), 2); + QCOMPARE(frameChangedSpy.size(), 22); for (int i = 11; i < 22; ++i) { QCOMPARE(frameChangedSpy.at(i).at(0).toInt(), 2 - (i+2) % 3); } @@ -456,8 +456,8 @@ void tst_QTimeLine::bindableLoopCount() loop.exec(); - QCOMPARE(finishedSpy.count(), 1); - QCOMPARE(frameChangedSpy.count(), 11); + QCOMPARE(finishedSpy.size(), 1); + QCOMPARE(frameChangedSpy.size(), 11); for (int i = 0; i < 11; ++i) QCOMPARE(frameChangedSpy.at(i).at(0).toInt(), (i + 1) % 3); } @@ -466,8 +466,8 @@ void tst_QTimeLine::bindableLoopCount() timeLine.start(); loop.exec(); - QCOMPARE(finishedSpy.count(), 2); - QCOMPARE(frameChangedSpy.count(), 22); + QCOMPARE(finishedSpy.size(), 2); + QCOMPARE(frameChangedSpy.size(), 22); for (int i = 11; i < 22; ++i) QCOMPARE(frameChangedSpy.at(i).at(0).toInt(), 2 - (i + 2) % 3); } @@ -636,14 +636,14 @@ void tst_QTimeLine::frameChanged() timeLine.start(); QTest::qWait(timeLine.duration()/2); QCOMPARE(timeLine.state(), QTimeLine::Running); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); QTest::qWait(timeLine.duration()); if (timeLine.state() != QTimeLine::NotRunning) QEXPECT_FAIL("", "QTBUG-24796: QTimeLine runs slower than it should", Abort); QCOMPARE(timeLine.state(), QTimeLine::NotRunning); - if (spy.count() != 1) + if (spy.size() != 1) QEXPECT_FAIL("", "QTBUG-24796: QTimeLine runs slower than it should", Abort); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); // Test what happens when the frames are all emitted well before duration expires. timeLine.setUpdateInterval(5); @@ -652,7 +652,7 @@ void tst_QTimeLine::frameChanged() timeLine.start(); QTest::qWait(timeLine.duration()*2); QCOMPARE(timeLine.state(), QTimeLine::NotRunning); - QCOMPARE(spy.count(), 10); + QCOMPARE(spy.size(), 10); } void tst_QTimeLine::stopped() @@ -665,11 +665,11 @@ void tst_QTimeLine::stopped() timeLine.start(); QTest::qWait(timeLine.duration()*2); QCOMPARE(timeLine.state(), QTimeLine::NotRunning); - QCOMPARE(spy.count(), 2); + QCOMPARE(spy.size(), 2); spy.clear(); timeLine.start(); timeLine.stop(); - QCOMPARE(spy.count(), 2); + QCOMPARE(spy.size(), 2); timeLine.setDirection(QTimeLine::Backward); QCOMPARE(timeLine.loopCount(), 1); } @@ -681,13 +681,13 @@ void tst_QTimeLine::finished() QSignalSpy spy(&timeLine, &QTimeLine::finished); QVERIFY(spy.isValid()); timeLine.start(); - QTRY_COMPARE(spy.count(), 1); + QTRY_COMPARE(spy.size(), 1); QCOMPARE(timeLine.state(), QTimeLine::NotRunning); spy.clear(); timeLine.start(); timeLine.stop(); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); } void tst_QTimeLine::isRunning() @@ -720,7 +720,7 @@ void tst_QTimeLine::multipleTimeLines() timeLine.start(); timeLineKiller.stop(); QTest::qWait(timeLine.duration()*2); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); } void tst_QTimeLine::sineCurve() -- cgit v1.2.3