Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/bitfireAT/vcard4android.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/androidTest/java/at/bitfire/vcard4android/LocaleNonWesternDigitsTest.kt')
-rw-r--r--src/androidTest/java/at/bitfire/vcard4android/LocaleNonWesternDigitsTest.kt46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/androidTest/java/at/bitfire/vcard4android/LocaleNonWesternDigitsTest.kt b/src/androidTest/java/at/bitfire/vcard4android/LocaleNonWesternDigitsTest.kt
new file mode 100644
index 0000000..823f5db
--- /dev/null
+++ b/src/androidTest/java/at/bitfire/vcard4android/LocaleNonWesternDigitsTest.kt
@@ -0,0 +1,46 @@
+package at.bitfire.vcard4android
+
+import ezvcard.Ezvcard
+import ezvcard.VCard
+import ezvcard.VCardVersion
+import ezvcard.property.Geo
+import org.junit.Assert.assertEquals
+import org.junit.Before
+import org.junit.ComparisonFailure
+import org.junit.Test
+import java.util.*
+
+class LocaleNonWesternDigitsTest {
+
+ companion object {
+ val locale = Locale("fa", "ir", "u-un-arabext")
+ }
+
+ @Before
+ fun verifyLocale() {
+ assertEquals("Persian (Iran) locale not available", "fa", locale.language)
+ Locale.setDefault(locale)
+ }
+
+ @Test
+ fun testLocale_StringFormat() {
+ assertEquals("۲۰۲۰", String.format("%d", 2020))
+ }
+
+ @Test
+ fun testLocale_StringFormat_Root() {
+ assertEquals("2020", String.format(Locale.ROOT, "%d", 2020))
+ }
+
+ @Test(expected = ComparisonFailure::class) // should not fail in future
+ fun testLocale_ezVCard() {
+ val vCard = VCard(VCardVersion.V4_0)
+ vCard.geo = Geo(1.0, 2.0)
+ assertEquals("BEGIN:VCARD\r\n" +
+ "VERSION:4.0\r\n" +
+ "PRODID:ez-vcard 0.11.1\r\n" +
+ "GEO:geo:1.0,2.0\r\n" + // fails: is "GEO:geo:۱.۰,۲.۰\r\n" instead
+ "END:VCARD\r\n", Ezvcard.write(vCard).go())
+ }
+
+} \ No newline at end of file