Skip to content

Commit

Permalink
InternationalFixedEra.CE#getValue returns incorrect value (#205)
Browse files Browse the repository at this point in the history
There is but one era in the InternationalFixed chronology, documented to have the value 1.
This PR corrects the incorrect behaviour.

Co-authored-by: Carlo Dapor <carlo.dapor@abraxas.ch>
  • Loading branch information
catull and Carlo Dapor committed Aug 2, 2022
1 parent 58c9c6d commit 8a52854
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
/**
* An era in the International Fixed calendar system.
* <p>
* The International Fixed calendar system only has one era.
* The International Fixed calendar system officially only has one era.
* The current era, for years from 1 onwards, is known as 'Current Era'.
* All previous years are invalid.
* <p>
Expand Down Expand Up @@ -85,7 +85,7 @@ public static InternationalFixedEra of(final int era) {
*/
@Override
public int getValue() {
return ordinal();
return 1;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,30 @@ public void test_lengthOfMonth_specific() {
assertEquals(29, InternationalFixedDate.of(2000, 6, 29).lengthOfMonth());
}

@Test
public void test_era_valid() {
Era era = InternationalFixedChronology.INSTANCE.eraOf(1);
assertNotNull(era);
assertEquals(1, era.getValue());
}

//-----------------------------------------------------------------------
// data_invalidEraValues()
//-----------------------------------------------------------------------
public static Object[][] data_invalidEraValues() {
return new Object[][] {
{-1},
{0},
{2},
};
}

@ParameterizedTest
@MethodSource("data_invalidEraValues")
public void test_era_invalid(int eraValue) {
assertThrows(DateTimeException.class, () -> InternationalFixedChronology.INSTANCE.eraOf(eraValue));
}

//-----------------------------------------------------------------------
// era, prolepticYear and dateYearDay
//-----------------------------------------------------------------------
Expand Down

0 comments on commit 8a52854

Please sign in to comment.