summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/widgets/qdatetimeedit
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-11-03 14:59:24 +0100
commit1c6bf3e09ea9722717caedcfcceaaf3d607615cf (patch)
treecad1814e104667a84ba7b5f403bbda015413e058 /tests/auto/widgets/widgets/qdatetimeedit
parent43cda7807b98552e9292ac09a1f6612d432a8b13 (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 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 <ivan.solovev@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'tests/auto/widgets/widgets/qdatetimeedit')
-rw-r--r--tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp42
1 files changed, 21 insertions, 21 deletions
diff --git a/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp b/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp
index d221c09e47..7db98283ce 100644
--- a/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp
+++ b/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp
@@ -1122,7 +1122,7 @@ void tst_QDateTimeEdit::enterKey()
// we include this test so a change to the behaviour can't go unnoticed.
QSignalSpy enterSpy(testWidget, SIGNAL(dateChanged(QDate)));
QTest::keyClick(testWidget, Qt::Key_Enter);
- QCOMPARE(enterSpy.count(), 1);
+ QCOMPARE(enterSpy.size(), 1);
QVariantList list = enterSpy.takeFirst();
QCOMPARE(list.at(0).toDate(), QDate(2004, 5, 9));
}
@@ -2197,7 +2197,7 @@ void tst_QDateTimeEdit::dateSignalChecking()
QSignalSpy timeSpy(testWidget, SIGNAL(timeChanged(QTime)));
testWidget->setDate(newDate);
- QCOMPARE(dateSpy.count(), timesEmitted);
+ QCOMPARE(dateSpy.size(), timesEmitted);
if (timesEmitted > 0) {
QList<QVariant> list = dateSpy.takeFirst();
@@ -2205,8 +2205,8 @@ void tst_QDateTimeEdit::dateSignalChecking()
d = qvariant_cast<QDate>(list.at(0));
QCOMPARE(d, newDate);
}
- QCOMPARE(dateTimeSpy.count(), timesEmitted);
- QCOMPARE(timeSpy.count(), 0);
+ QCOMPARE(dateTimeSpy.size(), timesEmitted);
+ QCOMPARE(timeSpy.size(), 0);
}
void tst_QDateTimeEdit::timeSignalChecking_data()
@@ -2233,7 +2233,7 @@ void tst_QDateTimeEdit::timeSignalChecking()
QSignalSpy timeSpy(testWidget, SIGNAL(timeChanged(QTime)));
testWidget->setTime(newTime);
- QCOMPARE(timeSpy.count(), timesEmitted);
+ QCOMPARE(timeSpy.size(), timesEmitted);
if (timesEmitted > 0) {
QList<QVariant> list = timeSpy.takeFirst();
@@ -2241,8 +2241,8 @@ void tst_QDateTimeEdit::timeSignalChecking()
t = qvariant_cast<QTime>(list.at(0));
QCOMPARE(t, newTime);
}
- QCOMPARE(dateTimeSpy.count(), timesEmitted);
- QCOMPARE(dateSpy.count(), 0);
+ QCOMPARE(dateTimeSpy.size(), timesEmitted);
+ QCOMPARE(dateSpy.size(), 0);
}
void tst_QDateTimeEdit::dateTimeSignalChecking_data()
@@ -2283,7 +2283,7 @@ void tst_QDateTimeEdit::dateTimeSignalChecking()
QSignalSpy dateTimeSpy(testWidget, SIGNAL(dateTimeChanged(QDateTime)));
testWidget->setDateTime(newDateTime);
- QCOMPARE(dateSpy.count(), timesDateEmitted);
+ QCOMPARE(dateSpy.size(), timesDateEmitted);
if (timesDateEmitted > 0) {
QCOMPARE(timesDateEmitted, 1);
QList<QVariant> list = dateSpy.takeFirst();
@@ -2291,14 +2291,14 @@ void tst_QDateTimeEdit::dateTimeSignalChecking()
d = qvariant_cast<QDate>(list.at(0));
QCOMPARE(d, newDateTime.date());
}
- QCOMPARE(timeSpy.count(), timesTimeEmitted);
+ QCOMPARE(timeSpy.size(), timesTimeEmitted);
if (timesTimeEmitted > 0) {
QList<QVariant> list = timeSpy.takeFirst();
QTime t;
t = qvariant_cast<QTime>(list.at(0));
QCOMPARE(t, newDateTime.time());
}
- QCOMPARE(dateTimeSpy.count(), timesDateTimeEmitted);
+ QCOMPARE(dateTimeSpy.size(), timesDateTimeEmitted);
if (timesDateTimeEmitted > 0) {
QList<QVariant> list = dateTimeSpy.takeFirst();
QDateTime dt;
@@ -3162,22 +3162,22 @@ void tst_QDateTimeEdit::task149097()
testWidget->setDisplayFormat("yyyy/MM/dd hh:mm:ss");
testWidget->setDateTime(QDateTime(QDate(2001, 02, 03), QTime(5, 1, 2)));
// QTest::keyClick(testWidget, Qt::Key_Enter);
- QCOMPARE(dtSpy.count(), 1);
- QCOMPARE(dSpy.count(), 1);
- QCOMPARE(tSpy.count(), 1);
+ QCOMPARE(dtSpy.size(), 1);
+ QCOMPARE(dSpy.size(), 1);
+ QCOMPARE(tSpy.size(), 1);
testWidget->setCurrentSection(QDateTimeEdit::YearSection);
testWidget->stepBy(1);
- QCOMPARE(dtSpy.count(), 2);
- QCOMPARE(dSpy.count(), 2);
- QCOMPARE(tSpy.count(), 1);
+ QCOMPARE(dtSpy.size(), 2);
+ QCOMPARE(dSpy.size(), 2);
+ QCOMPARE(tSpy.size(), 1);
testWidget->setCurrentSection(QDateTimeEdit::MinuteSection);
testWidget->stepBy(1);
- QCOMPARE(dtSpy.count(), 3);
- QCOMPARE(dSpy.count(), 2);
- QCOMPARE(tSpy.count(), 2);
+ QCOMPARE(dtSpy.size(), 3);
+ QCOMPARE(dSpy.size(), 2);
+ QCOMPARE(tSpy.size(), 2);
}
void tst_QDateTimeEdit::task148725()
@@ -4555,12 +4555,12 @@ void tst_QDateTimeEdit::stepModifierPressAndHold()
QStyle::CC_SpinBox, &spinBoxStyleOption, subControl, &edit);
QTest::mousePress(&edit, Qt::LeftButton, modifiers, buttonRect.center());
- QTRY_VERIFY(spy.length() >= 3);
+ QTRY_VERIFY(spy.size() >= 3);
QTest::mouseRelease(&edit, Qt::LeftButton, modifiers, buttonRect.center());
const auto value = spy.last().at(0);
QVERIFY(value.userType() == QMetaType::QDate);
- const QDate expectedDate = startDate.addYears(spy.length() *
+ const QDate expectedDate = startDate.addYears(spy.size() *
expectedStepModifier);
QCOMPARE(value.toDate(), expectedDate);
}