summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/time/qdate/tst_qdate.cpp
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2020-01-15 01:00:38 +0100
committerQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2020-01-15 01:00:39 +0100
commitc3123c757a2301445ac286ce2c8af20959151e21 (patch)
treec8f5421725d0fe0cfe8a29136937e54d6f3f95c2 /tests/auto/corelib/time/qdate/tst_qdate.cpp
parent2cbc5f6f7ae8ba580126a7cafc1898377c2a2407 (diff)
parent7a59d6f138ff8799170cc03d709525ab965d703a (diff)
Merge remote-tracking branch 'origin/5.14' into 5.15
Diffstat (limited to 'tests/auto/corelib/time/qdate/tst_qdate.cpp')
-rw-r--r--tests/auto/corelib/time/qdate/tst_qdate.cpp39
1 files changed, 17 insertions, 22 deletions
diff --git a/tests/auto/corelib/time/qdate/tst_qdate.cpp b/tests/auto/corelib/time/qdate/tst_qdate.cpp
index dd2cb3eea8..567209dcf6 100644
--- a/tests/auto/corelib/time/qdate/tst_qdate.cpp
+++ b/tests/auto/corelib/time/qdate/tst_qdate.cpp
@@ -88,7 +88,7 @@ private slots:
void toStringDateFormat();
void isLeapYear();
void yearsZeroToNinetyNine();
- void negativeYear() const;
+ void printNegativeYear_data() const;
void printNegativeYear() const;
void roundtripGermanLocale() const;
#if QT_CONFIG(textdate) && QT_DEPRECATED_SINCE(5, 10)
@@ -1458,33 +1458,28 @@ void tst_QDate::yearsZeroToNinetyNine()
}
}
-
-void tst_QDate::negativeYear() const
+void tst_QDate::printNegativeYear_data() const
{
- QDate y(-20, 3, 4);
- QVERIFY(y.isValid());
- QCOMPARE(y.year(), -20);
+ QTest::addColumn<int>("year");
+ QTest::addColumn<QString>("expect");
+ QTest::newRow("millennium") << -1000 << QStringLiteral("-1000");
+ QTest::newRow("century") << -500 << QStringLiteral("-0500");
+ QTest::newRow("decade") << -20 << QStringLiteral("-0020");
+ QTest::newRow("year") << -7 << QStringLiteral("-0007");
}
void tst_QDate::printNegativeYear() const
{
- {
- QDate date(-500, 3, 4);
- QVERIFY(date.isValid());
- QCOMPARE(date.toString(QLatin1String("yyyy")), QString::fromLatin1("-0500"));
- }
-
- {
- QDate date(-10, 3, 4);
- QVERIFY(date.isValid());
- QCOMPARE(date.toString(QLatin1String("yyyy")), QString::fromLatin1("-0010"));
- }
+ QFETCH(int, year);
+ QFETCH(QString, expect);
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ expect.replace(QLatin1Char('-'), QLocale().negativeSign());
+#endif
- {
- QDate date(-2, 3, 4);
- QVERIFY(date.isValid());
- QCOMPARE(date.toString(QLatin1String("yyyy")), QString::fromLatin1("-0002"));
- }
+ QDate date(year, 3, 4);
+ QVERIFY(date.isValid());
+ QCOMPARE(date.year(), year);
+ QCOMPARE(date.toString(QLatin1String("yyyy")), expect);
}
void tst_QDate::roundtripGermanLocale() const