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