1 /*
   2  * Copyright (c) 1998, 2016, 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  * @library /java/text/testlib
  27  * @summary test International Decimal Format Symbols
  28  */
  29 /*
  30 (C) Copyright Taligent, Inc. 1996, 1997 - All Rights Reserved
  31 (C) Copyright IBM Corp. 1996, 1997 - All Rights Reserved
  32 
  33   The original version of this source code and documentation is copyrighted and
  34 owned by Taligent, Inc., a wholly-owned subsidiary of IBM. These materials are
  35 provided under terms of a License Agreement between Taligent and Sun. This
  36 technology is protected by multiple US and International patents. This notice and
  37 attribution to Taligent may not be removed.
  38   Taligent is a registered trademark of Taligent, Inc.
  39 */
  40 
  41 import java.text.*;
  42 import java.util.*;
  43 
  44 public class IntlTestDecimalFormatSymbols extends IntlTest
  45 {
  46     public static void main(String[] args) throws Exception {
  47         new IntlTestDecimalFormatSymbols().run(args);
  48     }
  49 
  50     // Test the API of DecimalFormatSymbols; primarily a simple get/set set.
  51     public void TestSymbols()
  52     {
  53         DecimalFormatSymbols fr = new DecimalFormatSymbols(Locale.FRENCH);
  54 
  55         DecimalFormatSymbols en = new DecimalFormatSymbols(Locale.ENGLISH);
  56 
  57         if(en.equals(fr)) {
  58             errln("ERROR: English DecimalFormatSymbols equal to French");
  59         }
  60 
  61         // just do some VERY basic tests to make sure that get/set work
  62 
  63         char zero = en.getZeroDigit();
  64         fr.setZeroDigit(zero);
  65         if(fr.getZeroDigit() != en.getZeroDigit()) {
  66             errln("ERROR: get/set ZeroDigit failed");
  67         }
  68 
  69         char group = en.getGroupingSeparator();
  70         fr.setGroupingSeparator(group);
  71         if(fr.getGroupingSeparator() != en.getGroupingSeparator()) {
  72             errln("ERROR: get/set GroupingSeparator failed");
  73         }
  74 
  75         char decimal = en.getDecimalSeparator();
  76         fr.setDecimalSeparator(decimal);
  77         if(fr.getDecimalSeparator() != en.getDecimalSeparator()) {
  78             errln("ERROR: get/set DecimalSeparator failed");
  79         }
  80 
  81         char perMill = en.getPerMill();
  82         fr.setPerMill(perMill);
  83         if(fr.getPerMill() != en.getPerMill()) {
  84             errln("ERROR: get/set PerMill failed");
  85         }
  86 
  87         char percent = en.getPercent();
  88         fr.setPercent(percent);
  89         if(fr.getPercent() != en.getPercent()) {
  90             errln("ERROR: get/set Percent failed");
  91         }
  92 
  93         char digit = en.getDigit();
  94         fr.setDigit(digit);
  95         if(fr.getPercent() != en.getPercent()) {
  96             errln("ERROR: get/set Percent failed");
  97         }
  98 
  99         char patternSeparator = en.getPatternSeparator();
 100         fr.setPatternSeparator(patternSeparator);
 101         if(fr.getPatternSeparator() != en.getPatternSeparator()) {
 102             errln("ERROR: get/set PatternSeparator failed");
 103         }
 104 
 105         String infinity = en.getInfinity();
 106         fr.setInfinity(infinity);
 107         String infinity2 = fr.getInfinity();
 108         if(! infinity.equals(infinity2)) {
 109             errln("ERROR: get/set Infinity failed");
 110         }
 111 
 112         String nan = en.getNaN();
 113         fr.setNaN(nan);
 114         String nan2 = fr.getNaN();
 115         if(! nan.equals(nan2)) {
 116             errln("ERROR: get/set NaN failed");
 117         }
 118 
 119         char minusSign = en.getMinusSign();
 120         fr.setMinusSign(minusSign);
 121         if(fr.getMinusSign() != en.getMinusSign()) {
 122             errln("ERROR: get/set MinusSign failed");
 123         }
 124 
 125 //        char exponential = en.getExponentialSymbol();
 126 //        fr.setExponentialSymbol(exponential);
 127 //        if(fr.getExponentialSymbol() != en.getExponentialSymbol()) {
 128 //            errln("ERROR: get/set Exponential failed");
 129 //        }
 130 
 131         DecimalFormatSymbols foo = new DecimalFormatSymbols();
 132 
 133         en = (DecimalFormatSymbols) fr.clone();
 134 
 135         if(! en.equals(fr)) {
 136             errln("ERROR: Clone failed");
 137         }
 138     }
 139 }