Increase test coverage.

This commit is contained in:
dotasek.dev 2024-03-20 10:34:48 -04:00
parent 65ecbea430
commit d331c3a3e3
1 changed files with 122 additions and 2 deletions

View File

@ -20,7 +20,10 @@ public class LanguageSubtagRegistryTest {
LanguageSubtagRegistry registry = new LanguageSubtagRegistry();
// pick some random entries.
/* Test entries of every subtag type (language, script, variant, extLang, region)
These should cover both simple, and more complex entries with a larger number
of fields.
*/
/*
Type: language
@ -59,9 +62,126 @@ public class LanguageSubtagRegistryTest {
ScriptSubtag cpmn = registry.getScript("Cpmn");
assertEquals("Cypro-Minoan", cpmn.getDescriptions().get(0));
assertEquals("2017-08-13", cpmn.getAdded());
//assertNull(cpmn.getComments());
assertTrue(cpmn.getComments().isEmpty());
assertNull(cpmn.getDeprecated());
/*
Type: script
Subtag: Lisu
Description: Lisu
Description: Fraser
Added: 2009-03-13
*/
ScriptSubtag lisu = registry.getScript("Lisu");
assertEquals(2, lisu.getDescriptions().size());
assertEquals("Lisu", lisu.getDescriptions().get(0));
assertEquals("Fraser", lisu.getDescriptions().get(1));
assertEquals("2009-03-13", lisu.getAdded());
/*
Type: variant
Subtag: tarask
Description: Belarusian in Taraskievica orthography
Added: 2007-04-27
Prefix: be
Comments: The subtag represents Branislau Taraskievic's Belarusian
orthography as published in "Bielaruski klasycny pravapis" by Juras
Buslakou, Vincuk Viacorka, Zmicier Sanko, and Zmicier Sauka (Vilnia-
Miensk 2005).
*/
final String taraskComment = "The subtag represents Branislau Taraskievic's Belarusian orthography as published in \"Bielaruski klasycny pravapis\" by Juras Buslakou, Vincuk Viacorka, Zmicier Sanko, and Zmicier Sauka (Vilnia- Miensk 2005).";
VariantSubtag tarask = registry.getVariant("tarask");
assertEquals(1, tarask.getDescriptions().size());
assertEquals("Belarusian in Taraskievica orthography", tarask.getDescriptions().get(0));
assertEquals(1, tarask.getPrefixes().size());
assertEquals("be", tarask.getPrefixes().get(0));
assertEquals("2007-04-27", tarask.getAdded());
assertEquals(taraskComment, tarask.getComments().get(0));
/*
Type: variant
Subtag: ao1990
Description: Portuguese Language Orthographic Agreement of 1990 (Acordo
Ortográfico da Língua Portuguesa de 1990)
Added: 2015-05-06
Prefix: pt
Prefix: gl
Comments: Portuguese orthography conventions established in 1990 but
not brought into effect until 2009
*/
VariantSubtag ao1990 = registry.getVariant("ao1990");
assertEquals(1, ao1990.getDescriptions().size());
assertEquals("Portuguese Language Orthographic Agreement of 1990 (Acordo Ortográfico da Língua Portuguesa de 1990)", ao1990.getDescriptions().get(0));
assertEquals(2, ao1990.getPrefixes().size());
assertEquals("pt", ao1990.getPrefixes().get(0));
assertEquals("gl", ao1990.getPrefixes().get(1));
assertEquals(1, ao1990.getComments().size());
assertEquals("Portuguese orthography conventions established in 1990 but not brought into effect until 2009", ao1990.getComments().get(0));
/*
Type: extlang
Subtag: arq
Description: Algerian Arabic
Added: 2009-07-29
Preferred-Value: arq
Prefix: ar
Macrolanguage: ar
*/
ExtLangSubtag arq = registry.getExtLang("arq");
assertEquals(1, arq.getDescriptions().size());
assertEquals("Algerian Arabic", arq.getDescriptions().get(0));
assertEquals("2009-07-29", arq.getAdded());
assertEquals("arq", arq.getPreferredValue());
assertEquals("ar", arq.getPrefix());
assertEquals("ar", arq.getMacrolanguage());
/*
Type: extlang
Subtag: kvk
Description: Korean Sign Language
Added: 2009-07-29
Preferred-Value: kvk
Prefix: sgn
*/
ExtLangSubtag kvk = registry.getExtLang("kvk");
assertEquals(1, kvk.getDescriptions().size());
assertEquals("Korean Sign Language", kvk.getDescriptions().get(0));
assertEquals("2009-07-29", kvk.getAdded());
assertEquals("kvk", kvk.getPreferredValue());
assertEquals("sgn", kvk.getPrefix());
/*
Type: region
Subtag: YD
Description: Democratic Yemen
Added: 2005-10-16
Deprecated: 1990-08-14
Preferred-Value: YE
*/
RegionSubtag yd = registry.getRegion("YD");
assertEquals(1, yd.getDescriptions().size());
assertEquals("Democratic Yemen", yd.getDescriptions().get(0));
assertEquals("2005-10-16", yd.getAdded());
assertEquals("1990-08-14", yd.getDeprecated());
assertEquals("YE", yd.getPreferredValue());
/*
Type: region
Subtag: HN
Description: Honduras
Added: 2005-10-16
*/
RegionSubtag hn = registry.getRegion("HN");
assertEquals(1, hn.getDescriptions().size());
assertEquals("Honduras", hn.getDescriptions().get(0));
assertEquals("2005-10-16", hn.getAdded());
}
}