< prev index next >

test/jdk/java/util/Formatter/spi/NoGroupingUsed.java

Print this page

        

*** 20,45 **** * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ ! /* * @test ! * @bug 8196399 * @summary test Formatter if any ArithmeticException is thrown while * formatting a number in the locale which does not use any ! * grouping, but specifies a grouping separator e.g. hy_AM. ! * @modules jdk.localedata */ import java.util.Formatter; import java.util.Locale; public class NoGroupingUsed { public static void main(String[] args) { ! ! Locale locale = new Locale("hy", "AM"); String number = "1234567"; String formatString = "%,d"; try { testGrouping(locale, formatString, number); --- 20,47 ---- * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ ! /* * @test ! * @bug 8196399 8202537 * @summary test Formatter if any ArithmeticException is thrown while * formatting a number in the locale which does not use any ! * grouping, but specifies a grouping separator. ! * @library provider ! * @build provider/module-info provider/test.NumberFormatProviderImpl ! * @run main/othervm -Djava.locale.providers=SPI,COMPAT NoGroupingUsed */ + import java.util.Formatter; import java.util.Locale; public class NoGroupingUsed { public static void main(String[] args) { ! Locale locale = new Locale("xx", "YY"); String number = "1234567"; String formatString = "%,d"; try { testGrouping(locale, formatString, number);
*** 47,61 **** throw new RuntimeException("[FAILED: ArithmeticException occurred" + " while formatting the number: " + number + ", with" + " format string: " + formatString + ", in locale: " + locale, ex); } - } private static void testGrouping(Locale locale, String formatString, String number) { - // test using String.format String result = String.format(locale, formatString, Integer.parseInt(number)); if (!number.equals(result)) { throw new RuntimeException("[FAILED: Incorrect formatting" + " of number: " + number + " using String.format with format" --- 49,61 ----
*** 72,78 **** + " of number: " + number + "using Formatter.format with" + " format string: " + formatString + " in locale: " + locale + ". Actual: " + sb.toString() + ", Expected: " + number + "]"); } } - } --- 72,77 ----
< prev index next >