Skip to content

Commit

Permalink
Fix addition of multiples of 10 days
Browse files Browse the repository at this point in the history
Fix addition of multiples of 10 days
Test lastDayOfYear
  • Loading branch information
David Leunen committed Mar 2, 2017
1 parent f7ac065 commit 8daddaf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -478,9 +478,6 @@ FrenchRepublicDate plusWeeks(long weeks) {

@Override
FrenchRepublicDate plusDays(long days) {
if (days % 10 == 0) {
return plusWeeks(days / 10);
}
return (FrenchRepublicDate) super.plusDays(days);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ public void test_plusDays(FrenchRepublicDate frenchRepublic, LocalDate iso) {
assertEquals(LocalDate.from(frenchRepublic.plus(35, DAYS)), iso.plusDays(35));
assertEquals(LocalDate.from(frenchRepublic.plus(-1, DAYS)), iso.plusDays(-1));
assertEquals(LocalDate.from(frenchRepublic.plus(-59, DAYS)), iso.plusDays(-59));
assertEquals(LocalDate.from(frenchRepublic.plus(-60, DAYS)), iso.plusDays(-60));
}

@Test(dataProvider = "samples")
Expand All @@ -249,6 +250,7 @@ public void test_minusDays(FrenchRepublicDate frenchRepublic, LocalDate iso) {
assertEquals(LocalDate.from(frenchRepublic.minus(35, DAYS)), iso.minusDays(35));
assertEquals(LocalDate.from(frenchRepublic.minus(-1, DAYS)), iso.minusDays(-1));
assertEquals(LocalDate.from(frenchRepublic.minus(-57, DAYS)), iso.minusDays(-57));
assertEquals(LocalDate.from(frenchRepublic.minus(-60, DAYS)), iso.minusDays(-60));
}

@Test(dataProvider = "samples")
Expand Down Expand Up @@ -611,6 +613,13 @@ public void test_adjust2() {
assertEquals(test, FrenchRepublicDate.of(3, 12, 30));
}

@Test
public void test_adjust3() {
FrenchRepublicDate base = FrenchRepublicDate.of(3, 5, 2);
FrenchRepublicDate test = base.with(TemporalAdjusters.lastDayOfYear());
assertEquals(test, FrenchRepublicDate.of(3, 13, 6));
}

//-----------------------------------------------------------------------
// FrenchRepublicDate.with(Local*)
//-----------------------------------------------------------------------
Expand Down

0 comments on commit 8daddaf

Please sign in to comment.