Skip to content

Instantly share code, notes, and snippets.

@sergiandreplace
Last active August 25, 2019 18:30
Show Gist options
  • Save sergiandreplace/29f995cd7a135484fa36ba05b6d0795e to your computer and use it in GitHub Desktop.
Save sergiandreplace/29f995cd7a135484fa36ba05b6d0795e to your computer and use it in GitHub Desktop.
A test to check if standalone month formatting for catalan works correctly
package com.sergiandreplace.localization
import org.junit.Test
import org.threeten.bp.LocalDate
import org.threeten.bp.Month
import org.threeten.bp.format.DateTimeFormatter
import java.util.Locale
import org.junit.Assert.assertEquals
class CatalanDateFormatTest {
val locale = Locale("ca", "ES")
val contextualFormatter = DateTimeFormatter.ofPattern("d MMMM \'de\' YYYY", locale)
val standaloneFormatter = DateTimeFormatter.ofPattern("LLLL \'de\' YYYY", locale)
@Test
fun `donat un dia de març el resultat contextualitzat no ha de duur apòstrof`() {
val date = LocalDate.of(2019, Month.MARCH, 11)
val result = contextualFormatter.format(date)
assertEquals("11 de març de 2019", result)
}
@Test
fun `donat un dia d'abril el resultat contextualitzat ha de duur apòstrof`() {
val date = LocalDate.of(2019, Month.APRIL, 11)
val result = contextualFormatter.format(date)
assertEquals("11 d’abril de 2019", result)
}
@Test
fun `donat un dia de març el resultat independent no ha de duur determinant`() {
val date = LocalDate.of(2019, Month.MARCH, 11)
val result = standaloneFormatter.format(date)
assertEquals("març de 2019", result)
}
@Test
fun `donat un dia d'abril el resultat independent no ha de duur determinant`() {
val date = LocalDate.of(2019, Month.APRIL, 11)
val result = standaloneFormatter.format(date)
assertEquals("abril de 2019", result)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment