• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package com.ibm.icu.dev.test;
2 
3 import java.util.Arrays;
4 import java.util.List;
5 
6 import com.ibm.icu.text.GenderInfo;
7 import com.ibm.icu.text.GenderInfo.Gender;
8 import com.ibm.icu.util.ULocale;
9 
10 public class GenderInfoTest extends TestFmwk {
main(String[] args)11     public static void main(String[] args) {
12         new GenderInfoTest().run(args);
13     }
14 
15     public static GenderInfo NEUTRAL_LOCALE = new GenderInfo(ULocale.ENGLISH);
16     public static GenderInfo MIXED_NEUTRAL_LOCALE = new GenderInfo(new ULocale("is"));
17     public static GenderInfo MALE_TAINTS_LOCALE = new GenderInfo(ULocale.FRANCE);
18 
TestEmpty()19     public void TestEmpty() {
20         check(Gender.OTHER, Gender.OTHER);
21     }
22 
TestOne()23     public void TestOne() {
24         for (Gender g : Gender.values()) {
25             check(g, g, g);
26         }
27     }
28 
TestOther()29     public void TestOther() {
30         check(Gender.OTHER, Gender.MALE, Gender.MALE, Gender.FEMALE);
31         check(Gender.OTHER, Gender.MALE, Gender.FEMALE, Gender.MALE);
32         check(Gender.MALE, Gender.MALE, Gender.MALE, Gender.MALE);
33         check(Gender.FEMALE, Gender.FEMALE, Gender.FEMALE, Gender.FEMALE);
34         check(Gender.OTHER, Gender.MALE, Gender.FEMALE, Gender.OTHER);
35     }
36 
check(Gender mixed, Gender taints, Gender... genders)37     public void check(Gender mixed, Gender taints, Gender... genders) {
38         List<Gender> mixed0 = Arrays.asList(genders);
39         assertEquals("neutral " + mixed0, Gender.OTHER, NEUTRAL_LOCALE.getListGender(mixed0));
40         assertEquals("mixed neutral " + mixed0, mixed, MIXED_NEUTRAL_LOCALE.getListGender(mixed0));
41         assertEquals("male taints " + mixed0, taints, MALE_TAINTS_LOCALE.getListGender(mixed0));
42     }
43 }
44