001: /*****************************************************************************************
002: *
003: * Copyright (C) 1996-2005, International Business Machines
004: * Corporation and others. All Rights Reserved.
005: **/
006:
007: /**
008: * Port From: JDK 1.4b1 : java.text.Format.IntlTestDecimalFormatSymbols
009: * Source File: java/text/format/IntlTestDecimalFormatSymbols.java
010: **/package com.ibm.icu.dev.test.format;
011:
012: import com.ibm.icu.text.*;
013: import com.ibm.icu.util.Currency;
014:
015: import java.util.Locale;
016:
017: public class IntlTestDecimalFormatSymbols extends
018: com.ibm.icu.dev.test.TestFmwk {
019: public static void main(String[] args) throws Exception {
020: new IntlTestDecimalFormatSymbols().run(args);
021: }
022:
023: // Test the API of DecimalFormatSymbols; primarily a simple get/set set.
024: public void TestSymbols() {
025: DecimalFormatSymbols fr = new DecimalFormatSymbols(
026: Locale.FRENCH);
027:
028: DecimalFormatSymbols en = new DecimalFormatSymbols(
029: Locale.ENGLISH);
030:
031: if (en.equals(fr)) {
032: errln("ERROR: English DecimalFormatSymbols equal to French");
033: }
034:
035: // just do some VERY basic tests to make sure that get/set work
036:
037: char zero = en.getZeroDigit();
038: fr.setZeroDigit(zero);
039: if (fr.getZeroDigit() != en.getZeroDigit()) {
040: errln("ERROR: get/set ZeroDigit failed");
041: }
042:
043: char sigDigit = en.getSignificantDigit();
044: fr.setSignificantDigit(sigDigit);
045: if (fr.getSignificantDigit() != en.getSignificantDigit()) {
046: errln("ERROR: get/set SignificantDigit failed");
047: }
048:
049: Currency currency = Currency.getInstance("USD");
050: fr.setCurrency(currency);
051: if (!fr.getCurrency().equals(currency)) {
052: errln("ERROR: get/set Currency failed");
053: }
054:
055: char group = en.getGroupingSeparator();
056: fr.setGroupingSeparator(group);
057: if (fr.getGroupingSeparator() != en.getGroupingSeparator()) {
058: errln("ERROR: get/set GroupingSeparator failed");
059: }
060:
061: char decimal = en.getDecimalSeparator();
062: fr.setDecimalSeparator(decimal);
063: if (fr.getDecimalSeparator() != en.getDecimalSeparator()) {
064: errln("ERROR: get/set DecimalSeparator failed");
065: }
066:
067: char perMill = en.getPerMill();
068: fr.setPerMill(perMill);
069: if (fr.getPerMill() != en.getPerMill()) {
070: errln("ERROR: get/set PerMill failed");
071: }
072:
073: char percent = en.getPercent();
074: fr.setPercent(percent);
075: if (fr.getPercent() != en.getPercent()) {
076: errln("ERROR: get/set Percent failed");
077: }
078:
079: char digit = en.getDigit();
080: fr.setDigit(digit);
081: if (fr.getPercent() != en.getPercent()) {
082: errln("ERROR: get/set Percent failed");
083: }
084:
085: char patternSeparator = en.getPatternSeparator();
086: fr.setPatternSeparator(patternSeparator);
087: if (fr.getPatternSeparator() != en.getPatternSeparator()) {
088: errln("ERROR: get/set PatternSeparator failed");
089: }
090:
091: String infinity = en.getInfinity();
092: fr.setInfinity(infinity);
093: String infinity2 = fr.getInfinity();
094: if (!infinity.equals(infinity2)) {
095: errln("ERROR: get/set Infinity failed");
096: }
097:
098: String nan = en.getNaN();
099: fr.setNaN(nan);
100: String nan2 = fr.getNaN();
101: if (!nan.equals(nan2)) {
102: errln("ERROR: get/set NaN failed");
103: }
104:
105: char minusSign = en.getMinusSign();
106: fr.setMinusSign(minusSign);
107: if (fr.getMinusSign() != en.getMinusSign()) {
108: errln("ERROR: get/set MinusSign failed");
109: }
110:
111: char plusSign = en.getPlusSign();
112: fr.setPlusSign(plusSign);
113: if (fr.getPlusSign() != en.getPlusSign()) {
114: errln("ERROR: get/set PlusSign failed");
115: }
116:
117: char padEscape = en.getPadEscape();
118: fr.setPadEscape(padEscape);
119: if (fr.getPadEscape() != en.getPadEscape()) {
120: errln("ERROR: get/set PadEscape failed");
121: }
122:
123: String exponential = en.getExponentSeparator();
124: fr.setExponentSeparator(exponential);
125: if (fr.getExponentSeparator() != en.getExponentSeparator()) {
126: errln("ERROR: get/set Exponential failed");
127: }
128:
129: //DecimalFormatSymbols foo = new DecimalFormatSymbols(); //The variable is never used
130:
131: en = (DecimalFormatSymbols) fr.clone();
132:
133: if (!en.equals(fr)) {
134: errln("ERROR: Clone failed");
135: }
136: }
137:
138: public void testCoverage() {
139: DecimalFormatSymbols df = new DecimalFormatSymbols();
140: DecimalFormatSymbols df2 = (DecimalFormatSymbols) df.clone();
141: if (!df.equals(df2) || df.hashCode() != df2.hashCode()) {
142: errln("decimal format symbols clone, equals, or hashCode failed");
143: }
144: }
145: }
|