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