From 5c6a11e72755cc500c77b5fa92dae43ab990f21e Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Thu, 24 Sep 2026 16:18:02 +0200 Subject: fix: expand a long dense series completely and flag overrides' own all-day --- tests/test_calendarstore.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'tests/test_calendarstore.cpp') diff --git a/tests/test_calendarstore.cpp b/tests/test_calendarstore.cpp index c7e4836..b27c6ec 100644 --- a/tests/test_calendarstore.cpp +++ b/tests/test_calendarstore.cpp @@ -101,6 +101,8 @@ private slots: void honoursCountAndUntil(); void expandsMonthlyLastFridayAndYearlyByMonth(); void readsTheRepeatRuleExdatesAndOverrides(); + void expandsADenseOldSeriesToTheWindow(); + void anAllDayOverrideKeepsItsOwnAllDayFlag(); }; void TestCalendarStore::parsesAUtcEvent() @@ -282,6 +284,24 @@ void TestCalendarStore::anOverrideReplacesItsSlotAndMovesFreely() QCOMPARE(occ[0].recurrenceId, utc(2026, 9, 22, 8)); } +void TestCalendarStore::anAllDayOverrideKeepsItsOwnAllDayFlag() +{ + // The master is timed, the override is an all-day "day off". The override + // occurrence must carry its OWN all-day state, not the master's. + const QString body = vevent(QStringLiteral( + "UID:adov@example.org\r\nDTSTART:20260921T080000Z\r\nDTEND:20260921T090000Z\r\n" + "RRULE:FREQ=DAILY\r\n")) + + vevent(QStringLiteral( + "UID:adov@example.org\r\nRECURRENCE-ID:20260922T080000Z\r\n" + "DTSTART;VALUE=DATE:20260922\r\nDTEND;VALUE=DATE:20260923\r\nSUMMARY:Day off\r\n")); + const QDateTime day0(QDate(2026, 9, 22), QTime(0, 0)); + const QList occ = expand(body, day0, day0.addDays(1)); + QCOMPARE(occ.size(), 1); + QVERIFY(occ[0].isOverride); + QVERIFY(occ[0].allDay); + QCOMPARE(occ[0].recurrenceId, utc(2026, 9, 22, 8)); +} + void TestCalendarStore::anInfiniteSeriesYieldsOnlyTheWindow() { const QList occ = expand(vevent(QStringLiteral( @@ -291,6 +311,19 @@ void TestCalendarStore::anInfiniteSeriesYieldsOnlyTheWindow() QCOMPARE(occ.first().start, utc(2026, 9, 1, 8)); } +void TestCalendarStore::expandsADenseOldSeriesToTheWindow() +{ + // A daily series from 1970 needs ~20700 iterator steps to reach a 2026 + // window. At a 10000 cap the walk dies around 1997 and returns nothing. + const QList occ = expand(vevent(QStringLiteral( + "UID:dense@example.org\r\nDTSTART:19700101T080000Z\r\n" + "DTEND:19700101T090000Z\r\nRRULE:FREQ=DAILY\r\n")), + utc(2026, 9, 21), utc(2026, 9, 28)); + QCOMPARE(occ.size(), 7); + QCOMPARE(occ.first().start, utc(2026, 9, 21, 8)); + QCOMPARE(occ.last().start, utc(2026, 9, 27, 8)); +} + void TestCalendarStore::honoursCountAndUntil() { QCOMPARE(expand(vevent(QStringLiteral( -- cgit v1.2.3