Skip to content

Commit

Permalink
Add test case for #75
Browse files Browse the repository at this point in the history
Looks like there is nothing to do because it's already handled
correctly, at elast when using `RecurrenceSet`.

closes #75
  • Loading branch information
dmfs committed Nov 6, 2022
1 parent bfe749b commit 09a2b6d
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,29 +53,27 @@ public RuleInstances(RecurrenceRule rule)
public InstanceIterator iterator(DateTime firstInstance)
{
RecurrenceRuleIterator iterator = mRrule.iterator(firstInstance);

return new InstanceIterator()
{
private final RecurrenceRuleIterator mIterator = iterator;


@Override
public boolean hasNext()
{
return mIterator.hasNext();
return iterator.hasNext();
}


@Override
public long next()
{
return mIterator.nextMillis();
return iterator.nextMillis();
}


@Override
public void fastForward(long until)
{
mIterator.fastForward(until);
iterator.fastForward(until);
}
};
}
Expand Down
35 changes: 35 additions & 0 deletions src/test/java/org/dmfs/rfc5545/iterable/RecurrenceSetTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,39 @@ void testWithDuplicates() throws InvalidRecurrenceRuleException
DateTime.parse("20220125")
));
}


// see https://github.com/dmfs/lib-recur/issues/75
@Test
void testBySetPosWithOutOfSyncFirst() throws InvalidRecurrenceRuleException
{
assertThat(new RecurrenceSet(DateTime.parse("20220101"),
new FirstAndRuleInstances(new RecurrenceRule("FREQ=MONTHLY;BYDAY=MO,FR;BYSETPOS=1,2,3;COUNT=6")
)),
iteratesTo(
DateTime.parse("20220101"),
DateTime.parse("20220103"),
DateTime.parse("20220107"),
DateTime.parse("20220204"),
DateTime.parse("20220207"),
DateTime.parse("20220211")));
}


// see https://github.com/dmfs/lib-recur/issues/75
@Test
void testBySetPosWithSyncedFirst() throws InvalidRecurrenceRuleException
{
assertThat(new RecurrenceSet(DateTime.parse("20220101"),
new RuleInstances(new RecurrenceRule("FREQ=MONTHLY;BYDAY=MO,FR;BYSETPOS=1,2,3;COUNT=6")
)),
iteratesTo(
DateTime.parse("20220103"),
DateTime.parse("20220107"),
DateTime.parse("20220110"),
DateTime.parse("20220204"),
DateTime.parse("20220207"),
DateTime.parse("20220211")
));
}
}

0 comments on commit 09a2b6d

Please sign in to comment.