jdk/test/java/text/Format/NumberFormat/NumberRegression.java
author okutsu
Fri, 27 May 2016 14:33:48 +0900
changeset 38581 e761c1ccd13e
child 40455 db40a6f6f274
permissions -rw-r--r--
8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository. Reviewed-by: alanb, peytoia, naoto
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
38581
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
     1
/*
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
     2
 * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
     4
 *
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
     7
 * published by the Free Software Foundation.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
     8
 *
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    13
 * accompanied this code).
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    14
 *
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    18
 *
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    21
 * questions.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    22
 */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    23
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    24
/**
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    25
 * @test
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    26
 * @bug 4052223 4059870 4061302 4062486 4066646 4068693 4070798 4071005 4071014
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    27
 * 4071492 4071859 4074454 4074620 4075713 4083018 4086575 4087244 4087245
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    28
 * 4087251 4087535 4088161 4088503 4090489 4090504 4092480 4092561 4095713
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    29
 * 4098741 4099404 4101481 4106658 4106662 4106664 4108738 4110936 4122840
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    30
 * 4125885 4134034 4134300 4140009 4141750 4145457 4147295 4147706 4162198
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    31
 * 4162852 4167494 4170798 4176114 4179818 4185761 4212072 4212073 4216742
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    32
 * 4217661 4243011 4243108 4330377 4233840 4241880 4833877 8008577
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    33
 * @summary Regression tests for NumberFormat and associated classes
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    34
 * @library /java/text/testlib
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    35
 * @build IntlTest HexDumpReader
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    36
 * @modules java.base/sun.util.resources
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    37
 * @compile -XDignore.symbol.file NumberRegression.java
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    38
 * @run main/othervm -Djava.locale.providers=COMPAT,SPI NumberRegression
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    39
 */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    40
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    41
/*
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    42
(C) Copyright Taligent, Inc. 1996 - All Rights Reserved
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    43
(C) Copyright IBM Corp. 1996 - All Rights Reserved
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    44
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    45
  The original version of this source code and documentation is copyrighted and
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    46
owned by Taligent, Inc., a wholly-owned subsidiary of IBM. These materials are
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    47
provided under terms of a License Agreement between Taligent and Sun. This
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    48
technology is protected by multiple US and International patents. This notice and
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    49
attribution to Taligent may not be removed.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    50
  Taligent is a registered trademark of Taligent, Inc.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    51
*/
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    52
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    53
import java.text.*;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    54
import java.util.*;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    55
import java.math.BigDecimal;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    56
import java.io.*;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    57
import java.math.BigInteger;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    58
import sun.util.resources.LocaleData;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    59
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    60
public class NumberRegression extends IntlTest {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    61
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    62
    public static void main(String[] args) throws Exception {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    63
        new NumberRegression().run(args);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    64
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    65
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    66
    /**
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    67
     * NumberFormat.equals comparing with null should always return false.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    68
     */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    69
    public void Test4075713(){
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    70
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    71
        try {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    72
            MyNumberFormatTest tmp = new MyNumberFormatTest();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    73
            if (!tmp.equals(null))
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    74
                logln("NumberFormat.equals passed");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    75
        } catch (NullPointerException e) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    76
            errln("(new MyNumberFormatTest()).equals(null) throws unexpected exception");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    77
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    78
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    79
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    80
    /**
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    81
     * NumberFormat.equals comparing two obj equal even the setGroupingUsed
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    82
     * flag is different.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    83
     */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    84
    public void Test4074620() {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    85
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    86
        MyNumberFormatTest nf1 = new MyNumberFormatTest();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    87
        MyNumberFormatTest nf2 = new MyNumberFormatTest();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    88
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    89
        nf1.setGroupingUsed(false);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    90
        nf2.setGroupingUsed(true);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    91
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    92
        if (nf1.equals(nf2)) errln("Test for bug 4074620 failed");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    93
        else logln("Test for bug 4074620 passed.");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    94
        return;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    95
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    96
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    97
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    98
    /**
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    99
     * DecimalFormat.format() incorrectly uses maxFractionDigits setting.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   100
     */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   101
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   102
    public void Test4088161 (){
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   103
        DecimalFormat df = new DecimalFormat();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   104
        double d = 100;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   105
        df.setMinimumFractionDigits(0);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   106
        df.setMaximumFractionDigits(16);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   107
        StringBuffer sBuf1 = new StringBuffer("");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   108
        FieldPosition fp1 = new FieldPosition(0);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   109
        logln("d = " + d);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   110
        logln("maxFractionDigits = " + df.getMaximumFractionDigits());
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   111
        logln(" format(d) = '" + df.format(d, sBuf1, fp1) + "'");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   112
        df.setMaximumFractionDigits(17);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   113
        StringBuffer sBuf2 = new StringBuffer("");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   114
        FieldPosition fp2 = new FieldPosition(0);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   115
        logln("maxFractionDigits = " + df.getMaximumFractionDigits());
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   116
        df.format(d, sBuf2, fp2);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   117
        String expected = Locale.getDefault().equals(new Locale("hi", "IN")) ?
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   118
                              "\u0967\u0966\u0966" : "100";
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   119
        if (!sBuf2.toString().equals(expected))
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   120
            errln(" format(d) = '" + sBuf2 + "'");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   121
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   122
    /**
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   123
     * DecimalFormatSymbols should be cloned in the ctor DecimalFormat.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   124
     * DecimalFormat(String, DecimalFormatSymbols).
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   125
     */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   126
    public void Test4087245 (){
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   127
        DecimalFormatSymbols symbols = DecimalFormatSymbols.getInstance();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   128
        DecimalFormat df = new DecimalFormat("#,##0.0", symbols);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   129
        long n = 123;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   130
        StringBuffer buf1 = new StringBuffer();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   131
        StringBuffer buf2 = new StringBuffer();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   132
        logln("format(" + n + ") = " +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   133
        df.format(n, buf1, new FieldPosition(0)));
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   134
        symbols.setDecimalSeparator('p'); // change value of field
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   135
        logln("format(" + n + ") = " +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   136
        df.format(n, buf2, new FieldPosition(0)));
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   137
        if (!buf1.toString().equals(buf2.toString()))
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   138
            errln("Test for bug 4087245 failed");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   139
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   140
    /**
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   141
     * DecimalFormat.format() incorrectly formats 0.0
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   142
     */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   143
    public void Test4087535 ()
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   144
    {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   145
        DecimalFormat df = new DecimalFormat();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   146
        df.setMinimumIntegerDigits(0);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   147
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   148
        double n = 0;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   149
        String buffer = new String();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   150
        buffer = df.format(n);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   151
        if (buffer.length() == 0)
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   152
            errln(n + ": '" + buffer + "'");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   153
        n = 0.1;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   154
        buffer = df.format(n);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   155
        if (buffer.length() == 0)
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   156
            errln(n + ": '" + buffer + "'");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   157
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   158
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   159
    /**
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   160
     * DecimalFormat.format fails when groupingSize is set to 0.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   161
     */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   162
    public void Test4088503 (){
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   163
        DecimalFormat df = new DecimalFormat();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   164
        df.setGroupingSize(0);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   165
        StringBuffer sBuf = new StringBuffer("");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   166
        FieldPosition fp = new FieldPosition(0);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   167
        try {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   168
            logln(df.format(123, sBuf, fp).toString());
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   169
        } catch (Exception foo) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   170
            errln("Test for bug 4088503 failed.");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   171
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   172
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   173
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   174
    /**
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   175
     * NumberFormat.getCurrencyInstance is wrong.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   176
     */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   177
    public void Test4066646 () {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   178
        float returnfloat = 0.0f;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   179
        assignFloatValue(2.04f);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   180
        assignFloatValue(2.03f);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   181
        assignFloatValue(2.02f);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   182
        assignFloatValue(0.0f);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   183
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   184
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   185
    public float assignFloatValue(float returnfloat)
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   186
    {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   187
        logln(" VALUE " + returnfloat);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   188
        NumberFormat nfcommon =  NumberFormat.getCurrencyInstance(Locale.US);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   189
        nfcommon.setGroupingUsed(false);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   190
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   191
        String stringValue = nfcommon.format(returnfloat).substring(1);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   192
        if (Float.valueOf(stringValue).floatValue() != returnfloat)
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   193
            errln(" DISPLAYVALUE " + stringValue);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   194
        return returnfloat;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   195
    } // End Of assignFloatValue()
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   196
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   197
    /**
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   198
     * DecimalFormat throws exception when parsing "0"
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   199
     */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   200
    public void Test4059870() {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   201
        DecimalFormat format = new DecimalFormat("00");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   202
        try {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   203
            logln(format.parse("0").toString());
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   204
        } catch (Exception e) { errln("Test for bug 4059870 failed : " + e); }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   205
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   206
    /**
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   207
     * DecimalFormatSymbol.equals should always return false when
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   208
     * comparing with null.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   209
     */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   210
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   211
    public void Test4083018 (){
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   212
        DecimalFormatSymbols dfs = DecimalFormatSymbols.getInstance();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   213
        try {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   214
            if (!dfs.equals(null))
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   215
                logln("Test Passed!");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   216
        } catch (Exception foo) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   217
            errln("Test for bug 4083018 failed => Message : " + foo.getMessage());
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   218
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   219
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   220
    /**
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   221
     * DecimalFormat does not round up correctly.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   222
     */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   223
    public void Test4071492 (){
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   224
        Locale savedLocale = Locale.getDefault();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   225
        Locale.setDefault(Locale.US);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   226
        double x = 0.00159999;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   227
        NumberFormat nf = NumberFormat.getInstance();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   228
        nf.setMaximumFractionDigits(4);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   229
        String out = nf.format(x);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   230
        logln("0.00159999 formats with 4 fractional digits to " + out);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   231
        String expected = "0.0016";
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   232
        if (!out.equals(expected))
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   233
            errln("FAIL: Expected " + expected);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   234
        Locale.setDefault(savedLocale);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   235
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   236
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   237
    /**
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   238
     * A space as a group separator for localized pattern causes
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   239
     * wrong format.  WorkAround : use non-breaking space.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   240
     */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   241
    public void Test4086575() {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   242
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   243
        NumberFormat nf = NumberFormat.getInstance(Locale.FRANCE);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   244
        logln("nf toPattern1: " + ((DecimalFormat)nf).toPattern());
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   245
        logln("nf toLocPattern1: " + ((DecimalFormat)nf).toLocalizedPattern());
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   246
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   247
        // No group separator
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   248
        logln("...applyLocalizedPattern ###,00;(###,00) ");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   249
        ((DecimalFormat)nf).applyLocalizedPattern("###,00;(###,00)");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   250
        logln("nf toPattern2: " + ((DecimalFormat)nf).toPattern());
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   251
        logln("nf toLocPattern2: " + ((DecimalFormat)nf).toLocalizedPattern());
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   252
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   253
        logln("nf: " + nf.format(1234)); // 1234,00
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   254
        logln("nf: " + nf.format(-1234)); // (1234,00)
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   255
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   256
        // Space as group separator
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   257
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   258
        logln("...applyLocalizedPattern # ###,00;(# ###,00) ");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   259
        ((DecimalFormat)nf).applyLocalizedPattern("#\u00a0###,00;(#\u00a0###,00)");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   260
        logln("nf toPattern2: " + ((DecimalFormat)nf).toPattern());
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   261
        logln("nf toLocPattern2: " + ((DecimalFormat)nf).toLocalizedPattern());
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   262
        String buffer = nf.format(1234);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   263
        if (!buffer.equals("1\u00a0234,00"))
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   264
            errln("nf : " + buffer); // Expect 1 234,00
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   265
        buffer = nf.format(-1234);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   266
        if (!buffer.equals("(1\u00a0234,00)"))
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   267
            errln("nf : " + buffer); // Expect (1 234,00)
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   268
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   269
        // Erroneously prints:
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   270
        // 1234,00 ,
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   271
        // (1234,00 ,)
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   272
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   273
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   274
    /**
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   275
     * DecimalFormat.parse returns wrong value
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   276
     */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   277
    public void Test4068693()
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   278
    {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   279
        Locale savedLocale = Locale.getDefault();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   280
        Locale.setDefault(Locale.US);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   281
        logln("----- Test Application -----");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   282
        ParsePosition pos;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   283
        DecimalFormat df = new DecimalFormat();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   284
        Double d = (Double)df.parse("123.55456", pos=new ParsePosition(0));
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   285
        if (!d.toString().equals("123.55456")) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   286
            errln("Result -> " + d.doubleValue());
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   287
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   288
        Locale.setDefault(savedLocale);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   289
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   290
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   291
    /* bugs 4069754, 4067878
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   292
     * null pointer thrown when accessing a deserialized DecimalFormat
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   293
     * object.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   294
     */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   295
    public void Test4069754()
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   296
    {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   297
        try {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   298
            myformat it = new myformat();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   299
            logln(it.Now());
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   300
            FileOutputStream ostream = new FileOutputStream("t.tmp");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   301
            ObjectOutputStream p = new ObjectOutputStream(ostream);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   302
            p.writeObject(it);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   303
            ostream.close();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   304
            logln("Saved ok.");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   305
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   306
            FileInputStream istream = new FileInputStream("t.tmp");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   307
            ObjectInputStream p2 = new ObjectInputStream(istream);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   308
            myformat it2 = (myformat)p2.readObject();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   309
            logln(it2.Now());
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   310
            istream.close();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   311
            logln("Loaded ok.");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   312
        } catch (Exception foo) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   313
            errln("Test for bug 4069754 or 4057878 failed => Exception: " + foo.getMessage());
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   314
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   315
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   316
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   317
    /**
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   318
     * DecimalFormat.applyPattern(String) allows illegal patterns
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   319
     */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   320
    public void Test4087251 (){
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   321
        DecimalFormat df = new DecimalFormat();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   322
        try {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   323
            df.applyPattern("#.#.#");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   324
            logln("toPattern() returns \"" + df.toPattern() + "\"");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   325
            errln("applyPattern(\"#.#.#\") doesn't throw IllegalArgumentException");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   326
        } catch (IllegalArgumentException e) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   327
            logln("Caught Illegal Argument Error !");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   328
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   329
        // Second test; added 5/11/98 when reported to fail on 1.2b3
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   330
        try {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   331
            df.applyPattern("#0.0#0#0");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   332
            logln("toPattern() returns \"" + df.toPattern() + "\"");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   333
            errln("applyPattern(\"#0.0#0#0\") doesn't throw IllegalArgumentException");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   334
        } catch (IllegalArgumentException e) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   335
            logln("Ok - IllegalArgumentException for #0.0#0#0");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   336
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   337
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   338
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   339
    /**
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   340
     * DecimalFormat.format() loses precision
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   341
     */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   342
    public void Test4090489 (){
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   343
        Locale savedLocale = Locale.getDefault();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   344
        Locale.setDefault(Locale.US);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   345
        DecimalFormat df = new DecimalFormat();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   346
        df.setMinimumFractionDigits(10);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   347
        df.setGroupingUsed(false);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   348
        double d = 1.000000000000001E7;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   349
        BigDecimal bd = new BigDecimal(d);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   350
        StringBuffer sb = new StringBuffer("");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   351
        FieldPosition fp = new FieldPosition(0);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   352
        logln("d = " + d);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   353
        logln("BigDecimal.toString():  " + bd.toString());
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   354
        df.format(d, sb, fp);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   355
        if (!sb.toString().equals("10000000.0000000100")) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   356
            errln("DecimalFormat.format(): " + sb.toString());
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   357
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   358
        Locale.setDefault(savedLocale);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   359
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   360
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   361
    /**
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   362
     * DecimalFormat.format() loses precision
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   363
     */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   364
    public void Test4090504 ()
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   365
    {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   366
        double d = 1;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   367
        logln("d = " + d);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   368
        DecimalFormat df = new DecimalFormat();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   369
        StringBuffer sb;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   370
        FieldPosition fp;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   371
        try {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   372
            for (int i = 17; i <= 20; i++) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   373
                df.setMaximumFractionDigits(i);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   374
                sb = new StringBuffer("");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   375
                fp = new FieldPosition(0);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   376
                logln("  getMaximumFractionDigits() = " + i);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   377
                logln("  formated: " + df.format(d, sb, fp));
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   378
            }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   379
        } catch (Exception foo) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   380
            errln("Bug 4090504 regression test failed. Message : " + foo.getMessage());
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   381
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   382
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   383
    /**
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   384
     * DecimalFormat.parse(String str, ParsePosition pp) loses precision
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   385
     */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   386
    public void Test4095713 ()
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   387
    {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   388
        Locale savedLocale = Locale.getDefault();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   389
        Locale.setDefault(Locale.US);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   390
        DecimalFormat df = new DecimalFormat();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   391
        String str = "0.1234";
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   392
        Double d1 = new Double(str);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   393
        Double d2 = (Double) df.parse(str, new ParsePosition(0));
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   394
        logln(d1.toString());
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   395
        if (d2.doubleValue() != d1.doubleValue())
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   396
            errln("Bug 4095713 test failed, new double value : " + d2.doubleValue());
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   397
        Locale.setDefault(savedLocale);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   398
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   399
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   400
    /**
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   401
     * DecimalFormat.parse() fails when multiplier is not set to 1
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   402
     */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   403
    public void Test4092561 ()
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   404
    {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   405
        Locale savedLocale = Locale.getDefault();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   406
        Locale.setDefault(Locale.US);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   407
        DecimalFormat df = new DecimalFormat();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   408
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   409
        String str = Long.toString(Long.MIN_VALUE);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   410
        logln("Long.MIN_VALUE : " + df.parse(str, new ParsePosition(0)).toString());
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   411
        df.setMultiplier(100);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   412
        Number num = df.parse(str, new ParsePosition(0));
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   413
        if (num.doubleValue() != -9.223372036854776E16) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   414
            errln("Bug 4092561 test failed when multiplier is not set to 1. Expected: -9.223372036854776E16, got: " + num.doubleValue());
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   415
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   416
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   417
        df.setMultiplier(-100);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   418
        num = df.parse(str, new ParsePosition(0));
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   419
        if (num.doubleValue() != 9.223372036854776E16) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   420
            errln("Bug 4092561 test failed when multiplier is not set to 1. Expected: 9.223372036854776E16, got: " + num.doubleValue());
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   421
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   422
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   423
        str = Long.toString(Long.MAX_VALUE);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   424
        logln("Long.MAX_VALUE : " + df.parse(str, new ParsePosition(0)).toString());
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   425
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   426
        df.setMultiplier(100);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   427
        num = df.parse(str, new ParsePosition(0));
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   428
        if (num.doubleValue() != 9.223372036854776E16) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   429
            errln("Bug 4092561 test failed when multiplier is not set to 1. Expected: 9.223372036854776E16, got: " + num.doubleValue());
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   430
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   431
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   432
        df.setMultiplier(-100);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   433
        num = df.parse(str, new ParsePosition(0));
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   434
        if (num.doubleValue() != -9.223372036854776E16) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   435
            errln("Bug 4092561 test failed when multiplier is not set to 1. Expected: -9.223372036854776E16, got: " + num.doubleValue());
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   436
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   437
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   438
        Locale.setDefault(savedLocale);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   439
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   440
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   441
    /**
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   442
     * DecimalFormat: Negative format ignored.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   443
     */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   444
    public void Test4092480 ()
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   445
    {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   446
        DecimalFormat dfFoo = new DecimalFormat("000");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   447
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   448
        try {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   449
            dfFoo.applyPattern("0000;-000");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   450
            if (!dfFoo.toPattern().equals("#0000"))
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   451
                errln("dfFoo.toPattern : " + dfFoo.toPattern());
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   452
            logln(dfFoo.format(42));
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   453
            logln(dfFoo.format(-42));
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   454
            dfFoo.applyPattern("000;-000");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   455
            if (!dfFoo.toPattern().equals("#000"))
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   456
                errln("dfFoo.toPattern : " + dfFoo.toPattern());
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   457
            logln(dfFoo.format(42));
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   458
            logln(dfFoo.format(-42));
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   459
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   460
            dfFoo.applyPattern("000;-0000");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   461
            if (!dfFoo.toPattern().equals("#000"))
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   462
                errln("dfFoo.toPattern : " + dfFoo.toPattern());
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   463
            logln(dfFoo.format(42));
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   464
            logln(dfFoo.format(-42));
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   465
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   466
            dfFoo.applyPattern("0000;-000");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   467
            if (!dfFoo.toPattern().equals("#0000"))
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   468
                errln("dfFoo.toPattern : " + dfFoo.toPattern());
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   469
            logln(dfFoo.format(42));
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   470
            logln(dfFoo.format(-42));
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   471
        } catch (Exception foo) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   472
            errln("Message " + foo.getMessage());
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   473
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   474
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   475
    /**
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   476
     * NumberFormat.getCurrencyInstance() produces format that uses
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   477
     * decimal separator instead of monetary decimal separator.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   478
     *
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   479
     * Rewrote this test not to depend on the actual pattern.  Pattern should
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   480
     * never contain the monetary separator!  Decimal separator in pattern is
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   481
     * interpreted as monetary separator if currency symbol is seen!
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   482
     */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   483
    public void Test4087244 () {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   484
        Locale de = new Locale("pt", "PT");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   485
        DecimalFormat df = (DecimalFormat) NumberFormat.getCurrencyInstance(de);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   486
        DecimalFormatSymbols sym = df.getDecimalFormatSymbols();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   487
        sym.setMonetaryDecimalSeparator('$');
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   488
        df.setDecimalFormatSymbols(sym);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   489
        char decSep = sym.getDecimalSeparator();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   490
        char monSep = sym.getMonetaryDecimalSeparator();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   491
        char zero = sym.getZeroDigit();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   492
        if (decSep == monSep) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   493
            errln("ERROR in test: want decimal sep != monetary sep");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   494
        } else {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   495
            df.setMinimumIntegerDigits(1);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   496
            df.setMinimumFractionDigits(2);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   497
            String str = df.format(1.23);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   498
            String monStr = "1" + monSep + "23";
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   499
            String decStr = "1" + decSep + "23";
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   500
            if (str.indexOf(monStr) >= 0 && str.indexOf(decStr) < 0) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   501
                logln("OK: 1.23 -> \"" + str + "\" contains \"" +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   502
                      monStr + "\" and not \"" + decStr + '"');
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   503
            } else {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   504
                errln("FAIL: 1.23 -> \"" + str + "\", should contain \"" +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   505
                      monStr +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   506
                      "\" and not \"" + decStr + '"');
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   507
            }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   508
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   509
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   510
    /**
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   511
     * Number format data rounding errors for locale FR
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   512
     */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   513
    public void Test4070798 () {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   514
        NumberFormat formatter;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   515
        String tempString;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   516
        /* User error :
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   517
        String expectedDefault = "-5\u00a0789,987";
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   518
        String expectedCurrency = "5\u00a0789,98 F";
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   519
        String expectedPercent = "-578\u00a0998%";
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   520
        */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   521
        String expectedDefault = "-5\u00a0789,988";
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   522
        String expectedCurrency = "5\u00a0789,99 \u20AC";
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   523
        // changed for bug 6547501
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   524
        String expectedPercent = "-578\u00a0999 %";
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   525
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   526
        formatter = NumberFormat.getNumberInstance(Locale.FRANCE);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   527
        tempString = formatter.format (-5789.9876);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   528
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   529
        if (tempString.equals(expectedDefault)) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   530
            logln ("Bug 4070798 default test passed.");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   531
        } else {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   532
            errln("Failed:" +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   533
            " Expected " + expectedDefault +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   534
            " Received " + tempString );
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   535
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   536
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   537
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   538
        formatter = NumberFormat.getCurrencyInstance(Locale.FRANCE);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   539
        tempString = formatter.format( 5789.9876 );
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   540
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   541
        if (tempString.equals(expectedCurrency) ) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   542
            logln ("Bug 4070798 currency test assed.");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   543
        } else {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   544
            errln("Failed:" +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   545
            " Expected " + expectedCurrency +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   546
            " Received " + tempString );
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   547
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   548
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   549
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   550
        formatter = NumberFormat.getPercentInstance(Locale.FRANCE);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   551
        tempString = formatter.format (-5789.9876);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   552
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   553
        if (tempString.equals(expectedPercent) ) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   554
            logln ("Bug 4070798 percentage test passed.");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   555
        } else {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   556
            errln("Failed:" +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   557
            " Expected " + expectedPercent +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   558
            " Received " + tempString );
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   559
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   560
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   561
    /**
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   562
     * Data rounding errors for French (Canada) locale
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   563
     */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   564
    public void Test4071005 () {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   565
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   566
        NumberFormat formatter;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   567
        String tempString;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   568
    /* user error :
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   569
        String expectedDefault = "-5 789,987";
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   570
        String expectedCurrency = "5 789,98 $";
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   571
        String expectedPercent = "-578 998%";
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   572
    */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   573
        String expectedDefault = "-5\u00a0789,988";
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   574
        String expectedCurrency = "5\u00a0789,99 $";
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   575
        // changed for bug 6547501
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   576
        String expectedPercent = "-578\u00a0999 %";
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   577
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   578
        formatter = NumberFormat.getNumberInstance(Locale.CANADA_FRENCH);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   579
        tempString = formatter.format (-5789.9876);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   580
        if (tempString.equals(expectedDefault)) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   581
            logln ("Bug 4071005 default test passed.");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   582
        } else {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   583
            errln("Failed:" +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   584
            " Expected " + expectedDefault +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   585
            " Received " + tempString );
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   586
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   587
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   588
        formatter = NumberFormat.getCurrencyInstance(Locale.CANADA_FRENCH);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   589
        tempString = formatter.format( 5789.9876 ) ;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   590
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   591
        if (tempString.equals(expectedCurrency) ) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   592
            logln ("Bug 4071005 currency test passed.");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   593
        } else {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   594
            errln("Failed:" +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   595
            " Expected " + expectedCurrency +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   596
            " Received " + tempString );
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   597
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   598
        formatter = NumberFormat.getPercentInstance(Locale.CANADA_FRENCH);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   599
        tempString = formatter.format (-5789.9876);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   600
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   601
        if (tempString.equals(expectedPercent) ) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   602
            logln ("Bug 4071005 percentage test passed.");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   603
        } else {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   604
            errln("Failed:" +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   605
            " Expected " + expectedPercent +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   606
            " Received " + tempString );
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   607
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   608
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   609
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   610
    /**
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   611
     * Data rounding errors for German (Germany) locale
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   612
     */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   613
    public void Test4071014 () {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   614
        NumberFormat formatter;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   615
        String tempString;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   616
        /* user error :
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   617
        String expectedDefault = "-5.789,987";
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   618
        String expectedCurrency = "5.789,98 DM";
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   619
        String expectedPercent = "-578.998%";
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   620
        */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   621
        String expectedDefault = "-5.789,988";
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   622
        String expectedCurrency = "5.789,99 \u20AC";
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   623
        String expectedPercent = "-578.999%";
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   624
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   625
        formatter = NumberFormat.getNumberInstance(Locale.GERMANY);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   626
        tempString = formatter.format (-5789.9876);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   627
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   628
        if (tempString.equals(expectedDefault)) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   629
            logln ("Bug 4071014 default test passed.");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   630
        } else {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   631
            errln("Failed:" +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   632
            " Expected " + expectedDefault +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   633
            " Received " + tempString );
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   634
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   635
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   636
        formatter = NumberFormat.getCurrencyInstance(Locale.GERMANY);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   637
        tempString = formatter.format( 5789.9876 ) ;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   638
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   639
        if (tempString.equals(expectedCurrency) ) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   640
            logln ("Bug 4071014 currency test passed.");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   641
        } else {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   642
            errln("Failed:" +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   643
            " Expected " + expectedCurrency +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   644
            " Received " + tempString );
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   645
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   646
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   647
        formatter = NumberFormat.getPercentInstance(Locale.GERMANY);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   648
        tempString = formatter.format (-5789.9876);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   649
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   650
        if (tempString.equals(expectedPercent) ) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   651
            logln ("Bug 4071014 percentage test passed.");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   652
        } else {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   653
            errln("Failed:" +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   654
            " Expected " + expectedPercent +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   655
            " Received " + tempString );
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   656
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   657
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   658
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   659
    /**
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   660
     * Data rounding errors for Italian locale number formats
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   661
     */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   662
    public void Test4071859 () {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   663
        NumberFormat formatter;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   664
        String tempString;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   665
        /* user error :
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   666
        String expectedDefault = "-5.789,987";
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   667
        String expectedCurrency = "-L. 5.789,98";
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   668
        String expectedPercent = "-578.998%";
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   669
        */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   670
        String expectedDefault = "-5.789,988";
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   671
        String expectedCurrency = "-\u20AC 5.789,99";
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   672
        String expectedPercent = "-578.999%";
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   673
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   674
        formatter = NumberFormat.getNumberInstance(Locale.ITALY);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   675
        tempString = formatter.format (-5789.9876);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   676
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   677
        if (tempString.equals(expectedDefault)) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   678
            logln ("Bug 4071859 default test passed.");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   679
        } else {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   680
            errln("Failed:" +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   681
            " Expected " + expectedDefault +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   682
            " Received " + tempString );
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   683
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   684
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   685
        formatter = NumberFormat.getCurrencyInstance(Locale.ITALY);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   686
        tempString = formatter.format( -5789.9876 ) ;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   687
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   688
        if (tempString.equals(expectedCurrency) ) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   689
            logln ("Bug 4071859 currency test passed.");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   690
        } else {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   691
            errln("Failed:" +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   692
            " Expected " + expectedCurrency +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   693
            " Received " + tempString );
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   694
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   695
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   696
        formatter = NumberFormat.getPercentInstance(Locale.ITALY);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   697
        tempString = formatter.format (-5789.9876);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   698
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   699
        if (tempString.equals(expectedPercent) ) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   700
            logln ("Bug 4071859 percentage test passed.");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   701
        } else {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   702
            errln("Failed:" +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   703
            " Expected " + expectedPercent +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   704
            " Received " + tempString );
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   705
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   706
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   707
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   708
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   709
    /* bug 4071859
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   710
     * Test rounding for nearest even.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   711
     */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   712
    public void Test4093610()
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   713
    {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   714
        Locale savedLocale = Locale.getDefault();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   715
        Locale.setDefault(Locale.US);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   716
        DecimalFormat df = new DecimalFormat("#0.#");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   717
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   718
        roundingTest(df, 12.15, "12.2"); // Rounding-up. Above tie (12.150..)
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   719
        roundingTest(df, 12.25, "12.2"); // No round-up. Exact + half-even rule.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   720
        roundingTest(df, 12.45, "12.4"); // No round-up. Below tie (12.449..)
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   721
        roundingTest(df, 12.450000001,"12.5"); // Rounding-up. Above tie.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   722
        roundingTest(df, 12.55, "12.6"); // Rounding-up. Above tie (12.550..)
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   723
        roundingTest(df, 12.650000001,"12.7"); // Rounding-up. Above tie.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   724
        roundingTest(df, 12.75, "12.8"); // Rounding-up. Exact + half-even rule.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   725
        roundingTest(df, 12.750000001,"12.8"); // Rounding-up. Above tie.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   726
        roundingTest(df, 12.85, "12.8"); // No round-up. Below tie (12.849..)
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   727
        roundingTest(df, 12.850000001,"12.9"); // Rounding-up. Above tie.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   728
        roundingTest(df, 12.950000001,"13");   // Rounding-up. Above tie.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   729
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   730
        Locale.setDefault(savedLocale);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   731
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   732
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   733
    void roundingTest(DecimalFormat df, double x, String expected)
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   734
    {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   735
        String out = df.format(x);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   736
        logln("" + x + " formats with 1 fractional digits to " + out);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   737
        if (!out.equals(expected)) errln("FAIL: Expected " + expected);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   738
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   739
    /**
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   740
     * Tests the setMaximumFractionDigits limit.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   741
     */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   742
    public void Test4098741()
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   743
    {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   744
        try {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   745
            NumberFormat fmt = NumberFormat.getPercentInstance();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   746
            fmt.setMaximumFractionDigits(20);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   747
            logln(fmt.format(.001));
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   748
        } catch (Exception foo) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   749
            errln("Bug 4098471 failed with exception thrown : " + foo.getMessage());
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   750
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   751
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   752
    /**
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   753
     * Tests illegal pattern exception.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   754
     * Fix comment : HShih A31 Part1 will not be fixed and javadoc needs to be updated.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   755
     * Part2 has been fixed.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   756
     */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   757
    public void Test4074454()
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   758
    {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   759
        Locale savedLocale = Locale.getDefault();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   760
        Locale.setDefault(Locale.US);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   761
        try {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   762
            DecimalFormat fmt = new DecimalFormat("#,#00.00;-#.#");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   763
            logln("Inconsistent negative pattern is fine.");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   764
            DecimalFormat newFmt = new DecimalFormat("#,#00.00 p''ieces;-#,#00.00 p''ieces");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   765
            String tempString = newFmt.format(3456.78);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   766
            if (!tempString.equals("3,456.78 p'ieces"))
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   767
                errln("Failed!  3,456.78 p'ieces expected, but got : " + tempString);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   768
        } catch (Exception foo) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   769
            errln("An exception was thrown for any inconsistent negative pattern.");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   770
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   771
        Locale.setDefault(savedLocale);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   772
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   773
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   774
    /**
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   775
     * Tests all different comments.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   776
     * Response to some comments :
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   777
     * [1] DecimalFormat.parse API documentation is more than just one line.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   778
     * This is not a reproducable doc error in 116 source code.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   779
     * [2] See updated javadoc.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   780
     * [3] Fixed.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   781
     * [4] NumberFormat.parse(String, ParsePosition) : If parsing fails,
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   782
     * a null object will be returned.  The unchanged parse position also
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   783
     * reflects an error.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   784
     * NumberFormat.parse(String) : If parsing fails, an ParseException
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   785
     * will be thrown.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   786
     * See updated javadoc for more details.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   787
     * [5] See updated javadoc.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   788
     * [6] See updated javadoc.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   789
     * [7] This is a correct behavior if the DateFormat object is linient.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   790
     * Otherwise, an IllegalArgumentException will be thrown when formatting
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   791
     * "January 35".  See GregorianCalendar class javadoc for more details.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   792
     */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   793
    public void Test4099404()
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   794
    {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   795
        try {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   796
            DecimalFormat fmt = new DecimalFormat("000.0#0");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   797
            errln("Bug 4099404 failed applying illegal pattern \"000.0#0\"");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   798
        } catch (Exception foo) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   799
            logln("Bug 4099404 pattern \"000.0#0\" passed");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   800
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   801
        try {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   802
            DecimalFormat fmt = new DecimalFormat("0#0.000");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   803
            errln("Bug 4099404 failed applying illegal pattern \"0#0.000\"");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   804
        } catch (Exception foo) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   805
            logln("Bug 4099404 pattern \"0#0.000\" passed");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   806
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   807
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   808
    /**
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   809
     * DecimalFormat.applyPattern doesn't set minimum integer digits
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   810
     */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   811
    public void Test4101481()
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   812
    {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   813
        DecimalFormat sdf = new DecimalFormat("#,##0");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   814
        if (sdf.getMinimumIntegerDigits() != 1)
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   815
            errln("Minimum integer digits : " + sdf.getMinimumIntegerDigits());
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   816
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   817
    /**
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   818
     * Tests ParsePosition.setErrorPosition() and ParsePosition.getErrorPosition().
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   819
     */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   820
    public void Test4052223()
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   821
    {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   822
        try {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   823
            DecimalFormat fmt = new DecimalFormat("#,#00.00");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   824
            Number num = fmt.parse("abc3");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   825
            errln("Bug 4052223 failed : can't parse string \"a\".  Got " + num);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   826
        } catch (ParseException foo) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   827
            logln("Caught expected ParseException : " + foo.getMessage() + " at index : " + foo.getErrorOffset());
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   828
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   829
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   830
    /**
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   831
     * API tests for API addition request A9.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   832
     */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   833
    public void Test4061302()
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   834
    {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   835
        DecimalFormatSymbols fmt = DecimalFormatSymbols.getInstance();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   836
        String currency = fmt.getCurrencySymbol();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   837
        String intlCurrency = fmt.getInternationalCurrencySymbol();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   838
        char monDecSeparator = fmt.getMonetaryDecimalSeparator();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   839
        if (currency.equals("") ||
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   840
            intlCurrency.equals("") ||
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   841
            monDecSeparator == 0) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   842
            errln("getCurrencySymbols failed, got empty string.");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   843
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   844
        logln("Before set ==> Currency : " + currency + " Intl Currency : " + intlCurrency + " Monetary Decimal Separator : " + monDecSeparator);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   845
        fmt.setCurrencySymbol("XYZ");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   846
        fmt.setInternationalCurrencySymbol("ABC");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   847
        fmt.setMonetaryDecimalSeparator('*');
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   848
        currency = fmt.getCurrencySymbol();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   849
        intlCurrency = fmt.getInternationalCurrencySymbol();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   850
        monDecSeparator = fmt.getMonetaryDecimalSeparator();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   851
        if (!currency.equals("XYZ") ||
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   852
            !intlCurrency.equals("ABC") ||
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   853
            monDecSeparator != '*') {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   854
            errln("setCurrencySymbols failed.");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   855
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   856
        logln("After set ==> Currency : " + currency + " Intl Currency : " + intlCurrency + " Monetary Decimal Separator : " + monDecSeparator);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   857
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   858
    /**
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   859
     * API tests for API addition request A23. FieldPosition.getBeginIndex and
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   860
     * FieldPosition.getEndIndex.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   861
     */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   862
    public void Test4062486()
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   863
    {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   864
        DecimalFormat fmt = new DecimalFormat("#,##0.00");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   865
        StringBuffer formatted = new StringBuffer();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   866
        FieldPosition field = new FieldPosition(0);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   867
        Double num = new Double(1234.5);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   868
        fmt.format(num, formatted, field);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   869
        if (field.getBeginIndex() != 0 && field.getEndIndex() != 5)
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   870
            errln("Format 1234.5 failed. Begin index: " + field.getBeginIndex() + " End index: " + field.getEndIndex());
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   871
        field.setBeginIndex(7);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   872
        field.setEndIndex(4);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   873
        if (field.getBeginIndex() != 7 && field.getEndIndex() != 4)
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   874
            errln("Set begin/end field indexes failed. Begin index: " + field.getBeginIndex() + " End index: " + field.getEndIndex());
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   875
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   876
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   877
    /**
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   878
     * DecimalFormat.parse incorrectly works with a group separator.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   879
     */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   880
    public void Test4108738()
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   881
    {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   882
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   883
        DecimalFormat df = new DecimalFormat("#,##0.###",
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   884
        DecimalFormatSymbols.getInstance(java.util.Locale.US));
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   885
        String text = "1.222,111";
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   886
        Number num = df.parse(text,new ParsePosition(0));
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   887
        if (!num.toString().equals("1.222"))
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   888
            errln("\"" + text + "\"  is parsed as " + num);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   889
        text = "1.222x111";
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   890
        num = df.parse(text,new ParsePosition(0));
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   891
        if (!num.toString().equals("1.222"))
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   892
            errln("\"" + text + "\"  is parsed as " + num);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   893
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   894
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   895
    /**
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   896
     * DecimalFormat.format() incorrectly formats negative doubles.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   897
     */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   898
    public void Test4106658()
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   899
    {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   900
        Locale savedLocale = Locale.getDefault();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   901
        Locale.setDefault(Locale.US);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   902
        DecimalFormat df = new DecimalFormat(); // Corrected; see 4147706
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   903
        double d1 = -0.0;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   904
        double d2 = -0.0001;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   905
        StringBuffer buffer = new StringBuffer();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   906
        logln("pattern: \"" + df.toPattern() + "\"");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   907
        df.format(d1, buffer, new FieldPosition(0));
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   908
        if (!buffer.toString().equals("-0")) { // Corrected; see 4147706
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   909
            errln(d1 + "      is formatted as " + buffer);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   910
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   911
        buffer.setLength(0);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   912
        df.format(d2, buffer, new FieldPosition(0));
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   913
        if (!buffer.toString().equals("-0")) { // Corrected; see 4147706
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   914
            errln(d2 + "      is formatted as " + buffer);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   915
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   916
        Locale.setDefault(savedLocale);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   917
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   918
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   919
    /**
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   920
     * DecimalFormat.parse returns 0 if string parameter is incorrect.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   921
     */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   922
    public void Test4106662()
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   923
    {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   924
        DecimalFormat df = new DecimalFormat();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   925
        String text = "x";
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   926
        ParsePosition pos1 = new ParsePosition(0), pos2 = new ParsePosition(0);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   927
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   928
        logln("pattern: \"" + df.toPattern() + "\"");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   929
        Number num = df.parse(text, pos1);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   930
        if (num != null) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   931
            errln("Test Failed: \"" + text + "\" is parsed as " + num);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   932
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   933
        df = null;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   934
        df = new DecimalFormat("$###.00");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   935
        num = df.parse("$", pos2);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   936
        if (num != null){
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   937
            errln("Test Failed: \"$\" is parsed as " + num);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   938
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   939
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   940
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   941
    /**
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   942
     * NumberFormat.parse doesn't return null
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   943
     */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   944
    public void Test4114639()
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   945
    {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   946
        NumberFormat format = NumberFormat.getInstance();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   947
        String text = "time 10:x";
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   948
        ParsePosition pos = new ParsePosition(8);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   949
        Number result = format.parse(text, pos);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   950
        if (result != null) errln("Should return null but got : " + result); // Should be null; it isn't
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   951
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   952
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   953
    /**
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   954
     * DecimalFormat.format(long n) fails if n * multiplier > MAX_LONG.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   955
     */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   956
    public void Test4106664()
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   957
    {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   958
        DecimalFormat df = new DecimalFormat();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   959
        long n = 1234567890123456L;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   960
        int m = 12345678;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   961
        BigInteger bigN = BigInteger.valueOf(n);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   962
        bigN = bigN.multiply(BigInteger.valueOf(m));
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   963
        df.setMultiplier(m);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   964
        df.setGroupingUsed(false);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   965
        logln("formated: " +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   966
            df.format(n, new StringBuffer(), new FieldPosition(0)));
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   967
        logln("expected: " + bigN.toString());
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   968
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   969
    /**
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   970
     * DecimalFormat.format incorrectly formats -0.0.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   971
     */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   972
    public void Test4106667()
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   973
    {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   974
        Locale savedLocale = Locale.getDefault();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   975
        Locale.setDefault(Locale.US);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   976
        DecimalFormat df = new DecimalFormat();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   977
        df.setPositivePrefix("+");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   978
        double d = -0.0;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   979
        logln("pattern: \"" + df.toPattern() + "\"");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   980
        StringBuffer buffer = new StringBuffer();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   981
        df.format(d, buffer, new FieldPosition(0));
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   982
        if (!buffer.toString().equals("-0")) { // Corrected; see 4147706
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   983
            errln(d + "  is formatted as " + buffer);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   984
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   985
        Locale.setDefault(savedLocale);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   986
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   987
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   988
    /**
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   989
     * DecimalFormat.setMaximumIntegerDigits() works incorrectly.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   990
     */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   991
    public void Test4110936()
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   992
    {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   993
        NumberFormat nf = NumberFormat.getInstance();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   994
        nf.setMaximumIntegerDigits(128);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   995
        logln("setMaximumIntegerDigits(128)");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   996
        if (nf.getMaximumIntegerDigits() != 128)
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   997
            errln("getMaximumIntegerDigits() returns " +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   998
                nf.getMaximumIntegerDigits());
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   999
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1000
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1001
    /**
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1002
     * Locale data should use generic currency symbol
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1003
     *
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1004
     * 1) Make sure that all currency formats use the generic currency symbol.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1005
     * 2) Make sure we get the same results using the generic symbol or a
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1006
     *    hard-coded one.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1007
     */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1008
    public void Test4122840()
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1009
    {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1010
        Locale[] locales = NumberFormat.getAvailableLocales();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1011
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1012
        for (int i = 0; i < locales.length; i++) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1013
            ResourceBundle rb = LocaleData.getBundle("sun.text.resources.FormatData",
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1014
                                                     locales[i]);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1015
            //
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1016
            // Get the currency pattern for this locale.  We have to fish it
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1017
            // out of the ResourceBundle directly, since DecimalFormat.toPattern
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1018
            // will return the localized symbol, not \00a4
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1019
            //
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1020
            String[] numPatterns = (String[])rb.getObject("NumberPatterns");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1021
            String pattern = numPatterns[1];
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1022
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1023
            if (pattern.indexOf("\u00A4") == -1 ) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1024
                errln("Currency format for " + locales[i] +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1025
                        " does not contain generic currency symbol:" +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1026
                        pattern );
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1027
            }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1028
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1029
            // Create a DecimalFormat using the pattern we got and format a number
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1030
            DecimalFormatSymbols symbols = DecimalFormatSymbols.getInstance(locales[i]);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1031
            DecimalFormat fmt1 = new DecimalFormat(pattern, symbols);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1032
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1033
            String result1 = fmt1.format(1.111);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1034
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1035
            //
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1036
            // Now substitute in the locale's currency symbol and create another
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1037
            // pattern.  Replace the decimal separator with the monetary separator.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1038
            //
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1039
            char decSep = symbols.getDecimalSeparator();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1040
            char monSep = symbols.getMonetaryDecimalSeparator();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1041
            StringBuffer buf = new StringBuffer(pattern);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1042
            for (int j = 0; j < buf.length(); j++) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1043
                if (buf.charAt(j) == '\u00a4') {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1044
                    String cur = "'" + symbols.getCurrencySymbol() + "'";
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1045
                    buf.replace(j, j+1, cur);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1046
                    j += cur.length() - 1;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1047
                }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1048
            }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1049
            symbols.setDecimalSeparator(monSep);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1050
            DecimalFormat fmt2 = new DecimalFormat(buf.toString(), symbols);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1051
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1052
            String result2 = fmt2.format(1.111);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1053
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1054
            if (!result1.equals(result2)) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1055
                errln("Results for " + locales[i] + " differ: " +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1056
                      result1 + " vs " + result2);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1057
            }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1058
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1059
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1060
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1061
    /**
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1062
     * DecimalFormat.format() delivers wrong string.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1063
     */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1064
    public void Test4125885()
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1065
    {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1066
        Locale savedLocale = Locale.getDefault();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1067
        Locale.setDefault(Locale.US);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1068
        double rate = 12.34;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1069
        DecimalFormat formatDec = new DecimalFormat ("000.00");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1070
        logln("toPattern: " + formatDec.toPattern());
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1071
        String rateString= formatDec.format(rate);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1072
        if (!rateString.equals("012.34"))
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1073
            errln("result : " + rateString + " expected : 012.34");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1074
        rate = 0.1234;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1075
        formatDec = null;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1076
        formatDec = new DecimalFormat ("+000.00%;-000.00%");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1077
        logln("toPattern: " + formatDec.toPattern());
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1078
        rateString= formatDec.format(rate);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1079
        if (!rateString.equals("+012.34%"))
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1080
            errln("result : " + rateString + " expected : +012.34%");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1081
        Locale.setDefault(savedLocale);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1082
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1083
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1084
    /**
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1085
     **
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1086
     * DecimalFormat produces extra zeros when formatting numbers.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1087
     */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1088
    public void Test4134034() {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1089
        Locale savedLocale = Locale.getDefault();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1090
        Locale.setDefault(Locale.US);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1091
        DecimalFormat nf = new DecimalFormat("##,###,###.00");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1092
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1093
        String f = nf.format(9.02);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1094
        if (f.equals("9.02")) logln(f + " ok"); else errln("9.02 -> " + f + "; want 9.02");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1095
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1096
        f = nf.format(0);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1097
        if (f.equals(".00")) logln(f + " ok"); else errln("0 -> " + f + "; want .00");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1098
        Locale.setDefault(savedLocale);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1099
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1100
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1101
    /**
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1102
     * CANNOT REPRODUCE - This bug could not be reproduced.  It may be
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1103
     * a duplicate of 4134034.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1104
     *
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1105
     * JDK 1.1.6 Bug, did NOT occur in 1.1.5
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1106
     * Possibly related to bug 4125885.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1107
     *
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1108
     * This class demonstrates a regression in version 1.1.6
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1109
     * of DecimalFormat class.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1110
     *
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1111
     * 1.1.6 Results
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1112
     * Value 1.2 Format #.00 Result '01.20' !!!wrong
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1113
     * Value 1.2 Format 0.00 Result '001.20' !!!wrong
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1114
     * Value 1.2 Format 00.00 Result '0001.20' !!!wrong
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1115
     * Value 1.2 Format #0.0# Result '1.2'
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1116
     * Value 1.2 Format #0.00 Result '001.20' !!!wrong
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1117
     *
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1118
     * 1.1.5 Results
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1119
     * Value 1.2 Format #.00 Result '1.20'
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1120
     * Value 1.2 Format 0.00 Result '1.20'
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1121
     * Value 1.2 Format 00.00 Result '01.20'
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1122
     * Value 1.2 Format #0.0# Result '1.2'
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1123
     * Value 1.2 Format #0.00 Result '1.20'
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1124
     */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1125
    public void Test4134300() {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1126
        Locale savedLocale = Locale.getDefault();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1127
        Locale.setDefault(Locale.US);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1128
        String[] DATA = {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1129
         // Pattern      Expected string
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1130
            "#.00",      "1.20",
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1131
            "0.00",      "1.20",
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1132
            "00.00",     "01.20",
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1133
            "#0.0#",     "1.2",
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1134
            "#0.00",     "1.20",
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1135
        };
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1136
        for (int i=0; i<DATA.length; i+=2) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1137
            String result = new DecimalFormat(DATA[i]).format(1.2);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1138
            if (!result.equals(DATA[i+1])) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1139
                errln("Fail: 1.2 x " + DATA[i] + " = " + result +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1140
                      "; want " + DATA[i+1]);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1141
            }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1142
            else {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1143
                logln("Ok: 1.2 x " + DATA[i] + " = " + result);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1144
            }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1145
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1146
        Locale.setDefault(savedLocale);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1147
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1148
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1149
    /**
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1150
     * Empty pattern produces double negative prefix.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1151
     */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1152
    public void Test4140009() {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1153
        for (int i=0; i<2; ++i) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1154
            DecimalFormat f = null;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1155
            switch (i) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1156
            case 0:
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1157
                f = new DecimalFormat("",
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1158
                            DecimalFormatSymbols.getInstance(Locale.ENGLISH));
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1159
                break;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1160
            case 1:
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1161
                f = new DecimalFormat("#.#",
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1162
                            DecimalFormatSymbols.getInstance(Locale.ENGLISH));
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1163
                f.applyPattern("");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1164
                break;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1165
            }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1166
            String s = f.format(123.456);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1167
            if (!s.equals("123.456"))
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1168
                errln("Fail: Format empty pattern x 123.456 => " + s);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1169
            s = f.format(-123.456);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1170
            if (!s.equals("-123.456"))
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1171
                errln("Fail: Format empty pattern x -123.456 => " + s);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1172
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1173
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1174
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1175
    /**
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1176
     * BigDecimal numbers get their fractions truncated by NumberFormat.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1177
     */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1178
    public void Test4141750() {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1179
        try {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1180
            String str = "12345.67";
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1181
            BigDecimal bd = new BigDecimal(str);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1182
            NumberFormat nf = NumberFormat.getInstance(Locale.US);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1183
            String sd = nf.format(bd);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1184
            if (!sd.endsWith("67")) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1185
                errln("Fail: " + str + " x format -> " + sd);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1186
            }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1187
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1188
        catch (Exception e) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1189
            errln(e.toString());
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1190
            e.printStackTrace();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1191
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1192
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1193
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1194
    /**
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1195
     * DecimalFormat toPattern() doesn't quote special characters or handle
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1196
     * single quotes.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1197
     */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1198
    public void Test4145457() {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1199
        try {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1200
            DecimalFormat nf = (DecimalFormat)NumberFormat.getInstance();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1201
            DecimalFormatSymbols sym = nf.getDecimalFormatSymbols();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1202
            sym.setDecimalSeparator('\'');
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1203
            nf.setDecimalFormatSymbols(sym);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1204
            double pi = 3.14159;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1205
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1206
            String[] PATS = { "#.00 'num''ber'", "''#.00''" };
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1207
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1208
            for (int i=0; i<PATS.length; ++i) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1209
                nf.applyPattern(PATS[i]);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1210
                String out = nf.format(pi);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1211
                String pat = nf.toPattern();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1212
                double val = nf.parse(out).doubleValue();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1213
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1214
                nf.applyPattern(pat);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1215
                String out2 = nf.format(pi);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1216
                String pat2 = nf.toPattern();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1217
                double val2 = nf.parse(out2).doubleValue();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1218
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1219
                if (!pat.equals(pat2))
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1220
                    errln("Fail with \"" + PATS[i] + "\": Patterns should concur, \"" +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1221
                          pat + "\" vs. \"" + pat2 + "\"");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1222
                else
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1223
                    logln("Ok \"" + PATS[i] + "\" toPattern() -> \"" + pat + '"');
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1224
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1225
                if (val == val2 && out.equals(out2)) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1226
                    logln("Ok " + pi + " x \"" + PATS[i] + "\" -> \"" +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1227
                          out + "\" -> " + val + " -> \"" +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1228
                          out2 + "\" -> " + val2);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1229
                }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1230
                else {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1231
                    errln("Fail " + pi + " x \"" + PATS[i] + "\" -> \"" +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1232
                          out + "\" -> " + val + " -> \"" +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1233
                          out2 + "\" -> " + val2);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1234
                }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1235
            }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1236
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1237
        catch (ParseException e) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1238
            errln("Fail: " + e);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1239
            e.printStackTrace();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1240
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1241
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1242
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1243
    /**
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1244
     * DecimalFormat.applyPattern() sets minimum integer digits incorrectly.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1245
     * CANNOT REPRODUCE
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1246
     * This bug is a duplicate of 4139344, which is a duplicate of 4134300
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1247
     */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1248
    public void Test4147295() {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1249
        DecimalFormat sdf = new DecimalFormat();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1250
        String pattern = "#,###";
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1251
        logln("Applying pattern \"" + pattern + "\"");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1252
        sdf.applyPattern(pattern);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1253
        int minIntDig = sdf.getMinimumIntegerDigits();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1254
        if (minIntDig != 0) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1255
            errln("Test failed");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1256
            errln(" Minimum integer digits : " + minIntDig);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1257
            errln(" new pattern: " + sdf.toPattern());
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1258
        } else {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1259
            logln("Test passed");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1260
            logln(" Minimum integer digits : " + minIntDig);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1261
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1262
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1263
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1264
    /**
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1265
     * DecimalFormat formats -0.0 as +0.0
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1266
     * See also older related bug 4106658, 4106667
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1267
     */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1268
    public void Test4147706() {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1269
        DecimalFormat df = new DecimalFormat("#,##0.0##");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1270
        df.setDecimalFormatSymbols(DecimalFormatSymbols.getInstance(Locale.ENGLISH));
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1271
        double d1 = -0.0;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1272
        double d2 = -0.0001;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1273
        StringBuffer f1 = df.format(d1, new StringBuffer(), new FieldPosition(0));
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1274
        StringBuffer f2 = df.format(d2, new StringBuffer(), new FieldPosition(0));
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1275
        if (!f1.toString().equals("-0.0")) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1276
            errln(d1 + " x \"" + df.toPattern() + "\" is formatted as \"" + f1 + '"');
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1277
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1278
        if (!f2.toString().equals("-0.0")) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1279
            errln(d2 + " x \"" + df.toPattern() + "\" is formatted as \"" + f2 + '"');
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1280
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1281
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1282
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1283
    /**
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1284
     * NumberFormat cannot format Double.MAX_VALUE
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1285
     */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1286
    public void Test4162198() {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1287
        double dbl = Double.MAX_VALUE;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1288
        NumberFormat f = NumberFormat.getInstance();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1289
        f.setMaximumFractionDigits(Integer.MAX_VALUE);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1290
        f.setMaximumIntegerDigits(Integer.MAX_VALUE);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1291
        String s = f.format(dbl);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1292
        logln("The number " + dbl + " formatted to " + s);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1293
        Number n = null;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1294
        try {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1295
            n = f.parse(s);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1296
        } catch (java.text.ParseException e) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1297
            errln("Caught a ParseException:");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1298
            e.printStackTrace();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1299
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1300
        logln("The string " + s + " parsed as " + n);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1301
        if (n.doubleValue() != dbl) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1302
            errln("Round trip failure");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1303
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1304
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1305
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1306
    /**
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1307
     * NumberFormat does not parse negative zero.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1308
     */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1309
    public void Test4162852() throws ParseException {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1310
        for (int i=0; i<2; ++i) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1311
            NumberFormat f = (i == 0) ? NumberFormat.getInstance()
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1312
                : NumberFormat.getPercentInstance();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1313
            double d = -0.0;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1314
            String s = f.format(d);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1315
            double e = f.parse(s).doubleValue();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1316
            logln("" +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1317
                  d + " -> " +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1318
                  '"' + s + '"' + " -> " +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1319
              e);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1320
            if (e != 0.0 || 1.0/e > 0.0) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1321
                logln("Failed to parse negative zero");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1322
            }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1323
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1324
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1325
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1326
    /**
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1327
     * NumberFormat truncates data
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1328
     */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1329
    public void Test4167494() throws Exception {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1330
        NumberFormat fmt = NumberFormat.getInstance(Locale.US);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1331
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1332
        double a = Double.MAX_VALUE;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1333
        String s = fmt.format(a);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1334
        double b = fmt.parse(s).doubleValue();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1335
        boolean match = a == b;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1336
        if (match) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1337
            logln("" + a + " -> \"" + s + "\" -> " + b + " ok");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1338
        } else {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1339
            errln("" + a + " -> \"" + s + "\" -> " + b + " FAIL");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1340
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1341
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1342
        // We don't test Double.MIN_VALUE because the locale data for the US
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1343
        // currently doesn't specify enough digits to display Double.MIN_VALUE.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1344
        // This is correct for now; however, we leave this here as a reminder
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1345
        // in case we want to address this later.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1346
        if (false) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1347
            a = Double.MIN_VALUE;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1348
            s = fmt.format(a);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1349
            b = fmt.parse(s).doubleValue();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1350
            match = a == b;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1351
            if (match) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1352
                logln("" + a + " -> \"" + s + "\" -> " + b + " ok");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1353
            } else {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1354
                errln("" + a + " -> \"" + s + "\" -> " + b + " FAIL");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1355
            }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1356
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1357
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1358
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1359
    /**
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1360
     * DecimalFormat.parse() fails when ParseIntegerOnly set to true
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1361
     */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1362
    public void Test4170798() {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1363
        Locale savedLocale = Locale.getDefault();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1364
        Locale.setDefault(Locale.US);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1365
        DecimalFormat df = new DecimalFormat();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1366
        df.setParseIntegerOnly(true);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1367
        Number n = df.parse("-0.0", new ParsePosition(0));
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1368
        if (!(n instanceof Long || n instanceof Integer)
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1369
            || n.intValue() != 0) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1370
            errln("FAIL: parse(\"-0.0\") returns " +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1371
                  n + " (" + n.getClass().getName() + ')');
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1372
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1373
        Locale.setDefault(savedLocale);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1374
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1375
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1376
    /**
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1377
     * toPattern only puts the first grouping separator in.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1378
     */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1379
    public void Test4176114() {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1380
        String[] DATA = {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1381
            "00", "#00",
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1382
            "000", "#000", // No grouping
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1383
            "#000", "#000", // No grouping
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1384
            "#,##0", "#,##0",
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1385
            "#,000", "#,000",
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1386
            "0,000", "#0,000",
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1387
            "00,000", "#00,000",
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1388
            "000,000", "#,000,000",
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1389
            "0,000,000,000,000.0000", "#0,000,000,000,000.0000", // Reported
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1390
        };
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1391
        for (int i=0; i<DATA.length; i+=2) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1392
            DecimalFormat df = new DecimalFormat(DATA[i]);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1393
            String s = df.toPattern();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1394
            if (!s.equals(DATA[i+1])) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1395
                errln("FAIL: " + DATA[i] + " -> " + s + ", want " + DATA[i+1]);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1396
            }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1397
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1398
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1399
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1400
    /**
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1401
     * DecimalFormat is incorrectly rounding numbers like 1.2501 to 1.2
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1402
     */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1403
    public void Test4179818() {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1404
        String DATA[] = {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1405
            // Input  Pattern  Expected output
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1406
            "1.2511", "#.#",   "1.3",
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1407
            "1.2501", "#.#",   "1.3",
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1408
            "0.9999", "#",     "1",
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1409
        };
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1410
        DecimalFormat fmt = new DecimalFormat("#",
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1411
                DecimalFormatSymbols.getInstance(Locale.US));
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1412
        for (int i=0; i<DATA.length; i+=3) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1413
            double in = Double.valueOf(DATA[i]).doubleValue();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1414
            String pat = DATA[i+1];
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1415
            String exp = DATA[i+2];
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1416
            fmt.applyPattern(pat);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1417
            String out = fmt.format(in);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1418
            if (out.equals(exp)) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1419
                logln("Ok: " + in + " x " + pat + " = " + out);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1420
            } else {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1421
                errln("FAIL: " + in + " x  " + pat + " = " + out +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1422
                      ", expected " + exp);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1423
            }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1424
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1425
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1426
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1427
    public void Test4185761() throws IOException, ClassNotFoundException {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1428
        /* Code used to write out the initial files, which are
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1429
         * then edited manually:
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1430
        NumberFormat nf = NumberFormat.getInstance(Locale.US);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1431
        nf.setMinimumIntegerDigits(0x111); // Keep under 309
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1432
        nf.setMaximumIntegerDigits(0x112); // Keep under 309
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1433
        nf.setMinimumFractionDigits(0x113); // Keep under 340
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1434
        nf.setMaximumFractionDigits(0x114); // Keep under 340
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1435
        FileOutputStream ostream =
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1436
            new FileOutputStream("NumberFormat4185761");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1437
        ObjectOutputStream p = new ObjectOutputStream(ostream);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1438
        p.writeObject(nf);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1439
        ostream.close();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1440
        */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1441
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1442
        // File                 minint maxint minfrac maxfrac
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1443
        // NumberFormat4185761a  0x122  0x121   0x124   0x123
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1444
        // NumberFormat4185761b  0x311  0x312   0x313   0x314
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1445
        // File a is bad because the mins are smaller than the maxes.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1446
        // File b is bad because the values are too big for a DecimalFormat.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1447
        // These files have a sufix ".ser.txt".
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1448
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1449
        InputStream istream = HexDumpReader.getStreamFromHexDump("NumberFormat4185761a.ser.txt");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1450
        ObjectInputStream p = new ObjectInputStream(istream);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1451
        try {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1452
            NumberFormat nf = (NumberFormat) p.readObject();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1453
            errln("FAIL: Deserialized bogus NumberFormat int:" +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1454
                  nf.getMinimumIntegerDigits() + ".." +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1455
                  nf.getMaximumIntegerDigits() + " frac:" +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1456
                  nf.getMinimumFractionDigits() + ".." +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1457
                  nf.getMaximumFractionDigits());
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1458
        } catch (InvalidObjectException e) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1459
            logln("Ok: " + e.getMessage());
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1460
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1461
        istream.close();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1462
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1463
        istream = HexDumpReader.getStreamFromHexDump("NumberFormat4185761b.ser.txt");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1464
        p = new ObjectInputStream(istream);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1465
        try {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1466
            NumberFormat nf = (NumberFormat) p.readObject();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1467
            errln("FAIL: Deserialized bogus DecimalFormat int:" +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1468
                  nf.getMinimumIntegerDigits() + ".." +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1469
                  nf.getMaximumIntegerDigits() + " frac:" +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1470
                  nf.getMinimumFractionDigits() + ".." +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1471
                  nf.getMaximumFractionDigits());
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1472
        } catch (InvalidObjectException e) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1473
            logln("Ok: " + e.getMessage());
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1474
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1475
        istream.close();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1476
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1477
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1478
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1479
    /**
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1480
     * Some DecimalFormatSymbols changes are not picked up by DecimalFormat.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1481
     * This includes the minus sign, currency symbol, international currency
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1482
     * symbol, percent, and permille.  This is filed as bugs 4212072 and
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1483
     * 4212073.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1484
     */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1485
    public void Test4212072() throws IOException, ClassNotFoundException {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1486
        DecimalFormatSymbols sym = DecimalFormatSymbols.getInstance(Locale.US);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1487
        DecimalFormat fmt = new DecimalFormat("#", sym);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1488
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1489
        sym.setMinusSign('^');
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1490
        fmt.setDecimalFormatSymbols(sym);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1491
        if (!fmt.format(-1).equals("^1")) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1492
            errln("FAIL: -1 x (minus=^) -> " + fmt.format(-1) +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1493
                  ", exp ^1");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1494
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1495
        if (!fmt.getNegativePrefix().equals("^")) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1496
            errln("FAIL: (minus=^).getNegativePrefix -> " +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1497
                  fmt.getNegativePrefix() + ", exp ^");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1498
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1499
        sym.setMinusSign('-');
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1500
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1501
        fmt.applyPattern("#%");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1502
        sym.setPercent('^');
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1503
        fmt.setDecimalFormatSymbols(sym);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1504
        if (!fmt.format(0.25).equals("25^")) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1505
            errln("FAIL: 0.25 x (percent=^) -> " + fmt.format(0.25) +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1506
                  ", exp 25^");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1507
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1508
        if (!fmt.getPositiveSuffix().equals("^")) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1509
            errln("FAIL: (percent=^).getPositiveSuffix -> " +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1510
                  fmt.getPositiveSuffix() + ", exp ^");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1511
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1512
        sym.setPercent('%');
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1513
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1514
        fmt.applyPattern("#\u2030");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1515
        sym.setPerMill('^');
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1516
        fmt.setDecimalFormatSymbols(sym);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1517
        if (!fmt.format(0.25).equals("250^")) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1518
            errln("FAIL: 0.25 x (permill=^) -> " + fmt.format(0.25) +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1519
                  ", exp 250^");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1520
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1521
        if (!fmt.getPositiveSuffix().equals("^")) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1522
            errln("FAIL: (permill=^).getPositiveSuffix -> " +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1523
                  fmt.getPositiveSuffix() + ", exp ^");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1524
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1525
        sym.setPerMill('\u2030');
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1526
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1527
        fmt.applyPattern("\u00A4#.00");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1528
        sym.setCurrencySymbol("usd");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1529
        fmt.setDecimalFormatSymbols(sym);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1530
        if (!fmt.format(12.5).equals("usd12.50")) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1531
            errln("FAIL: 12.5 x (currency=usd) -> " + fmt.format(12.5) +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1532
                  ", exp usd12.50");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1533
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1534
        if (!fmt.getPositivePrefix().equals("usd")) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1535
            errln("FAIL: (currency=usd).getPositivePrefix -> " +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1536
                  fmt.getPositivePrefix() + ", exp usd");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1537
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1538
        sym.setCurrencySymbol("$");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1539
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1540
        fmt.applyPattern("\u00A4\u00A4#.00");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1541
        sym.setInternationalCurrencySymbol("DOL");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1542
        fmt.setDecimalFormatSymbols(sym);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1543
        if (!fmt.format(12.5).equals("DOL12.50")) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1544
            errln("FAIL: 12.5 x (intlcurrency=DOL) -> " + fmt.format(12.5) +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1545
                  ", exp DOL12.50");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1546
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1547
        if (!fmt.getPositivePrefix().equals("DOL")) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1548
            errln("FAIL: (intlcurrency=DOL).getPositivePrefix -> " +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1549
                  fmt.getPositivePrefix() + ", exp DOL");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1550
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1551
        sym.setInternationalCurrencySymbol("USD");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1552
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1553
        // Since the pattern logic has changed, make sure that patterns round
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1554
        // trip properly.  Test stream in/out integrity too.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1555
        Locale[] avail = NumberFormat.getAvailableLocales();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1556
        for (int i=0; i<avail.length; ++i) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1557
            for (int j=0; j<3; ++j) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1558
                NumberFormat nf;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1559
                switch (j) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1560
                case 0:
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1561
                    nf = NumberFormat.getInstance(avail[i]);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1562
                    break;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1563
                case 1:
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1564
                    nf = NumberFormat.getCurrencyInstance(avail[i]);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1565
                    break;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1566
                default:
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1567
                    nf = NumberFormat.getPercentInstance(avail[i]);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1568
                    break;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1569
                }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1570
                DecimalFormat df = (DecimalFormat) nf;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1571
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1572
                // Test toPattern/applyPattern round trip
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1573
                String pat = df.toPattern();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1574
                DecimalFormatSymbols symb = DecimalFormatSymbols.getInstance(avail[i]);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1575
                DecimalFormat f2 = new DecimalFormat(pat, symb);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1576
                if (!df.equals(f2)) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1577
                    errln("FAIL: " + avail[i] + " -> \"" + pat +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1578
                          "\" -> \"" + f2.toPattern() + '"');
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1579
                }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1580
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1581
                // Test toLocalizedPattern/applyLocalizedPattern round trip
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1582
                pat = df.toLocalizedPattern();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1583
                f2.applyLocalizedPattern(pat);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1584
                if (!df.equals(f2)) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1585
                    errln("FAIL: " + avail[i] + " -> localized \"" + pat +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1586
                          "\" -> \"" + f2.toPattern() + '"');
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1587
                }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1588
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1589
                // Test writeObject/readObject round trip
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1590
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1591
                ObjectOutputStream oos = new ObjectOutputStream(baos);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1592
                oos.writeObject(df);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1593
                oos.flush();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1594
                baos.close();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1595
                byte[] bytes = baos.toByteArray();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1596
                ObjectInputStream ois =
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1597
                    new ObjectInputStream(new ByteArrayInputStream(bytes));
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1598
                f2 = (DecimalFormat) ois.readObject();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1599
                if (!df.equals(f2)) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1600
                    errln("FAIL: Stream in/out " + avail[i] + " -> \"" + pat +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1601
                          "\" -> " +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1602
                          (f2 != null ? ("\""+f2.toPattern()+'"') : "null"));
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1603
                }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1604
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1605
            }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1606
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1607
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1608
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1609
    /**
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1610
     * DecimalFormat.parse() fails for mulipliers 2^n.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1611
     */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1612
    public void Test4216742() throws ParseException {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1613
        DecimalFormat fmt = (DecimalFormat) NumberFormat.getInstance(Locale.US);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1614
        long[] DATA = { Long.MIN_VALUE, Long.MAX_VALUE, -100000000L, 100000000L};
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1615
        for (int i=0; i<DATA.length; ++i) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1616
            String str = Long.toString(DATA[i]);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1617
            for (int m = 1; m <= 100; m++) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1618
                fmt.setMultiplier(m);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1619
                long n = ((Number) fmt.parse(str)).longValue();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1620
                if (n > 0 != DATA[i] > 0) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1621
                    errln("\"" + str + "\" parse(x " + fmt.getMultiplier() +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1622
                          ") => " + n);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1623
                }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1624
            }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1625
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1626
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1627
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1628
    /**
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1629
     * DecimalFormat formats 1.001 to "1.00" instead of "1" with 2 fraction
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1630
     * digits.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1631
     */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1632
    public void Test4217661() {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1633
        Object[] DATA = {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1634
            new Double(0.001), "0",
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1635
            new Double(1.001), "1",
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1636
            new Double(0.006), "0.01",
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1637
            new Double(1.006), "1.01",
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1638
        };
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1639
        NumberFormat fmt = NumberFormat.getInstance(Locale.US);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1640
        fmt.setMaximumFractionDigits(2);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1641
        for (int i=0; i<DATA.length; i+=2) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1642
            String s = fmt.format(((Double) DATA[i]).doubleValue());
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1643
            if (!s.equals(DATA[i+1])) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1644
                errln("FAIL: Got " + s + ", exp " + DATA[i+1]);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1645
            }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1646
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1647
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1648
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1649
    /**
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1650
     * 4243011: Formatting .5 rounds to "1" instead of "0"
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1651
     */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1652
    public void Test4243011() {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1653
        Locale savedLocale = Locale.getDefault();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1654
        Locale.setDefault(Locale.US);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1655
        double DATA[] = {0.5, 1.5, 2.5, 3.5, 4.5};
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1656
        String EXPECTED[] = {"0.", "2.", "2.", "4.", "4."};
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1657
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1658
        DecimalFormat format = new DecimalFormat("0.");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1659
        for (int i = 0; i < DATA.length; i++) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1660
            String result = format.format(DATA[i]);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1661
            if (result.equals(EXPECTED[i])) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1662
                logln("OK: got " + result);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1663
            } else {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1664
                errln("FAIL: got " + result);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1665
            }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1666
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1667
        Locale.setDefault(savedLocale);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1668
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1669
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1670
    /**
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1671
     * 4243108: format(0.0) gives "0.1" if preceded by parse("99.99")
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1672
     */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1673
    public void Test4243108() {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1674
        Locale savedLocale = Locale.getDefault();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1675
        Locale.setDefault(Locale.US);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1676
        DecimalFormat f = new DecimalFormat("#.#");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1677
        String result = f.format(0.0);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1678
        if (result.equals("0")) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1679
            logln("OK: got " + result);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1680
        } else {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1681
            errln("FAIL: got " + result);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1682
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1683
        try {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1684
            double dResult = f.parse("99.99").doubleValue();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1685
            if (dResult == 99.99) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1686
                logln("OK: got " + dResult);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1687
            } else {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1688
                errln("FAIL: got " + dResult);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1689
            }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1690
        } catch (ParseException e) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1691
            errln("Caught a ParseException:");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1692
            e.printStackTrace();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1693
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1694
        result = f.format(0.0);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1695
        if (result.equals("0")) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1696
            logln("OK: got " + result);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1697
        } else {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1698
            errln("FAIL: got " + result);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1699
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1700
        Locale.setDefault(savedLocale);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1701
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1702
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1703
    /**
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1704
     * 4330377: DecimalFormat engineering notation gives incorrect results
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1705
     */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1706
    public void test4330377() {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1707
        Locale savedLocale = Locale.getDefault();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1708
        Locale.setDefault(Locale.US);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1709
        double[] input = {5000.0, 500.0, 50.0, 5.0, 0.5, 0.05, 0.005, 0.0005,
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1710
               5050.0, 505.0, 50.5, 5.05, 0.505, 0.0505, 0.00505, 0.000505};
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1711
        String[] pattern = {"000.#E0", "##0.#E0", "#00.#E0"};
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1712
        String[][] expected = {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1713
            // it's questionable whether "#00.#E0" should result in post-decimal
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1714
            // zeroes, i.e., whether "5.0E3", "5.0E0", "5.0E-3" are really good
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1715
            {"500E1", "5E3", "5.0E3"},
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1716
            {"500E0", "500E0", "500E0"},
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1717
            {"500E-1", "50E0", "50E0"},
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1718
            {"500E-2", "5E0", "5.0E0"},
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1719
            {"500E-3", "500E-3", "500E-3"},
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1720
            {"500E-4", "50E-3", "50E-3"},
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1721
            {"500E-5", "5E-3", "5.0E-3"},
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1722
            {"500E-6", "500E-6", "500E-6"},
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1723
            {"505E1", "5.05E3", "5.05E3"},
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1724
            {"505E0", "505E0", "505E0"},
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1725
            {"505E-1", "50.5E0", "50.5E0"},
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1726
            {"505E-2", "5.05E0", "5.05E0"},
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1727
            {"505E-3", "505E-3", "505E-3"},
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1728
            {"505E-4", "50.5E-3", "50.5E-3"},
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1729
            {"505E-5", "5.05E-3", "5.05E-3"},
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1730
            {"505E-6", "505E-6", "505E-6"}
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1731
        };
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1732
        for (int i = 0; i < input.length; i++) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1733
            for (int j = 0; j < pattern.length; j++) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1734
                DecimalFormat format = new DecimalFormat(pattern[j]);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1735
                String result = format.format(input[i]);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1736
                if (!result.equals(expected[i][j])) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1737
                    errln("FAIL: input: " + input[i] +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1738
                            ", pattern: " + pattern[j] +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1739
                            ", expected: " + expected[i][j] +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1740
                            ", got: " + result);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1741
                }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1742
            }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1743
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1744
        Locale.setDefault(savedLocale);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1745
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1746
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1747
    /**
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1748
     * 4233840: NumberFormat does not round correctly
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1749
     */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1750
    public void test4233840() {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1751
        float f = 0.0099f;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1752
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1753
        NumberFormat nf = new DecimalFormat("0.##", DecimalFormatSymbols.getInstance(Locale.US));
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1754
        nf.setMinimumFractionDigits(2);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1755
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1756
        String result = nf.format(f);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1757
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1758
        if (!result.equals("0.01")) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1759
            errln("FAIL: input: " + f + ", expected: 0.01, got: " + result);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1760
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1761
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1762
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1763
    /**
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1764
     * 4241880: Decimal format doesnt round a double properly when the number is less than 1
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1765
     */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1766
    public void test4241880() {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1767
        Locale savedLocale = Locale.getDefault();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1768
        Locale.setDefault(Locale.US);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1769
        double[] input = {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1770
                .019, .009, .015, .016, .014,
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1771
                .004, .005, .006, .007, .008,
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1772
                .5, 1.5, .25, .55, .045,
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1773
                .035, .0005, .0015,
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1774
        };
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1775
        String[] pattern = {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1776
                "##0%", "##0%", "##0%", "##0%", "##0%",
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1777
                "##0%", "##0%", "##0%", "##0%", "##0%",
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1778
                "#,##0", "#,##0", "#,##0.0", "#,##0.0", "#,##0.00",
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1779
                "#,##0.00", "#,##0.000", "#,##0.000",
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1780
        };
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1781
        String[] expected = {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1782
                "2%", "1%", "2%", "2%", "1%",
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1783
                "0%", "0%", "1%", "1%", "1%",
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1784
                "0", "2", "0.2", "0.6", "0.04",
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1785
                "0.04", "0.000", "0.002",
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1786
        };
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1787
        for (int i = 0; i < input.length; i++) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1788
            DecimalFormat format = new DecimalFormat(pattern[i]);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1789
            String result = format.format(input[i]);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1790
            if (!result.equals(expected[i])) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1791
                errln("FAIL: input: " + input[i] +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1792
                        ", pattern: " + pattern[i] +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1793
                        ", expected: " + expected[i] +
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1794
                        ", got: " + result);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1795
            }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1796
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1797
        Locale.setDefault(savedLocale);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1798
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1799
}
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1800
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1801
class myformat implements Serializable
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1802
{
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1803
    DateFormat _dateFormat = DateFormat.getDateInstance();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1804
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1805
    public String Now()
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1806
    {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1807
        GregorianCalendar calendar = new GregorianCalendar();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1808
        Date t = calendar.getTime();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1809
        String nowStr = _dateFormat.format(t);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1810
        return nowStr;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1811
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1812
}
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1813
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1814
class MyNumberFormatTest extends NumberFormat {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1815
    public StringBuffer format(double number, StringBuffer toAppendTo, FieldPosition pos) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1816
        return new StringBuffer("");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1817
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1818
    public StringBuffer format(long number,StringBuffer toAppendTo, FieldPosition pos) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1819
        return new StringBuffer("");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1820
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1821
    public Number parse(String text, ParsePosition parsePosition) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1822
        return new Integer(0);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1823
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
  1824
}