1 /*
  2  * Copyright (c) 1998, 2023, 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  * @summary test International Decimal Format Symbols
 28  * @run junit IntlTestDecimalFormatSymbols
 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 import org.junit.jupiter.api.Test;
 46 
 47 import static org.junit.jupiter.api.Assertions.fail;
 48 
 49 public class IntlTestDecimalFormatSymbols
 50 {
 51     // Test the API of DecimalFormatSymbols; primarily a simple get/set set.
 52     @Test
 53     public void TestSymbols()
 54     {
 55         DecimalFormatSymbols fr = new DecimalFormatSymbols(Locale.FRENCH);
 56 
 57         DecimalFormatSymbols en = new DecimalFormatSymbols(Locale.ENGLISH);
 58 
 59         if(en.equals(fr)) {
 60             fail("ERROR: English DecimalFormatSymbols equal to French");
 61         }
 62 
 63         // just do some VERY basic tests to make sure that get/set work
 64 
 65         if (!fr.getLocale().equals(Locale.FRENCH)) {
 66             fail("ERROR: French DecimalFormatSymbols not Locale.FRENCH");
 67         }
 68 
 69         if (!en.getLocale().equals(Locale.ENGLISH)) {
 70             fail("ERROR: English DecimalFormatSymbols not Locale.ENGLISH");
 71         }
 72 
 73         char zero = en.getZeroDigit();
 74         fr.setZeroDigit(zero);
 75         if(fr.getZeroDigit() != en.getZeroDigit()) {
 76             fail("ERROR: get/set ZeroDigit failed");
 77         }
 78 
 79         char group = en.getGroupingSeparator();
 80         fr.setGroupingSeparator(group);
 81         if(fr.getGroupingSeparator() != en.getGroupingSeparator()) {
 82             fail("ERROR: get/set GroupingSeparator failed");
 83         }
 84 
 85         char decimal = en.getDecimalSeparator();
 86         fr.setDecimalSeparator(decimal);
 87         if(fr.getDecimalSeparator() != en.getDecimalSeparator()) {
 88             fail("ERROR: get/set DecimalSeparator failed");
 89         }
 90 
 91         char perMill = en.getPerMill();
 92         fr.setPerMill(perMill);
 93         if(fr.getPerMill() != en.getPerMill()) {
 94             fail("ERROR: get/set PerMill failed");
 95         }
 96 
 97         char percent = en.getPercent();
 98         fr.setPercent(percent);
 99         if(fr.getPercent() != en.getPercent()) {
100             fail("ERROR: get/set Percent failed");
101         }
102 
103         char digit = en.getDigit();
104         fr.setDigit(digit);
105         if(fr.getPercent() != en.getPercent()) {
106             fail("ERROR: get/set Percent failed");
107         }
108 
109         char patternSeparator = en.getPatternSeparator();
110         fr.setPatternSeparator(patternSeparator);
111         if(fr.getPatternSeparator() != en.getPatternSeparator()) {
112             fail("ERROR: get/set PatternSeparator failed");
113         }
114 
115         String infinity = en.getInfinity();
116         fr.setInfinity(infinity);
117         String infinity2 = fr.getInfinity();
118         if(! infinity.equals(infinity2)) {
119             fail("ERROR: get/set Infinity failed");
120         }
121 
122         String nan = en.getNaN();
123         fr.setNaN(nan);
124         String nan2 = fr.getNaN();
125         if(! nan.equals(nan2)) {
126             fail("ERROR: get/set NaN failed");
127         }
128 
129         char minusSign = en.getMinusSign();
130         fr.setMinusSign(minusSign);
131         if(fr.getMinusSign() != en.getMinusSign()) {
132             fail("ERROR: get/set MinusSign failed");
133         }
134 
135 //        char exponential = en.getExponentialSymbol();
136 //        fr.setExponentialSymbol(exponential);
137 //        if(fr.getExponentialSymbol() != en.getExponentialSymbol()) {
138 //            errln("ERROR: get/set Exponential failed");
139 //        }
140 
141         DecimalFormatSymbols foo = new DecimalFormatSymbols();
142 
143         en = (DecimalFormatSymbols) fr.clone();
144 
145         if(! en.equals(fr)) {
146             fail("ERROR: Clone failed");
147         }
148     }
149 }