1 /*
   2  * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /* Type-specific source code for unit test
  25  *
  26  * Regenerate the BasicX classes via genBasic.sh whenever this file changes.
  27  * We check in the generated source files so that the test tree can be used
  28  * independently of the rest of the source tree.
  29  */
  30 
  31 // -- This file was mechanically generated: Do not edit! -- //
  32 
  33 import java.io.*;
  34 import java.math.BigDecimal;
  35 import java.math.BigInteger;
  36 import java.text.DateFormatSymbols;
  37 import java.util.*;
  38 
  39 import static java.util.Calendar.*;
  40 
  41 
  42 
  43 
  44 
  45 public class BasicDouble extends Basic {
  46 
  47     private static void test(String fs, String exp, Object ... args) {
  48         Formatter f = new Formatter(new StringBuilder(), Locale.US);
  49         f.format(fs, args);
  50         ck(fs, exp, f.toString());
  51 
  52         f = new Formatter(new StringBuilder(), Locale.US);
  53         f.format("foo " + fs + " bar", args);
  54         ck(fs, "foo " + exp + " bar", f.toString());
  55 
  56         JavacIntrinsicsSupport.formatAndCheck(fs, exp, Locale.US, args);
  57         JavacIntrinsicsSupport.formatAndCheck("foo " + fs + " bar", "foo " + exp + " bar", Locale.US, args);
  58     }
  59 
  60     private static void test(Locale l, String fs, String exp, Object ... args)
  61     {
  62         Formatter f = new Formatter(new StringBuilder(), l);
  63         f.format(fs, args);
  64         ck(fs, exp, f.toString());
  65 
  66         f = new Formatter(new StringBuilder(), l);
  67         f.format("foo " + fs + " bar", args);
  68         ck(fs, "foo " + exp + " bar", f.toString());
  69 
  70         JavacIntrinsicsSupport.formatAndCheck(fs, exp, l, args);
  71         JavacIntrinsicsSupport.formatAndCheck("foo " + fs + " bar", "foo " + exp + " bar", l, args);
  72     }
  73 
  74     private static void test(String fs, Object ... args) {
  75         Formatter f = new Formatter(new StringBuilder(), Locale.US);
  76         f.format(fs, args);
  77         ck(fs, "fail", f.toString());
  78     }
  79 
  80     private static void test(String fs) {
  81         Formatter f = new Formatter(new StringBuilder(), Locale.US);
  82         f.format(fs, "fail");
  83         ck(fs, "fail", f.toString());
  84     }
  85 
  86     private static void testSysOut(String fs, String exp, Object ... args) {
  87         FileOutputStream fos = null;
  88         FileInputStream fis = null;
  89         try {
  90             PrintStream saveOut = System.out;
  91             fos = new FileOutputStream("testSysOut");
  92             System.setOut(new PrintStream(fos));
  93             System.out.format(Locale.US, fs, args);
  94             fos.close();
  95 
  96             fis = new FileInputStream("testSysOut");
  97             byte [] ba = new byte[exp.length()];
  98             int len = fis.read(ba);
  99             String got = new String(ba);
 100             if (len != ba.length)
 101                 fail(fs, exp, got);
 102             ck(fs, exp, got);
 103 
 104             System.setOut(saveOut);
 105         } catch (FileNotFoundException ex) {
 106             fail(fs, ex.getClass());
 107         } catch (IOException ex) {
 108             fail(fs, ex.getClass());
 109         } finally {
 110             try {
 111                 if (fos != null)
 112                     fos.close();
 113                 if (fis != null)
 114                     fis.close();
 115             } catch (IOException ex) {
 116                 fail(fs, ex.getClass());
 117             }
 118         }
 119     }
 120 
 121     private static void tryCatch(String fs, Class<?> ex) {
 122         boolean caught = false;
 123         try {
 124             test(fs);
 125         } catch (Throwable x) {
 126             if (ex.isAssignableFrom(x.getClass()))
 127                 caught = true;
 128         }
 129         if (!caught)
 130             fail(fs, ex);
 131         else
 132             pass();
 133 
 134         tryCatchIntrinsic(fs, ex);
 135     }
 136 
 137     private static void tryCatch(String fs, Class<?> ex, Object ... args) {
 138         boolean caught = false;
 139         try {
 140             test(fs, args);
 141         } catch (Throwable x) {
 142             if (ex.isAssignableFrom(x.getClass()))
 143                 caught = true;
 144         }
 145         if (!caught)
 146             fail(fs, ex);
 147         else
 148             pass();
 149 
 150         tryCatchIntrinsic(fs, ex, args);
 151     }
 152 
 153     private static void tryCatchIntrinsic(String fs, Class<?> ex) {
 154         boolean caught = false;
 155         try {
 156             JavacIntrinsicsSupport.formatAndCheck(fs, "fail", Locale.US, "fail");
 157         } catch (Throwable x) {
 158             if (ex.isAssignableFrom(x.getClass()))
 159                 caught = true;
 160         }
 161         if (!caught)
 162             fail(fs, ex);
 163         else
 164             pass();
 165     }
 166 
 167     private static void tryCatchIntrinsic(String fs, Class<?> ex, Object ... args) {
 168         boolean caught = false;
 169         try {
 170             JavacIntrinsicsSupport.formatAndCheck(fs, "fail", Locale.US, args);
 171         } catch (Throwable x) {
 172             if (ex.isAssignableFrom(x.getClass()))
 173                 caught = true;
 174         }
 175         if (!caught)
 176             fail(fs, ex);
 177         else
 178             pass();
 179     }
 180 
 181 
 182 
 183 
 184 
 185 
 186 
 187 
 188 
 189 
 190 
 191 
 192 
 193 
 194 
 195 
 196 
 197 
 198 
 199 
 200 
 201 
 202 
 203 
 204 
 205 
 206 
 207 
 208 
 209 
 210 
 211 
 212 
 213 
 214 
 215 
 216 
 217 
 218 
 219 
 220 
 221 
 222 
 223 
 224 
 225 
 226 
 227 
 228 
 229 
 230 
 231 
 232 
 233 
 234 
 235 
 236 
 237 
 238 
 239 
 240 
 241 
 242 
 243 
 244 
 245 
 246 
 247 
 248 
 249 
 250 
 251 
 252 
 253 
 254 
 255 
 256 
 257 
 258 
 259 
 260 
 261 
 262 
 263 
 264 
 265 
 266 
 267 
 268 
 269 
 270 
 271 
 272 
 273 
 274 
 275 
 276 
 277 
 278 
 279 
 280 
 281 
 282 
 283 
 284 
 285 
 286 
 287 
 288 
 289 
 290 
 291 
 292 
 293 
 294 
 295 
 296 
 297 
 298 
 299 
 300 
 301 
 302 
 303 
 304 
 305 
 306 
 307 
 308 
 309 
 310 
 311 
 312 
 313 
 314 
 315 
 316 
 317 
 318 
 319 
 320 
 321 
 322 
 323 
 324 
 325 
 326 
 327 
 328 
 329 
 330 
 331 
 332 
 333 
 334 
 335 
 336 
 337 
 338 
 339 
 340 
 341     private static double create(double v) {
 342         return (double) v;
 343     }
 344 
 345 
 346     private static double negate(double v) {
 347         return -v;
 348     }
 349 
 350     private static double mult(double v, double mul) {
 351         return v * mul;
 352     }
 353 
 354     private static double recip(double v) {
 355         return 1.0 / v;
 356     }
 357 
 358 
 359 
 360 
 361 
 362 
 363 
 364 
 365 
 366 
 367 
 368 
 369 
 370 
 371 
 372 
 373 
 374 
 375 
 376     public static void test() {
 377         TimeZone.setDefault(TimeZone.getTimeZone("GMT-0800"));
 378 
 379         // Any characters not explicitly defined as conversions, date/time
 380         // conversion suffixes, or flags are illegal and are reserved for
 381         // future extensions.  Use of such a character in a format string will
 382         // cause an UnknownFormatConversionException or
 383         // UnknownFormatFlagsException to be thrown.
 384         tryCatch("%q", UnknownFormatConversionException.class);
 385         tryCatch("%t&", UnknownFormatConversionException.class);
 386         tryCatch("%&d", UnknownFormatConversionException.class);
 387         tryCatch("%^b", UnknownFormatConversionException.class);
 388 
 389         //---------------------------------------------------------------------
 390         // Formatter.java class javadoc examples
 391         //---------------------------------------------------------------------
 392         test(Locale.FRANCE, "e = %+10.4f", "e =    +2,7183", Math.E);
 393         test("%4$2s %3$2s %2$2s %1$2s", " d  c  b  a", "a", "b", "c", "d");
 394         test("Amount gained or lost since last statement: $ %,(.2f",
 395              "Amount gained or lost since last statement: $ (6,217.58)",
 396              (new BigDecimal("-6217.58")));
 397         Calendar c = new GregorianCalendar(1969, JULY, 20, 16, 17, 0);
 398         testSysOut("Local time: %tT", "Local time: 16:17:00", c);
 399 
 400         test("Unable to open file '%1$s': %2$s",
 401              "Unable to open file 'food': No such file or directory",
 402              "food", "No such file or directory");
 403         Calendar duke = new GregorianCalendar(1995, MAY, 23, 19, 48, 34);
 404         duke.set(Calendar.MILLISECOND, 584);
 405         test("Duke's Birthday: %1$tB %1$te, %1$tY",
 406              "Duke's Birthday: May 23, 1995",
 407              duke);
 408         test("Duke's Birthday: %1$tB %1$te, %1$tY",
 409              "Duke's Birthday: May 23, 1995",
 410              duke.getTime());
 411         test("Duke's Birthday: %1$tB %1$te, %1$tY",
 412              "Duke's Birthday: May 23, 1995",
 413              duke.getTimeInMillis());
 414 
 415         test("%4$s %3$s %2$s %1$s %4$s %3$s %2$s %1$s",
 416              "d c b a d c b a", "a", "b", "c", "d");
 417         test("%s %s %<s %<s", "a b b b", "a", "b", "c", "d");
 418         test("%s %s %s %s", "a b c d", "a", "b", "c", "d");
 419         test("%2$s %s %<s %s", "b a a b", "a", "b", "c", "d");
 420 
 421         //---------------------------------------------------------------------
 422         // %b
 423         //
 424         // General conversion applicable to any argument.
 425         //---------------------------------------------------------------------
 426         test("%b", "true", true);
 427         test("%b", "false", false);
 428         test("%B", "TRUE", true);
 429         test("%B", "FALSE", false);
 430         test("%b", "true", Boolean.TRUE);
 431         test("%b", "false", Boolean.FALSE);
 432         test("%B", "TRUE", Boolean.TRUE);
 433         test("%B", "FALSE", Boolean.FALSE);
 434         test("%14b", "          true", true);
 435         test("%-14b", "true          ", true);
 436         test("%5.1b", "    f", false);
 437         test("%-5.1b", "f    ", false);
 438 
 439         test("%b", "true", "foo");
 440         test("%b", "false", (Object)null);
 441 
 442         // Boolean.java hardcodes the Strings for "true" and "false", so no
 443         // localization is possible.
 444         test(Locale.FRANCE, "%b", "true", true);
 445         test(Locale.FRANCE, "%b", "false", false);
 446 
 447         // If you pass in a single array to a varargs method, the compiler
 448         // uses it as the array of arguments rather than treating it as a
 449         // single array-type argument.
 450         test("%b", "false", (Object[])new String[2]);
 451         test("%b", "true", new String[2], new String[2]);
 452 
 453         int [] ia = { 1, 2, 3 };
 454         test("%b", "true", ia);
 455 
 456         //---------------------------------------------------------------------
 457         // %b - errors
 458         //---------------------------------------------------------------------
 459         tryCatch("%#b", FormatFlagsConversionMismatchException.class);
 460         tryCatch("%-b", MissingFormatWidthException.class);
 461         // correct or side-effect of implementation?
 462         tryCatch("%.b", UnknownFormatConversionException.class);
 463         tryCatch("%,b", FormatFlagsConversionMismatchException.class);
 464 
 465         //---------------------------------------------------------------------
 466         // %c
 467         //
 468         // General conversion applicable to any argument.
 469         //---------------------------------------------------------------------
 470         test("%c", "i", 'i');
 471         test("%C", "I", 'i');
 472         test("%4c",  "   i", 'i');
 473         test("%-4c", "i   ", 'i');
 474         test("%4C",  "   I", 'i');
 475         test("%-4C", "I   ", 'i');
 476         test("%c", "i", new Character('i'));
 477         test("%c", "H", (byte) 72);
 478         test("%c", "i", (short) 105);
 479         test("%c", "!", (int) 33);
 480         test("%c", "\u007F", Byte.MAX_VALUE);
 481         test("%c", new String(Character.toChars(Short.MAX_VALUE)),
 482              Short.MAX_VALUE);
 483         test("%c", "null", (Object) null);
 484 
 485         //---------------------------------------------------------------------
 486         // %c - errors
 487         //---------------------------------------------------------------------
 488         tryCatch("%c", IllegalFormatConversionException.class,
 489                  Boolean.TRUE);
 490         tryCatch("%c", IllegalFormatConversionException.class,
 491                  (float) 0.1);
 492         tryCatch("%c", IllegalFormatConversionException.class,
 493                  new Object());
 494         tryCatch("%c", IllegalFormatCodePointException.class,
 495                  Byte.MIN_VALUE);
 496         tryCatch("%c", IllegalFormatCodePointException.class,
 497                  Short.MIN_VALUE);
 498         tryCatch("%c", IllegalFormatCodePointException.class,
 499                  Integer.MIN_VALUE);
 500         tryCatch("%c", IllegalFormatCodePointException.class,
 501                  Integer.MAX_VALUE);
 502 
 503         tryCatch("%#c", FormatFlagsConversionMismatchException.class);
 504         tryCatch("%,c", FormatFlagsConversionMismatchException.class);
 505         tryCatch("%(c", FormatFlagsConversionMismatchException.class);
 506         tryCatch("%$c", UnknownFormatConversionException.class);
 507         tryCatch("%.2c", IllegalFormatPrecisionException.class);
 508 
 509         //---------------------------------------------------------------------
 510         // %s
 511         //
 512         // General conversion applicable to any argument.
 513         //---------------------------------------------------------------------
 514         test("%s", "Hello, Duke", "Hello, Duke");
 515         test("%S", "HELLO, DUKE", "Hello, Duke");
 516         test("%20S", "         HELLO, DUKE", "Hello, Duke");
 517         test("%20s", "         Hello, Duke", "Hello, Duke");
 518         test("%-20s", "Hello, Duke         ", "Hello, Duke");
 519         test("%-20.5s", "Hello               ", "Hello, Duke");
 520         test("%s", "null", (Object)null);
 521 
 522         StringBuffer sb = new StringBuffer("foo bar");
 523         test("%s", sb.toString(), sb);
 524         test("%S", sb.toString().toUpperCase(), sb);
 525 
 526         //---------------------------------------------------------------------
 527         // %s - errors
 528         //---------------------------------------------------------------------
 529         tryCatch("%-s", MissingFormatWidthException.class);
 530         tryCatch("%--s", DuplicateFormatFlagsException.class);
 531         tryCatch("%#s", FormatFlagsConversionMismatchException.class, 0);
 532         tryCatch("%#s", FormatFlagsConversionMismatchException.class, 0.5f);
 533         tryCatch("%#s", FormatFlagsConversionMismatchException.class, "hello");
 534         tryCatch("%#s", FormatFlagsConversionMismatchException.class, null);
 535 
 536         //---------------------------------------------------------------------
 537         // %h
 538         //
 539         // General conversion applicable to any argument.
 540         //---------------------------------------------------------------------
 541         test("%h", Integer.toHexString("Hello, Duke".hashCode()),
 542              "Hello, Duke");
 543         test("%10h", "  ddf63471", "Hello, Duke");
 544         test("%-10h", "ddf63471  ", "Hello, Duke");
 545         test("%-10H", "DDF63471  ", "Hello, Duke");
 546         test("%10h", "  402e0000", 15.0);
 547         test("%10H", "  402E0000", 15.0);
 548 
 549         //---------------------------------------------------------------------
 550         // %h - errors
 551         //---------------------------------------------------------------------
 552         tryCatch("%#h", FormatFlagsConversionMismatchException.class);
 553 
 554         //---------------------------------------------------------------------
 555         // flag/conversion errors
 556         //---------------------------------------------------------------------
 557         tryCatch("%F", UnknownFormatConversionException.class);
 558 
 559         tryCatch("%#g", FormatFlagsConversionMismatchException.class);
 560 
 561 
 562 
 563 
 564 
 565 
 566 
 567 
 568 
 569 
 570 
 571 
 572 
 573 
 574 
 575 
 576 
 577 
 578 
 579 
 580 
 581 
 582 
 583 
 584 
 585 
 586 
 587 
 588 
 589 
 590 
 591 
 592 
 593 
 594 
 595 
 596 
 597 
 598 
 599 
 600 
 601 
 602 
 603 
 604 
 605 
 606 
 607 
 608 
 609 
 610 
 611 
 612 
 613 
 614 
 615 
 616 
 617 
 618 
 619 
 620 
 621 
 622 
 623 
 624 
 625 
 626 
 627 
 628 
 629 
 630 
 631 
 632 
 633 
 634 
 635 
 636 
 637 
 638 
 639 
 640 
 641 
 642 
 643 
 644 
 645 
 646 
 647 
 648 
 649 
 650 
 651 
 652 
 653 
 654 
 655 
 656 
 657 
 658 
 659 
 660 
 661 
 662 
 663 
 664 
 665 
 666 
 667 
 668 
 669 
 670 
 671 
 672 
 673 
 674 
 675 
 676 
 677 
 678 
 679 
 680 
 681 
 682 
 683 
 684 
 685 
 686 
 687 
 688 
 689 
 690 
 691 
 692 
 693 
 694 
 695 
 696 
 697 
 698 
 699 
 700 
 701 
 702 
 703 
 704 
 705 
 706 
 707 
 708 
 709 
 710 
 711 
 712 
 713 
 714 
 715 
 716 
 717 
 718 
 719 
 720 
 721 
 722 
 723 
 724 
 725 
 726 
 727 
 728 
 729 
 730 
 731 
 732 
 733 
 734 
 735 
 736 
 737 
 738 
 739 
 740 
 741 
 742 
 743 
 744 
 745 
 746 
 747 
 748 
 749 
 750 
 751 
 752 
 753 
 754 
 755 
 756 
 757 
 758 
 759 
 760 
 761 
 762 
 763 
 764 
 765 
 766 
 767 
 768 
 769 
 770 
 771 
 772 
 773 
 774 
 775 
 776 
 777 
 778 
 779 
 780 
 781 
 782 
 783 
 784 
 785 
 786 
 787 
 788 
 789 
 790 
 791 
 792 
 793 
 794 
 795 
 796 
 797 
 798 
 799 
 800 
 801 
 802 
 803 
 804 
 805 
 806 
 807 
 808 
 809 
 810 
 811 
 812 
 813 
 814 
 815 
 816 
 817 
 818 
 819 
 820 
 821 
 822 
 823 
 824 
 825 
 826 
 827 
 828 
 829 
 830 
 831 
 832 
 833 
 834 
 835 
 836 
 837 
 838 
 839 
 840 
 841 
 842 
 843 
 844 
 845 
 846 
 847 
 848 
 849 
 850 
 851 
 852 
 853 
 854 
 855 
 856 
 857 
 858 
 859 
 860 
 861 
 862 
 863 
 864 
 865 
 866 
 867 
 868 
 869 
 870 
 871 
 872 
 873 
 874 
 875 
 876 
 877 
 878 
 879 
 880 
 881 
 882 
 883 
 884 
 885 
 886 
 887 
 888 
 889 
 890 
 891 
 892 
 893 
 894 
 895 
 896 
 897 
 898 
 899 
 900 
 901 
 902 
 903 
 904 
 905 
 906 
 907 
 908 
 909 
 910 
 911 
 912 
 913 
 914 
 915 
 916 
 917 
 918 
 919 
 920 
 921 
 922 
 923 
 924 
 925 
 926 
 927 
 928 
 929 
 930 
 931 
 932 
 933 
 934         //---------------------------------------------------------------------
 935         // %s - double
 936         //---------------------------------------------------------------------
 937         double one = 1.0;
 938         double ten = 10.0;
 939         double pi  = Math.PI;
 940 
 941         test("%s", "3.141592653589793", pi);
 942 
 943 
 944 
 945 
 946 
 947 
 948 
 949 
 950 
 951 
 952 
 953 
 954         //---------------------------------------------------------------------
 955         // flag/conversion errors
 956         //---------------------------------------------------------------------
 957         tryCatch("%d", IllegalFormatConversionException.class, one);
 958         tryCatch("%,.4e", FormatFlagsConversionMismatchException.class, one);
 959 
 960         //---------------------------------------------------------------------
 961         // %e
 962         //
 963         // Floating-point conversions applicable to float, double, and
 964         // BigDecimal.
 965         //---------------------------------------------------------------------
 966         test("%e", "null", (Object)null);
 967 
 968         //---------------------------------------------------------------------
 969         // %e - float and double
 970         //---------------------------------------------------------------------
 971         // double PI = 3.141 592 653 589 793 238 46;
 972         test("%e", "3.141593e+00", pi);
 973         test("%.0e", "1e+01", ten);
 974         test("%#.0e", "1.e+01", ten);
 975         test("%E", "3.141593E+00", pi);
 976         test("%10.3e", " 3.142e+00", pi);
 977         test("%10.3e", "-3.142e+00", negate(pi));
 978         test("%010.3e", "03.142e+00", pi);
 979         test("%010.3e", "-3.142e+00", negate(pi));
 980         test("%-12.3e", "3.142e+00   ", pi);
 981         test("%-12.3e", "-3.142e+00  ", negate(pi));
 982         test("%.3e", "3.142e+00", pi);
 983         test("%.3e", "-3.142e+00", negate(pi));
 984         test("%.3e", "3.142e+06", mult(pi, 1000000.0));
 985         test("%.3e", "-3.142e+06", mult(pi, -1000000.0));
 986 
 987         test(Locale.FRANCE, "%e", "3,141593e+00", pi);
 988 
 989         // double PI^300
 990         //    = 13962455701329742638131355433930076081862072808 ... e+149
 991 
 992 
 993 
 994 
 995 
 996 
 997 
 998 
 999 
1000 
1001 
1002 
1003 
1004 
1005 
1006 
1007 
1008 
1009 
1010 
1011 
1012 
1013 
1014 
1015 
1016 
1017 
1018 
1019 
1020 
1021 
1022         test("%10.3e", " 1.000e+00", one);
1023         test("%+.3e", "+3.142e+00", pi);
1024         test("%+.3e", "-3.142e+00", negate(pi));
1025         test("% .3e", " 3.142e+00", pi);
1026         test("% .3e", "-3.142e+00", negate(pi));
1027         test("%#.0e", "3.e+00", create(3.0));
1028         test("%#.0e", "-3.e+00", create(-3.0));
1029         test("%.0e", "3e+00", create(3.0));
1030         test("%.0e", "-3e+00", create(-3.0));
1031 
1032         test("%(.4e", "3.1416e+06", mult(pi, 1000000.0));
1033         test("%(.4e", "(3.1416e+06)", mult(pi, -1000000.0));
1034 
1035         //---------------------------------------------------------------------
1036         // %e - boundary problems
1037         //---------------------------------------------------------------------
1038         test("%3.0e", "1e-06", 0.000001);
1039         test("%3.0e", "1e-05", 0.00001);
1040         test("%3.0e", "1e-04", 0.0001);
1041         test("%3.0e", "1e-03", 0.001);
1042         test("%3.0e", "1e-02", 0.01);
1043         test("%3.0e", "1e-01", 0.1);
1044         test("%3.0e", "9e-01", 0.9);
1045         test("%3.1e", "9.0e-01", 0.9);
1046         test("%3.0e", "1e+00", 1.00);
1047         test("%3.0e", "1e+01", 10.00);
1048         test("%3.0e", "1e+02", 99.19);
1049         test("%3.1e", "9.9e+01", 99.19);
1050         test("%3.0e", "1e+02", 99.99);
1051         test("%3.0e", "1e+02", 100.00);
1052         test("%#3.0e", "1.e+03",     1000.00);
1053         test("%3.0e", "1e+04",     10000.00);
1054         test("%3.0e", "1e+05",    100000.00);
1055         test("%3.0e", "1e+06",   1000000.00);
1056         test("%3.0e", "1e+07",  10000000.00);
1057         test("%3.0e", "1e+08", 100000000.00);
1058 
1059         //---------------------------------------------------------------------
1060         // %f
1061         //
1062         // Floating-point conversions applicable to float, double, and
1063         // BigDecimal.
1064         //---------------------------------------------------------------------
1065         test("%f", "null", (Object)null);
1066         test("%f", "3.141593", pi);
1067         test(Locale.FRANCE, "%f", "3,141593", pi);
1068         test("%10.3f", "     3.142", pi);
1069         test("%10.3f", "    -3.142", negate(pi));
1070         test("%010.3f", "000003.142", pi);
1071         test("%010.3f", "-00003.142", negate(pi));
1072         test("%-10.3f", "3.142     ", pi);
1073         test("%-10.3f", "-3.142    ", negate(pi));
1074         test("%.3f", "3.142", pi);
1075         test("%.3f", "-3.142", negate(pi));
1076         test("%+.3f", "+3.142", pi);
1077         test("%+.3f", "-3.142", negate(pi));
1078         test("% .3f", " 3.142", pi);
1079         test("% .3f", "-3.142", negate(pi));
1080         test("%#.0f", "3.", create(3.0));
1081         test("%#.0f", "-3.", create(-3.0));
1082         test("%.0f", "3", create(3.0));
1083         test("%.0f", "-3", create(-3.0));
1084         test("%.3f", "10.000", ten);
1085         test("%.3f", "1.000", one);
1086         test("%10.3f", "     1.000", one);
1087 
1088         //---------------------------------------------------------------------
1089         // %f - boundary problems
1090         //---------------------------------------------------------------------
1091         test("%3.0f", "  0", 0.000001);
1092         test("%3.0f", "  0", 0.00001);
1093         test("%3.0f", "  0", 0.0001);
1094         test("%3.0f", "  0", 0.001);
1095         test("%3.0f", "  0", 0.01);
1096         test("%3.0f", "  0", 0.1);
1097         test("%3.0f", "  1", 0.9);
1098         test("%3.1f", "0.9", 0.9);
1099         test("%3.0f", "  1", 1.00);
1100         test("%3.0f", " 10", 10.00);
1101         test("%3.0f", " 99", 99.19);
1102         test("%3.1f", "99.2", 99.19);
1103         test("%3.0f", "100", 99.99);
1104         test("%3.0f", "100", 100.00);
1105         test("%#3.0f", "1000.",     1000.00);
1106         test("%3.0f", "10000",     10000.00);
1107         test("%3.0f", "100000",    100000.00);
1108         test("%3.0f", "1000000",   1000000.00);
1109         test("%3.0f", "10000000",  10000000.00);
1110         test("%3.0f", "100000000", 100000000.00);
1111         test("%10.0f", "   1000000",   1000000.00);
1112         test("%,10.0f", " 1,000,000",   1000000.00);
1113         test("%,10.1f", "1,000,000.0",   1000000.00);
1114         test("%,3.0f", "1,000,000",   1000000.00);
1115         test("%,3.0f", "10,000,000",  10000000.00);
1116         test("%,3.0f", "100,000,000", 100000000.00);
1117         test("%,3.0f", "10,000,000",  10000000.00);
1118         test("%,3.0f", "100,000,000", 100000000.00);
1119 
1120 
1121 
1122 
1123 
1124 
1125 
1126 
1127 
1128 
1129 
1130 
1131 
1132 
1133 
1134 
1135 
1136 
1137 
1138 
1139 
1140 
1141 
1142 
1143 
1144 
1145 
1146 
1147 
1148 
1149 
1150 
1151 
1152 
1153 
1154 
1155 
1156 
1157 
1158 
1159 
1160 
1161 
1162 
1163 
1164 
1165 
1166 
1167 
1168 
1169 
1170 
1171 
1172 
1173 
1174 
1175 
1176 
1177 
1178 
1179 
1180 
1181 
1182 
1183 
1184 
1185 
1186 
1187 
1188 
1189 
1190 
1191 
1192 
1193 
1194 
1195 
1196 
1197 
1198 
1199 
1200 
1201 
1202 
1203 
1204 
1205 
1206 
1207 
1208 
1209 
1210 
1211 
1212 
1213 
1214 
1215 
1216         //---------------------------------------------------------------------
1217         // %f - float, double, Double, BigDecimal
1218         //---------------------------------------------------------------------
1219         test("%.3f", "3141592.654", mult(pi, 1000000.0));
1220         test("%.3f", "-3141592.654", mult(pi, -1000000.0));
1221         test("%,.4f", "3,141,592.6536", mult(pi, 1000000.0));
1222         test(Locale.FRANCE, "%,.4f", "3\u00a0141\u00a0592,6536", mult(pi, 1000000.0));
1223         test("%,.4f", "-3,141,592.6536", mult(pi, -1000000.0));
1224         test("%(.4f", "3141592.6536", mult(pi, 1000000.0));
1225         test("%(.4f", "(3141592.6536)", mult(pi, -1000000.0));
1226         test("%(,.4f", "3,141,592.6536", mult(pi, 1000000.0));
1227         test("%(,.4f", "(3,141,592.6536)", mult(pi, -1000000.0));
1228 
1229 
1230 
1231 
1232         //---------------------------------------------------------------------
1233         // %g
1234         //
1235         // Floating-point conversions applicable to float, double, and
1236         // BigDecimal.
1237         //---------------------------------------------------------------------
1238         test("%g", "null", (Object)null);
1239         test("%g", "3.14159", pi);
1240         test(Locale.FRANCE, "%g", "3,14159", pi);
1241         test("%.0g", "1e+01", ten);
1242         test("%G", "3.14159", pi);
1243         test("%10.3g", "      3.14", pi);
1244         test("%10.3g", "     -3.14", negate(pi));
1245         test("%010.3g", "0000003.14", pi);
1246         test("%010.3g", "-000003.14", negate(pi));
1247         test("%-12.3g", "3.14        ", pi);
1248         test("%-12.3g", "-3.14       ", negate(pi));
1249         test("%.3g", "3.14", pi);
1250         test("%.3g", "-3.14", negate(pi));
1251         test("%.3g", "3.14e+08", mult(pi, 100000000.0));
1252         test("%.3g", "-3.14e+08", mult(pi, -100000000.0));
1253 
1254         test("%.3g", "1.00e-05", recip(create(100000.0)));
1255         test("%.3g", "-1.00e-05", recip(create(-100000.0)));
1256         test("%.0g", "-1e-05", recip(create(-100000.0)));
1257         test("%.0g", "1e+05", create(100000.0));
1258         test("%.3G", "1.00E-05", recip(create(100000.0)));
1259         test("%.3G", "-1.00E-05", recip(create(-100000.0)));
1260 
1261         test("%.1g", "-0", -0.0);
1262         test("%3.0g", " -0", -0.0);
1263         test("%.1g", "0", 0.0);
1264         test("%3.0g", "  0", 0.0);
1265         test("%.1g", "0", +0.0);
1266         test("%3.0g", "  0", +0.0);
1267 
1268         test("%3.0g", "1e-06", 0.000001);
1269         test("%3.0g", "1e-05", 0.00001);
1270         test("%3.0g", "1e-05", 0.0000099);
1271         test("%3.1g", "1e-05", 0.0000099);
1272         test("%3.2g", "9.9e-06", 0.0000099);
1273         test("%3.0g", "0.0001", 0.0001);
1274         test("%3.0g", "9e-05",  0.00009);
1275         test("%3.0g", "0.0001", 0.000099);
1276         test("%3.1g", "0.0001", 0.000099);
1277         test("%3.2g", "9.9e-05", 0.000099);
1278         test("%3.0g", "0.001", 0.001);
1279         test("%3.0g", "0.001", 0.00099);
1280         test("%3.1g", "0.001", 0.00099);
1281         test("%3.2g", "0.00099", 0.00099);
1282         test("%3.3g", "0.00100", 0.001);
1283         test("%3.4g", "0.001000", 0.001);
1284         test("%3.0g", "0.01", 0.01);
1285         test("%3.0g", "0.1", 0.1);
1286         test("%3.0g", "0.9", 0.9);
1287         test("%3.1g", "0.9", 0.9);
1288         test("%3.0g", "  1", 1.00);
1289         test("%3.2g", " 10", 10.00);
1290         test("%3.0g", "1e+01", 10.00);
1291         test("%3.0g", "1e+02", 99.19);
1292         test("%3.1g", "1e+02", 99.19);
1293         test("%3.2g", " 99", 99.19);
1294         test("%3.0g", "1e+02", 99.9);
1295         test("%3.1g", "1e+02", 99.9);
1296         test("%3.2g", "1.0e+02", 99.9);
1297         test("%3.0g", "1e+02", 99.99);
1298         test("%3.0g", "1e+02", 100.00);
1299         test("%3.0g", "1e+03", 999.9);
1300         test("%3.1g", "1e+03", 999.9);
1301         test("%3.2g", "1.0e+03", 999.9);
1302         test("%3.3g", "1.00e+03", 999.9);
1303         test("%3.4g", "999.9", 999.9);
1304         test("%3.4g", "1000", 999.99);
1305         test("%3.0g", "1e+03", 1000.00);
1306         test("%3.0g", "1e+04",     10000.00);
1307         test("%3.0g", "1e+05",    100000.00);
1308         test("%3.0g", "1e+06",   1000000.00);
1309         test("%3.0g", "1e+07",  10000000.00);
1310         test("%3.9g", "100000000",  100000000.00);
1311         test("%3.10g", "100000000.0", 100000000.00);
1312 
1313         tryCatch("%#3.0g", FormatFlagsConversionMismatchException.class, 1000.00);
1314 
1315         // double PI^300
1316         //    = 13962455701329742638131355433930076081862072808 ... e+149
1317 
1318 
1319 
1320 
1321 
1322 
1323 
1324 
1325 
1326 
1327 
1328 
1329 
1330 
1331 
1332 
1333 
1334 
1335 
1336 
1337 
1338 
1339 
1340 
1341 
1342 
1343 
1344 
1345 
1346 
1347 
1348 
1349 
1350 
1351 
1352 
1353 
1354         test("%.3g", "10.0", ten);
1355         test("%.3g", "1.00", one);
1356         test("%10.3g", "      1.00", one);
1357         test("%+10.3g", "     +3.14", pi);
1358         test("%+10.3g", "     -3.14", negate(pi));
1359         test("% .3g", " 3.14", pi);
1360         test("% .3g", "-3.14", negate(pi));
1361         test("%.0g", "3", create(3.0));
1362         test("%.0g", "-3", create(-3.0));
1363 
1364         test("%(.4g", "3.142e+08", mult(pi, 100000000.0));
1365         test("%(.4g", "(3.142e+08)", mult(pi, -100000000.0));
1366 
1367 
1368 
1369 
1370 
1371 
1372 
1373         test("%,.11g", "3,141,592.6536", mult(pi, 1000000.0));
1374         test("%(,.11g", "(3,141,592.6536)", mult(pi, -1000000.0));
1375 
1376 
1377 
1378 
1379         //---------------------------------------------------------------------
1380         // %a
1381         //
1382         // Floating-point conversions applicable to float, double, and
1383         // BigDecimal.
1384         //---------------------------------------------------------------------
1385         test("%a", "null", (Object)null);
1386         test("%.11a", "0x0.00000000000p0", 0.0);
1387         test(Locale.FRANCE, "%.11a", "0x0.00000000000p0", 0.0); // no localization
1388         test("%.1a", "0x0.0p0", 0.0);
1389         test("%.11a", "-0x0.00000000000p0", -0.0);
1390         test("%.1a", "-0x0.0p0", -0.0);
1391         test("%.11a", "0x1.00000000000p0", 1.0);
1392         test("%.1a", "0x1.0p0", 1.0);
1393         test("%.11a", "-0x1.00000000000p0", -1.0);
1394         test("%.1a", "-0x1.0p0", -1.0);
1395         test("%.11a", "0x1.80000000000p1", 3.0);
1396         test("%.1a", "0x1.8p1", 3.0);
1397         test("%.11a", "0x1.00000000000p-1022", Double.MIN_NORMAL);
1398         test("%.1a", "0x1.0p-1022", Double.MIN_NORMAL);
1399         test("%.11a", "0x1.00000000000p-1022",
1400              Math.nextDown(Double.MIN_NORMAL));
1401         test("%.1a", "0x1.0p-1022",
1402              Math.nextDown(Double.MIN_NORMAL));
1403         test("%.11a", "0x1.ffffffffffep-1023", 0x0.fffffffffffp-1022);
1404         test("%.1a", "0x1.0p-1022", 0x0.fffffffffffp-1022);
1405         test("%.30a", "0x0.000000000000100000000000000000p-1022", Double.MIN_VALUE);
1406         test("%.13a", "0x0.0000000000001p-1022", Double.MIN_VALUE);
1407         test("%.11a", "0x1.00000000000p-1074", Double.MIN_VALUE);
1408         test("%.1a", "0x1.0p-1074", Double.MIN_VALUE);
1409 
1410         test("%.11a", "0x1.08000000000p-1069",
1411              Double.MIN_VALUE + Double.MIN_VALUE*32);
1412         test("%.1a", "0x1.0p-1069",
1413              Double.MIN_VALUE + Double.MIN_VALUE*32);
1414         test("%.30a", "0x1.fffffffffffff00000000000000000p1023", Double.MAX_VALUE);
1415         test("%.13a", "0x1.fffffffffffffp1023", Double.MAX_VALUE);
1416         test("%.11a", "0x1.00000000000p1024", Double.MAX_VALUE);
1417         test("%.1a", "0x1.0p1024", Double.MAX_VALUE);
1418         test("%.11a", "0x1.18000000000p0", 0x1.18p0);
1419         test("%.1a", "0x1.2p0", 0x1.18p0);
1420 
1421         test("%.11a", "0x1.18000000000p0", 0x1.180000000001p0);
1422         test("%.1a", "0x1.2p0", 0x1.180000000001p0);
1423         test("%.11a", "0x1.28000000000p0", 0x1.28p0);
1424         test("%.1a", "0x1.2p0", 0x1.28p0);
1425 
1426         test("%.11a", "0x1.28000000000p0", 0x1.280000000001p0);
1427         test("%.1a", "0x1.3p0", 0x1.280000000001p0);
1428 
1429         test("%a", "0x0.123p-1022", 0x0.123p-1022);
1430         test("%1.3a", "0x1.230p-1026", 0x0.123p-1022);
1431         test("%1.12a", "0x1.230000000000p-1026", 0x0.123p-1022);
1432         test("%1.15a", "0x0.123000000000000p-1022", 0x0.123p-1022);
1433         test("%1.5a", "0x1.00000p-1074", 0x0.0000000000001p-1022);
1434         test("%1.7a", "0x1.0000000p-1022", 0x0.fffffffffffffp-1022);
1435 
1436         test("%1.6a", "0x1.230000p-1026", 0x0.123000057p-1022);
1437         test("%1.7a", "0x1.2300005p-1026", 0x0.123000057p-1022);
1438         test("%1.8a", "0x1.23000057p-1026", 0x0.123000057p-1022);
1439         test("%1.9a", "0x1.230000570p-1026", 0x0.123000057p-1022);
1440 
1441         test("%1.6a", "0x1.230000p-1026", 0x0.123000058p-1022);
1442         test("%1.7a", "0x1.2300006p-1026", 0x0.123000058p-1022);
1443         test("%1.8a", "0x1.23000058p-1026", 0x0.123000058p-1022);
1444         test("%1.9a", "0x1.230000580p-1026", 0x0.123000058p-1022);
1445 
1446         test("%1.6a", "0x1.230000p-1026", 0x0.123000059p-1022);
1447         test("%1.7a", "0x1.2300006p-1026", 0x0.123000059p-1022);
1448         test("%1.8a", "0x1.23000059p-1026", 0x0.123000059p-1022);
1449         test("%1.9a", "0x1.230000590p-1026", 0x0.123000059p-1022);
1450 
1451         test("%1.4a", "0x1.0000p-1022", Math.nextDown(Double.MIN_NORMAL));
1452 
1453         test("%a", "0x1.fffffffffffffp1023", Double.MAX_VALUE);
1454         test("%1.1a", "0x1.0p1024", Double.MAX_VALUE);
1455         test("%1.2a", "0x1.00p1024", Double.MAX_VALUE);
1456         test("%1.6a", "0x1.000000p1024", Double.MAX_VALUE);
1457         test("%1.9a", "0x1.000000000p1024", Double.MAX_VALUE);
1458         test("%1.11a", "0x1.00000000000p1024", Double.MAX_VALUE);
1459         test("%1.12a", "0x1.000000000000p1024", Double.MAX_VALUE);
1460         test("%1.13a", "0x1.fffffffffffffp1023", Double.MAX_VALUE);
1461 
1462 
1463 
1464         //---------------------------------------------------------------------
1465         // %f, %e, %g, %a - Boundaries
1466         //---------------------------------------------------------------------
1467 
1468 
1469 
1470 
1471 
1472 
1473 
1474 
1475 
1476 
1477 
1478 
1479 
1480 
1481 
1482 
1483 
1484 
1485 
1486 
1487 
1488 
1489 
1490 
1491 
1492 
1493 
1494 
1495 
1496 
1497 
1498 
1499 
1500 
1501 
1502 
1503 
1504 
1505 
1506 
1507 
1508 
1509 
1510 
1511 
1512 
1513 
1514 
1515 
1516 
1517 
1518 
1519 
1520 
1521 
1522 
1523 
1524 
1525 
1526 
1527 
1528 
1529 
1530 
1531 
1532 
1533 
1534 
1535 
1536 
1537 
1538 
1539 
1540 
1541 
1542 
1543 
1544 
1545 
1546 
1547 
1548 
1549 
1550 
1551 
1552 
1553 
1554 
1555 
1556 
1557 
1558 
1559 
1560 
1561 
1562 
1563 
1564 
1565 
1566 
1567 
1568 
1569 
1570 
1571 
1572 
1573 
1574 
1575 
1576 
1577 
1578 
1579 
1580 
1581 
1582 
1583 
1584 
1585 
1586 
1587 
1588 
1589 
1590 
1591 
1592 
1593 
1594 
1595 
1596 
1597 
1598 
1599 
1600 
1601 
1602 
1603 
1604 
1605 
1606 
1607 
1608 
1609 
1610 
1611 
1612 
1613 
1614 
1615 
1616 
1617 
1618 
1619 
1620 
1621 
1622 
1623 
1624 
1625 
1626 
1627 
1628 
1629 
1630 
1631 
1632 
1633 
1634 
1635 
1636         //---------------------------------------------------------------------
1637         // %f, %e, %g, %a - Double.MIN_VALUE
1638         //---------------------------------------------------------------------
1639         test("%f", "0.000000", Double.MIN_VALUE);
1640         test("%,f", "0.000000", Double.MIN_VALUE);
1641         test("%(f", "(0.000000)", -Double.MIN_VALUE);
1642         test("%30.0f",  "                             0", Double.MIN_VALUE);
1643         test("%30.5f",  "                       0.00000", Double.MIN_VALUE);
1644         test("%30.13f", "               0.0000000000000", Double.MIN_VALUE);
1645         test("%30.20f", "        0.00000000000000000000", Double.MIN_VALUE);
1646         test("%30.350f","0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000490000000000000000000000000",
1647              Double.MIN_VALUE);
1648         test("%e", "4.900000e-324", Double.MIN_VALUE);
1649         test("%E", "4.900000E-324", Double.MIN_VALUE);
1650         test("%(.1e", "4.9e-324", Double.MIN_VALUE);
1651         test("%(E", "(4.900000E-324)", -Double.MIN_VALUE);
1652         test("%30.5e",  "                  4.90000e-324", Double.MIN_VALUE);
1653         test("%30.13e", "          4.9000000000000e-324", Double.MIN_VALUE);
1654         test("%30.20e", "   4.90000000000000000000e-324", Double.MIN_VALUE);
1655         test("%g", "4.90000e-324", Double.MIN_VALUE);
1656         test("%G", "4.90000E-324", Double.MIN_VALUE);
1657         test("%(g", "4.90000e-324", Double.MIN_VALUE);
1658         test("%,g", "4.90000e-324", Double.MIN_VALUE);
1659         test("%30.5g",  "                   4.9000e-324", Double.MIN_VALUE);
1660         test("%30.13g", "           4.900000000000e-324", Double.MIN_VALUE);
1661         test("%30.20g", "    4.9000000000000000000e-324", Double.MIN_VALUE);
1662         test("%a", "0x0.0000000000001p-1022", Double.MIN_VALUE);
1663         test("%A", "0X0.0000000000001P-1022", Double.MIN_VALUE);
1664         test("%30a",    "       0x0.0000000000001p-1022", Double.MIN_VALUE);
1665 
1666         //---------------------------------------------------------------------
1667         // %f, %e, %g, %a - Double.MAX_VALUE
1668         //---------------------------------------------------------------------
1669         test("%f", "179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.000000",
1670              Double.MAX_VALUE);
1671         test("%,f", "179,769,313,486,231,570,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000.000000",
1672              Double.MAX_VALUE);
1673         test("%,(f", "(179,769,313,486,231,570,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000.000000)",
1674              -Double.MAX_VALUE);
1675         test("%,30.5f", "179,769,313,486,231,570,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000.00000",
1676              Double.MAX_VALUE);
1677         test("%30.13f", "179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.0000000000000",
1678              Double.MAX_VALUE);
1679         test("%30.20f", "179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00000000000000000000",
1680              Double.MAX_VALUE);
1681         test("%e", "1.797693e+308", Double.MAX_VALUE);
1682         test("%E", "1.797693E+308", Double.MAX_VALUE);
1683         test("%(e", "1.797693e+308", Double.MAX_VALUE);
1684         test("%(e", "(1.797693e+308)", -Double.MAX_VALUE);
1685         test("%30.5e",  "                  1.79769e+308", Double.MAX_VALUE);
1686         test("%30.13e", "          1.7976931348623e+308", Double.MAX_VALUE);
1687         test("%30.20e", "   1.79769313486231570000e+308", Double.MAX_VALUE);
1688         test("%g", "1.79769e+308", Double.MAX_VALUE);
1689         test("%G", "1.79769E+308", Double.MAX_VALUE);
1690         test("%,g", "1.79769e+308", Double.MAX_VALUE);
1691         test("%(g", "(1.79769e+308)", -Double.MAX_VALUE);
1692         test("%30.5g",  "                   1.7977e+308", Double.MAX_VALUE);
1693         test("%30.13g", "           1.797693134862e+308", Double.MAX_VALUE);
1694         test("%30.20g", "    1.7976931348623157000e+308", Double.MAX_VALUE);
1695         test("%a", "0x1.fffffffffffffp1023", Double.MAX_VALUE);
1696         test("%A", "0X1.FFFFFFFFFFFFFP1023", Double.MAX_VALUE);
1697         test("%30a",    "        0x1.fffffffffffffp1023", Double.MAX_VALUE);
1698 
1699 
1700 
1701 
1702         //---------------------------------------------------------------------
1703         // %t
1704         //
1705         // Date/Time conversions applicable to Calendar, Date, and long.
1706         //---------------------------------------------------------------------
1707         test("%tA", "null", (Object)null);
1708         test("%TA", "NULL", (Object)null);
1709 
1710         //---------------------------------------------------------------------
1711         // %t - errors
1712         //---------------------------------------------------------------------
1713         tryCatch("%t", UnknownFormatConversionException.class);
1714         tryCatch("%T", UnknownFormatConversionException.class);
1715         tryCatch("%tP", UnknownFormatConversionException.class);
1716         tryCatch("%TP", UnknownFormatConversionException.class);
1717         tryCatch("%.5tB", IllegalFormatPrecisionException.class);
1718         tryCatch("%#tB", FormatFlagsConversionMismatchException.class);
1719         tryCatch("%-tB", MissingFormatWidthException.class);
1720 
1721 
1722 
1723 
1724 
1725 
1726 
1727 
1728 
1729 
1730 
1731 
1732 
1733 
1734 
1735 
1736 
1737 
1738 
1739 
1740 
1741 
1742 
1743 
1744 
1745 
1746 
1747 
1748 
1749 
1750 
1751 
1752 
1753 
1754 
1755 
1756 
1757 
1758 
1759 
1760 
1761 
1762 
1763 
1764 
1765 
1766 
1767 
1768 
1769 
1770 
1771 
1772 
1773 
1774 
1775 
1776 
1777 
1778 
1779 
1780 
1781 
1782 
1783 
1784 
1785 
1786 
1787 
1788 
1789 
1790 
1791 
1792 
1793 
1794 
1795 
1796 
1797 
1798 
1799 
1800 
1801 
1802 
1803 
1804 
1805 
1806 
1807 
1808 
1809 
1810 
1811 
1812 
1813 
1814 
1815         //---------------------------------------------------------------------
1816         // %n
1817         //---------------------------------------------------------------------
1818         test("%n", System.getProperty("line.separator"), (Object)null);
1819         test("%n", System.getProperty("line.separator"), "");
1820 
1821         tryCatch("%,n", IllegalFormatFlagsException.class);
1822         tryCatch("%.n", UnknownFormatConversionException.class);
1823         tryCatch("%5.n", UnknownFormatConversionException.class);
1824         tryCatch("%5n", IllegalFormatWidthException.class);
1825         tryCatch("%.7n", IllegalFormatPrecisionException.class);
1826         tryCatch("%<n", IllegalFormatFlagsException.class);
1827 
1828         //---------------------------------------------------------------------
1829         // %%
1830         //---------------------------------------------------------------------
1831         test("%%", "%", (Object)null);
1832         test("%%", "%", "");
1833 
1834         test("%5%", "    %", (Object)null);
1835         test("%5%", "    %", "");
1836         test("%-5%", "%    ", (Object)null);
1837         test("%-5%", "%    ", "");
1838 
1839         tryCatch("%.5%", IllegalFormatPrecisionException.class);
1840         tryCatch("%5.5%", IllegalFormatPrecisionException.class);
1841 
1842         tryCatch("%%%", UnknownFormatConversionException.class);
1843         // perhaps an IllegalFormatArgumentIndexException should be defined?
1844         tryCatch("%<%", IllegalFormatFlagsException.class);
1845     }
1846 }