Skip to content

Commit fc9e10f

Browse files
committed
More tests
1 parent a14bf47 commit fc9e10f

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

lib/src/main/kotlin/at/bitfire/synctools/mapping/calendar/builder/DurationBuilder.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ class DurationBuilder: AndroidEntityBuilder {
109109
* Calculates the DURATION from DTEND - DTSTART, if possible.
110110
*
111111
* @param dtStart start date/date-time
112-
* @param dtEnd (optional) end date/date-time (ignored if it's not before [dtStart])
112+
* @param dtEnd (optional) end date/date-time (ignored if not after [dtStart])
113113
*
114114
* @return duration or `null` if no valid end time was available
115115
*/

lib/src/test/kotlin/at/bitfire/synctools/mapping/calendar/builder/DurationBuilderTest.kt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,18 @@ class DurationBuilderTest {
7171
assertEquals("P3D", result.entityValues.get(Events.DURATION))
7272
}
7373

74+
@Test
75+
fun `Recurring all-day event (with negative DURATION)`() {
76+
val result = Entity(ContentValues())
77+
val event = VEvent(propertyListOf(
78+
DtStart(Date("20251010")),
79+
Duration(Period.ofDays(-3)), // invalid negative DURATION will be treated as positive
80+
RRule("FREQ=DAILY;COUNT=5")
81+
))
82+
builder.build(event, event, result)
83+
assertEquals("P3D", result.entityValues.get(Events.DURATION))
84+
}
85+
7486
@Test
7587
fun `Recurring all-day event (with zero seconds DURATION)`() {
7688
val result = Entity(ContentValues())
@@ -95,6 +107,18 @@ class DurationBuilderTest {
95107
assertEquals("PT1H30M", result.entityValues.get(Events.DURATION))
96108
}
97109

110+
@Test
111+
fun `Recurring non-all-day event (with negative DURATION)`() {
112+
val result = Entity(ContentValues())
113+
val event = VEvent(propertyListOf(
114+
DtStart(DateTime("20251010T010203", tzVienna)),
115+
Duration(java.time.Duration.ofMinutes(-90)), // invalid negative DURATION will be treated as positive
116+
RRule("FREQ=DAILY;COUNT=5")
117+
))
118+
builder.build(event, event, result)
119+
assertEquals("PT1H30M", result.entityValues.get(Events.DURATION))
120+
}
121+
98122
@Test
99123
fun `Recurring all-day event (with DTEND)`() {
100124
val result = Entity(ContentValues())

0 commit comments

Comments
 (0)