Add unit test for YearMonthDate
Coverage analysis showed that QCalendar::YearMonthDate was not rigorously tested. This patch adds a unit test. Pick-to: 6.0 Change-Id: I0af485d13c4883764b61ea1e35455905cc77b966 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
This commit is contained in:
parent
7b0fd20775
commit
b02147788b
@ -47,6 +47,7 @@ private slots:
|
||||
void specific();
|
||||
void daily_data() { basic_data(); }
|
||||
void daily();
|
||||
void testYearMonthDate();
|
||||
};
|
||||
|
||||
// Support for basic():
|
||||
@ -255,5 +256,35 @@ void tst_QCalendar::daily()
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QCalendar::testYearMonthDate()
|
||||
{
|
||||
QCalendar::YearMonthDay defYMD;
|
||||
QCOMPARE(defYMD.year, QCalendar::Unspecified);
|
||||
QCOMPARE(defYMD.month, QCalendar::Unspecified);
|
||||
QCOMPARE(defYMD.day, QCalendar::Unspecified);
|
||||
|
||||
QCalendar::YearMonthDay ymd2020(2020);
|
||||
QCOMPARE(ymd2020.year, 2020);
|
||||
QCOMPARE(ymd2020.month, 1);
|
||||
QCOMPARE(ymd2020.day, 1);
|
||||
|
||||
QVERIFY(!QCalendar::YearMonthDay(
|
||||
QCalendar::Unspecified, QCalendar::Unspecified, QCalendar::Unspecified).isValid());
|
||||
QVERIFY(!QCalendar::YearMonthDay(
|
||||
QCalendar::Unspecified, QCalendar::Unspecified, 1).isValid());
|
||||
QVERIFY(!QCalendar::YearMonthDay(
|
||||
QCalendar::Unspecified, 1, QCalendar::Unspecified).isValid());
|
||||
QVERIFY(QCalendar::YearMonthDay(
|
||||
QCalendar::Unspecified, 1, 1).isValid());
|
||||
QVERIFY(!QCalendar::YearMonthDay(
|
||||
2020, QCalendar::Unspecified, QCalendar::Unspecified).isValid());
|
||||
QVERIFY(!QCalendar::YearMonthDay(
|
||||
2020, QCalendar::Unspecified, 1).isValid());
|
||||
QVERIFY(!QCalendar::YearMonthDay(
|
||||
2020, 1, QCalendar::Unspecified).isValid());
|
||||
QVERIFY(QCalendar::YearMonthDay(
|
||||
2020, 1, 1).isValid());
|
||||
}
|
||||
|
||||
QTEST_APPLESS_MAIN(tst_QCalendar)
|
||||
#include "tst_qcalendar.moc"
|
||||
|
Loading…
Reference in New Issue
Block a user