Skip to content

Commit

Permalink
Improved test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
benfortuna committed Dec 14, 2018
1 parent 158d141 commit ef5fd2a
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 3 deletions.
17 changes: 15 additions & 2 deletions src/test/groovy/net/fortuna/ical4j/model/ComponentSpec.groovy
Expand Up @@ -13,12 +13,25 @@ class ComponentSpec extends Specification {
rrule 'FREQ=MONTHLY'
}
}
and: 'an expected list of periods'
def expectedPeriods = new PeriodList()
expectedPeriods.addAll(expectedResults.collect { new Period(it)})

expect: 'calculate recurrence set returns the expected results'
component.calculateRecurrenceSet(period) == expectedResults
component.calculateRecurrenceSet(period) == expectedPeriods

where:
period | expectedResults
new Period('20140630T000000Z/20150630T000000Z') | []
new Period('20140630T000000Z/20150630T000000Z') | ['20140730T000000/PT0S',
'20140830T000000/PT0S',
'20140930T000000/PT0S',
'20141030T000000/PT0S',
'20141130T000000/PT0S',
'20141230T000000/PT0S',
'20150130T000000/PT0S',
'20150330T000000/PT0S',
'20150430T000000/PT0S',
'20150530T000000/PT0S',
'20150630T000000/PT0S']
}
}
29 changes: 28 additions & 1 deletion src/test/groovy/net/fortuna/ical4j/model/RecurSpec.groovy
Expand Up @@ -78,6 +78,33 @@ class RecurSpec extends Specification {
'FREQ=WEEKLY;BYDAY=MO' | Value.DATE_TIME | '20110101T000000' | '20110201T000000' | ['20110103T000000', '20110110T000000', '20110117T000000', '20110124T000000', '20110131T000000']
'FREQ=DAILY;INTERVAL=14;WKST=MO;BYMONTH=10,12' | Value.DATE | '20181011' | '20181231' | ['20181011', '20181025', '20181206', '20181220']
'FREQ=WEEKLY;BYDAY=MO,TH,FR,SA,SU;BYHOUR=11;BYMINUTE=5' | Value.DATE_TIME | '20160325T110500' | '20160329T121000' | ['20160325T110500', '20160326T110500', '20160327T110500', '20160328T110500']
'FREQ=WEEKLY;INTERVAL=1;BYDAY=FR;WKST=MO;UNTIL=20170127T003000Z' | Value.DATE_TIME | '20160727T0030000Z' | '20170127T003000Z' | ['20160729T003000Z',
'20160805T003000Z',
'20160812T003000Z',
'20160819T003000Z',
'20160826T003000Z',
'20160902T003000Z',
'20160909T003000Z',
'20160916T003000Z',
'20160923T003000Z',
'20160930T003000Z',
'20161007T003000Z',
'20161014T003000Z',
'20161021T003000Z',
'20161028T003000Z',
'20161104T003000Z',
'20161111T003000Z',
'20161118T003000Z',
'20161125T003000Z',
'20161202T003000Z',
'20161209T003000Z',
'20161216T003000Z',
'20161223T003000Z',
'20161230T003000Z',
'20170106T003000Z',
'20170113T003000Z',
'20170120T003000Z',
'20170127T003000Z']
}

@Unroll
Expand Down Expand Up @@ -343,6 +370,6 @@ class RecurSpec extends Specification {

where:
rule | seed | start | expectedDate
'FREQ=MONTHLY;COUNT=100;INTERVAL=1' | new DateTime('20180329T025959') | new DateTime('20170729T030000') | new DateTime('20180329T030000')
'FREQ=MONTHLY;COUNT=100;INTERVAL=1' | new DateTime('20180329T025959') | new DateTime('20170729T030000') | new DateTime('20180329T025959')
}
}

0 comments on commit ef5fd2a

Please sign in to comment.