1 /*
  2  * Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved.
  3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  4  *
  5  * This code is free software; you can redistribute it and/or modify it
  6  * under the terms of the GNU General Public License version 2 only, as
  7  * published by the Free Software Foundation.
  8  *
  9  * This code is distributed in the hope that it will be useful, but WITHOUT
 10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  */
 23 
 24 /*
 25  * @test
 26  * @bug 8282625
 27  * @library /java/text/testlib
 28  * @summary test International Decimal Format Symbols
 29  */
 30 /*
 31 (C) Copyright Taligent, Inc. 1996, 1997 - All Rights Reserved
 32 (C) Copyright IBM Corp. 1996, 1997 - All Rights Reserved
 33 
 34   The original version of this source code and documentation is copyrighted and
 35 owned by Taligent, Inc., a wholly-owned subsidiary of IBM. These materials are
 36 provided under terms of a License Agreement between Taligent and Sun. This
 37 technology is protected by multiple US and International patents. This notice and
 38 attribution to Taligent may not be removed.
 39   Taligent is a registered trademark of Taligent, Inc.
 40 */
 41 
 42 import java.text.*;
 43 import java.util.*;
 44 
 45 public class IntlTestDecimalFormatSymbols extends IntlTest
 46 {
 47     public static void main(String[] args) throws Exception {
 48         new IntlTestDecimalFormatSymbols().run(args);
 49     }
 50 
 51     // Test the API of DecimalFormatSymbols; primarily a simple get/set set.
 52     public void TestSymbols()
 53     {
 54         DecimalFormatSymbols fr = new DecimalFormatSymbols(Locale.FRENCH);
 55 
 56         DecimalFormatSymbols en = new DecimalFormatSymbols(Locale.ENGLISH);
 57 
 58         if(en.equals(fr)) {
 59             errln("ERROR: English DecimalFormatSymbols equal to French");
 60         }
 61 
 62         // just do some VERY basic tests to make sure that get/set work
 63 
 64         if (!fr.getLocale().equals(Locale.FRENCH)) {
 65             errln("ERROR: French DecimalFormatSymbols not Locale.FRENCH");
 66         }
 67 
 68         if (!en.getLocale().equals(Locale.ENGLISH)) {
 69             errln("ERROR: English DecimalFormatSymbols not Locale.ENGLISH");
 70         }
 71 
 72         char zero = en.getZeroDigit();
 73         fr.setZeroDigit(zero);
 74         if(fr.getZeroDigit() != en.getZeroDigit()) {
 75             errln("ERROR: get/set ZeroDigit failed");
 76         }
 77 
 78         char group = en.getGroupingSeparator();
 79         fr.setGroupingSeparator(group);
 80         if(fr.getGroupingSeparator() != en.getGroupingSeparator()) {
 81             errln("ERROR: get/set GroupingSeparator failed");
 82         }
 83 
 84         char decimal = en.getDecimalSeparator();
 85         fr.setDecimalSeparator(decimal);
 86         if(fr.getDecimalSeparator() != en.getDecimalSeparator()) {
 87             errln("ERROR: get/set DecimalSeparator failed");
 88         }
 89 
 90         char perMill = en.getPerMill();
 91         fr.setPerMill(perMill);
 92         if(fr.getPerMill() != en.getPerMill()) {
 93             errln("ERROR: get/set PerMill failed");
 94         }
 95 
 96         char percent = en.getPercent();
 97         fr.setPercent(percent);
 98         if(fr.getPercent() != en.getPercent()) {
 99             errln("ERROR: get/set Percent failed");
100         }
101 
102         char digit = en.getDigit();
103         fr.setDigit(digit);
104         if(fr.getPercent() != en.getPercent()) {
105             errln("ERROR: get/set Percent failed");
106         }
107 
108         char patternSeparator = en.getPatternSeparator();
109         fr.setPatternSeparator(patternSeparator);
110         if(fr.getPatternSeparator() != en.getPatternSeparator()) {
111             errln("ERROR: get/set PatternSeparator failed");
112         }
113 
114         String infinity = en.getInfinity();
115         fr.setInfinity(infinity);
116         String infinity2 = fr.getInfinity();
117         if(! infinity.equals(infinity2)) {
118             errln("ERROR: get/set Infinity failed");
119         }
120 
121         String nan = en.getNaN();
122         fr.setNaN(nan);
123         String nan2 = fr.getNaN();
124         if(! nan.equals(nan2)) {
125             errln("ERROR: get/set NaN failed");
126         }
127 
128         char minusSign = en.getMinusSign();
129         fr.setMinusSign(minusSign);
130         if(fr.getMinusSign() != en.getMinusSign()) {
131             errln("ERROR: get/set MinusSign failed");
132         }
133 
134 //        char exponential = en.getExponentialSymbol();
135 //        fr.setExponentialSymbol(exponential);
136 //        if(fr.getExponentialSymbol() != en.getExponentialSymbol()) {
137 //            errln("ERROR: get/set Exponential failed");
138 //        }
139 
140         DecimalFormatSymbols foo = new DecimalFormatSymbols();
141 
142         en = (DecimalFormatSymbols) fr.clone();
143 
144         if(! en.equals(fr)) {
145             errln("ERROR: Clone failed");
146         }
147     }
148 }