From 16e4ed36358eb490e4b113fd205b33503a398afb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Tegn=C3=A9r?= Date: Tue, 25 Apr 2023 13:03:54 +0200 Subject: [PATCH] test: Added test for leap years. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Johannes Tegnér (cherry picked from commit b251bbb45335c230e3c4760a1d5ebfbd85597be3) --- src/test/java/PersonnummerTest.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/test/java/PersonnummerTest.java b/src/test/java/PersonnummerTest.java index 8242ed1..6187939 100644 --- a/src/test/java/PersonnummerTest.java +++ b/src/test/java/PersonnummerTest.java @@ -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; @@ -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() + ); + } }