Пример #1
0
  private static void testGetFallbackLocale() {
    Locale current = Locale.getDefault();
    Locale.setDefault(Locale.ITALY);
    try {
      Locale loc = CONTROL.getFallbackLocale("any", Locale.FRANCE);
      if (loc != Locale.ITALY) {
        error("getFallbackLocale: got %s, expected %s%n", toString(loc), toString(Locale.ITALY));
      }
      loc = CONTROL.getFallbackLocale("any", Locale.ITALY);
      if (loc != null) {
        error("getFallbackLocale: got %s, expected null%n", toString(loc));
      }
    } finally {
      Locale.setDefault(current);
    }

    final int NARGS = 2;
    for (int mask = 0; mask < (1 << NARGS) - 1; mask++) {
      Object[] data = getNpeArgs(NARGS, mask);
      try {
        Locale loc = CONTROL.getFallbackLocale((String) data[0], (Locale) data[1]);
        error("getFallbackLocale(%s, %s) doesn't throw NPE.%n", data[0], data[1]);
      } catch (NullPointerException e) {
      }
    }
  }
Пример #2
0
 private static String toString(Locale loc) {
   if (loc == null) return "null";
   return "\"" + loc.getLanguage() + "_" + loc.getCountry() + "_" + loc.getVariant() + "\"";
 }