From 8f98953576425939976998ae9e5414fc8fedcfcf Mon Sep 17 00:00:00 2001 From: Arnau Mora Date: Sun, 5 Nov 2023 13:02:48 +0100 Subject: [PATCH] Added test from raw String Signed-off-by: Arnau Mora --- .../vcard4android/AndroidContactTest.kt | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/lib/src/androidTest/java/at/bitfire/vcard4android/AndroidContactTest.kt b/lib/src/androidTest/java/at/bitfire/vcard4android/AndroidContactTest.kt index 809e70f..6c28ea3 100644 --- a/lib/src/androidTest/java/at/bitfire/vcard4android/AndroidContactTest.kt +++ b/lib/src/androidTest/java/at/bitfire/vcard4android/AndroidContactTest.kt @@ -25,6 +25,8 @@ import org.junit.Assert.* import java.io.ByteArrayOutputStream import java.io.StringReader import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.ZoneOffset class AndroidContactTest { @@ -122,6 +124,29 @@ class AndroidContactTest { } } + @Test + fun testBirthdayWithOffset() { + val vCard = "BEGIN:VCARD\r\n" + + "VERSION:3.0\n\n" + + "N:Doe;John;;;\n\n" + + "FN:John Doe\n\n" + + "BDAY:20010415T000000+0200\n\n" + + "END:VCARD\n\n" + val contacts = Contact.fromReader(StringReader(vCard), false, null) + + assertEquals(1, contacts.size) + contacts.first().birthDay.let { birthday -> + assertNotNull(birthday) + + val date = birthday?.date + assertNotNull(date) + + assertEquals( + OffsetDateTime.of(2001, 4, 15, 0, 0, 0, 0, ZoneOffset.ofHours(2)), date + ) + } + } + @Test @MediumTest fun testLargeTransactionManyRows() {