Move some repeated constants from tests into tst_QDate

Making them static constexpr class constants is tidier than
duplicating them in diverse tests.

Change-Id: I5a24c10d6db6f946581fa0523d28bdc80358e95e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Edward Welbourne 2023-03-24 15:29:55 +01:00
parent 79340518d7
commit 51bcad8a61

View File

@ -90,6 +90,8 @@ private:
return QDate::fromJulianDay(JULIAN_DAY_FOR_EPOCH);
}
static constexpr qint64 minJd = JulianDayMin;
static constexpr qint64 maxJd = JulianDayMax;
QDate invalidDate() const { return QDate(); }
};
@ -100,9 +102,6 @@ void tst_QDate::isNull_data()
QTest::addColumn<qint64>("jd");
QTest::addColumn<bool>("null");
qint64 minJd = JulianDayMin;
qint64 maxJd = JulianDayMax;
QTest::newRow("qint64 min") << std::numeric_limits<qint64>::min() << true;
QTest::newRow("minJd - 1") << minJd - 1 << true;
QTest::newRow("minJd") << minJd << false;
@ -695,8 +694,6 @@ void tst_QDate::julianDaysLimits()
{
qint64 min = std::numeric_limits<qint64>::min();
qint64 max = std::numeric_limits<qint64>::max();
qint64 minJd = JulianDayMin;
qint64 maxJd = JulianDayMax;
QDate maxDate = QDate::fromJulianDay(maxJd);
QDate minDate = QDate::fromJulianDay(minJd);
@ -919,9 +916,6 @@ void tst_QDate::addYears_data()
void tst_QDate::daysTo()
{
qint64 minJd = JulianDayMin;
qint64 maxJd = JulianDayMax;
QDate dt1(2000, 1, 1);
QDate dt2(2000, 1, 5);
QCOMPARE(dt1.daysTo(dt2), (qint64) 4);
@ -1684,9 +1678,6 @@ void tst_QDate::roundtrip() const
loopDate = loopDate.addDays(1);
}
qint64 minJd = JulianDayMin;
qint64 maxJd = JulianDayMax;
// Test Gregorian round trip at top end of conversion range
loopDate = QDate::fromJulianDay(maxJd);
while (loopDate.toJulianDay() >= maxJd - 146397) {