示例#1
0
  public void test_getISO3Language() {
    // Empty language code.
    assertEquals("", new Locale("", "US").getISO3Language());

    // Invalid language code.
    try {
      assertEquals("", new Locale("xx", "US").getISO3Language());
      fail();
    } catch (MissingResourceException expected) {
      assertEquals("FormatData_xx_US", expected.getClassName());
      assertEquals("ShortLanguage", expected.getKey());
    }

    // Valid language code.
    assertEquals("eng", new Locale("en", "").getISO3Language());
    assertEquals("eng", new Locale("en", "CA").getISO3Language());
    assertEquals("eng", new Locale("en", "XX").getISO3Language());
  }
示例#2
0
  public void test_getISO3Country() {
    // Empty country code.
    assertEquals("", new Locale("en", "").getISO3Country());

    // Invalid country code.
    try {
      assertEquals("", new Locale("en", "XX").getISO3Country());
      fail();
    } catch (MissingResourceException expected) {
      assertEquals("FormatData_en_XX", expected.getClassName());
      assertEquals("ShortCountry", expected.getKey());
    }

    // Valid country code.
    assertEquals("CAN", new Locale("", "CA").getISO3Country());
    assertEquals("CAN", new Locale("en", "CA").getISO3Country());
    assertEquals("CAN", new Locale("xx", "CA").getISO3Country());
  }