@@ -40,28 +40,35 @@ class LanguagePreferenceTest {
4040
4141 @Test
4242 fun entries () {
43+ // setup
44+ val expected = languageTags.filter { it.isNotEmpty() }.map { tag ->
45+ val locale = Locale .forLanguageTag(tag)
46+ locale.getDisplayName(locale).titlecaseFirst(locale)
47+ }.sorted()
48+
4349 // execute
4450 val actual: Array <CharSequence > = fixture.entries
51+
4552 // validate
4653 assertThat(actual).hasSize(languageTags.size)
47-
48- // Check system default entry
4954 assertThat(actual[0 ]).isEqualTo(mainActivity.getString(R .string.system_default))
50-
51- // Check language entries
52- languageTags.drop(1 ).forEachIndexed { index, tag ->
53- val locale = Locale .forLanguageTag(tag)
54- val displayName = locale.getDisplayName(locale).titlecaseFirst(locale)
55- assertThat(actual[index + 1 ]).isEqualTo(displayName)
56- }
55+ assertThat(actual.drop(1 )).containsExactlyElementsOf(expected)
5756 }
5857
5958 @Test
6059 fun entryValues () {
60+ // setup
61+ val expected = languageTags.filter { it.isNotEmpty() }.map { tag ->
62+ val locale = Locale .forLanguageTag(tag)
63+ Data (tag, locale.getDisplayName(locale).titlecaseFirst(locale))
64+ }.sorted().map { it.code }
65+
6166 // execute
6267 val actual: Array <CharSequence > = fixture.entryValues
68+
6369 // validate
6470 assertThat(actual).hasSize(languageTags.size)
65- assertThat(actual).containsExactlyElementsOf(languageTags)
71+ assertThat(actual[0 ]).isEqualTo(" " )
72+ assertThat(actual.drop(1 )).containsExactlyElementsOf(expected)
6673 }
6774}
0 commit comments