Skip to content

Commit

Permalink
test: Added test for leap years.
Browse files Browse the repository at this point in the history
Signed-off-by: Johannes Tegnér <johannes@jitesoft.com>
(cherry picked from commit b251bbb)
  • Loading branch information
Johannestegner committed Apr 25, 2023
1 parent c5bcf08 commit 16e4ed3
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/test/java/PersonnummerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import dev.personnummer.*;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;

Expand Down Expand Up @@ -231,4 +232,11 @@ public void testOrgNummer(PersonnummerData ssn) {
assertThrows(PersonnummerException.class, () -> Personnummer.parse(ssn.separatedFormat, new Options(false)));
}

@Test
void testLeapYear() {
assertEquals(
"Invalid personal identity number: Invalid date 'February 29' as '1985' is not a leap year",
assertThrows(PersonnummerException.class, () -> Personnummer.parse("8502291234")).getMessage()
);
}
}

0 comments on commit 16e4ed3

Please sign in to comment.