< prev index next >

test/jdk/java/util/Formatter/FormatLocale.java

Print this page




  90             "1.00000E+08",
  91             "I");
  92 
  93     static void formatLocaleTest() {
  94         StringBuilder sb = new StringBuilder();
  95 
  96         // checks whether upper casing follows Locale.Category.FORMAT locale
  97         IntStream.range(0, src.size()).forEach(i -> {
  98             sb.setLength(0);
  99             Locale.setDefault(Locale.Category.FORMAT, defaultLocale.get(i));
 100             new Formatter(sb).format(conversions.get(i), src.get(i));
 101             if (!sb.toString().equals(expectedWithDefaultLocale.get(i))) {
 102                 throw new RuntimeException(
 103                         "Wrong uppercasing while using Formatter.format(" +
 104                                 "\"" + conversions.get(i) + "\"" +
 105                                 ") with the default locale: '"
 106                                 + defaultLocale.get(i) +
 107                                 "'. Expected: " + expectedWithDefaultLocale.get(i) +
 108                                 " Returned: " + sb.toString());
 109             }













 110         });
 111 
 112         // checks whether upper casing uses the locale set during creation of
 113         // Formatter instance, instead of the default locale
 114         IntStream.range(0, src.size()).forEach(i -> {
 115             sb.setLength(0);
 116             Locale.setDefault(Locale.Category.FORMAT, defaultLocale.get(i));
 117             new Formatter(sb, formatLocale.get(i)).format(conversions.get(i),
 118                     src.get(i));












 119             if (!sb.toString().equals(expectedWithFormatLocale.get(i))) {
 120                 throw new RuntimeException(
 121                         "Wrong uppercasing while using Formatter.format(" +
 122                                 "\"" + conversions.get(i) + "\"" +
 123                                 ") with the locale specified during instance" +
 124                                 " creation: '" + formatLocale.get(i) +
 125                                 "'. Expected: " + expectedWithFormatLocale.get(i) +
 126                                 " Returned: " + sb.toString());
 127             }
 128         });
 129 
 130     }
 131 
 132     static void nullLocaleTest() {
 133         String fmt = "%1$ta %1$tA %1$th %1$tB %1tZ";
 134         String expected = "Fri Friday Jan January PST";
 135         StringBuilder sb = new StringBuilder();
 136         Locale orig = Locale.getDefault();
 137 
 138         try {




  90             "1.00000E+08",
  91             "I");
  92 
  93     static void formatLocaleTest() {
  94         StringBuilder sb = new StringBuilder();
  95 
  96         // checks whether upper casing follows Locale.Category.FORMAT locale
  97         IntStream.range(0, src.size()).forEach(i -> {
  98             sb.setLength(0);
  99             Locale.setDefault(Locale.Category.FORMAT, defaultLocale.get(i));
 100             new Formatter(sb).format(conversions.get(i), src.get(i));
 101             if (!sb.toString().equals(expectedWithDefaultLocale.get(i))) {
 102                 throw new RuntimeException(
 103                         "Wrong uppercasing while using Formatter.format(" +
 104                                 "\"" + conversions.get(i) + "\"" +
 105                                 ") with the default locale: '"
 106                                 + defaultLocale.get(i) +
 107                                 "'. Expected: " + expectedWithDefaultLocale.get(i) +
 108                                 " Returned: " + sb.toString());
 109             }
 110 
 111             sb.setLength(0);
 112             JavacIntrinsicsSupport.formatterFormat(new Formatter(sb), conversions.get(i), src.get(i));
 113             if (!sb.toString().equals(expectedWithDefaultLocale.get(i))) {
 114                 throw new RuntimeException(
 115                         "Wrong uppercasing while using Formatter.format(" +
 116                                 "\"" + conversions.get(i) + "\"" +
 117                                 ") with the default locale: '"
 118                                 + defaultLocale.get(i) +
 119                                 "'. Expected: " + expectedWithDefaultLocale.get(i) +
 120                                 " Returned: " + sb.toString());
 121             }
 122 
 123         });
 124 
 125         // checks whether upper casing uses the locale set during creation of
 126         // Formatter instance, instead of the default locale
 127         IntStream.range(0, src.size()).forEach(i -> {
 128             sb.setLength(0);
 129             Locale.setDefault(Locale.Category.FORMAT, defaultLocale.get(i));
 130             new Formatter(sb, formatLocale.get(i)).format(conversions.get(i),
 131                     src.get(i));
 132             if (!sb.toString().equals(expectedWithFormatLocale.get(i))) {
 133                 throw new RuntimeException(
 134                         "Wrong uppercasing while using Formatter.format(" +
 135                                 "\"" + conversions.get(i) + "\"" +
 136                                 ") with the locale specified during instance" +
 137                                 " creation: '" + formatLocale.get(i) +
 138                                 "'. Expected: " + expectedWithFormatLocale.get(i) +
 139                                 " Returned: " + sb.toString());
 140             }
 141 
 142             sb.setLength(0);
 143             JavacIntrinsicsSupport.formatterFormat(new Formatter(sb, formatLocale.get(i)), conversions.get(i), src.get(i));
 144             if (!sb.toString().equals(expectedWithFormatLocale.get(i))) {
 145                 throw new RuntimeException(
 146                         "Wrong uppercasing while using Formatter.format(" +
 147                                 "\"" + conversions.get(i) + "\"" +
 148                                 ") with the locale specified during instance" +
 149                                 " creation: '" + formatLocale.get(i) +
 150                                 "'. Expected: " + expectedWithFormatLocale.get(i) +
 151                                 " Returned: " + sb.toString());
 152             }
 153         });
 154 
 155     }
 156 
 157     static void nullLocaleTest() {
 158         String fmt = "%1$ta %1$tA %1$th %1$tB %1tZ";
 159         String expected = "Fri Friday Jan January PST";
 160         StringBuilder sb = new StringBuilder();
 161         Locale orig = Locale.getDefault();
 162 
 163         try {


< prev index next >