Home | History | Annotate | Download | only in tests
      1 //  2016 and later: Unicode, Inc. and others.
      2 // License & terms of use: http://www.unicode.org/copyright.html#License
      3 /*
      4  *******************************************************************************
      5  * Copyright (C) 2006-2011, International Business Machines Corporation and    *
      6  * others. All Rights Reserved.                                                *
      7  *******************************************************************************
      8  */
      9 
     10 package com.ibm.icu.tests;
     11 
     12 import java.util.Locale;
     13 
     14 import com.ibm.icu.text.DecimalFormatSymbols;
     15 import com.ibm.icu.util.ULocale;
     16 
     17 public class DecimalFormatSymbolsTest extends ICUTestCase {
     18 
     19     /*
     20      * Test method for 'com.ibm.icu.text.DecimalFormatSymbols.hashCode()'
     21      */
     22     public void testHashCode() {
     23         DecimalFormatSymbols dfs = new DecimalFormatSymbols(Locale.US);
     24         DecimalFormatSymbols dfs2 = new DecimalFormatSymbols(ULocale.US);
     25         DecimalFormatSymbols dfsn = new DecimalFormatSymbols(Locale.FRANCE);
     26         testEHCS(dfs, dfs2, dfsn);
     27     }
     28 
     29     /*
     30      * Test method for 'com.ibm.icu.text.DecimalFormatSymbols.DecimalFormatSymbols(DecimalFormatSymbols)'
     31      */
     32     public void testDecimalFormatSymbolsDecimalFormatSymbols() {
     33         // implicitly tested everywhere
     34     }
     35 
     36     /*
     37      * Test method for 'com.ibm.icu.text.DecimalFormatSymbols.DecimalFormatSymbols()'
     38      */
     39     public void testDecimalFormatSymbols() {
     40         DecimalFormatSymbols dfs = new DecimalFormatSymbols();
     41         assertTrue(-1 != dfs.getDecimalSeparator());
     42     }
     43 
     44     /*
     45      * Test method for 'com.ibm.icu.text.DecimalFormatSymbols.DecimalFormatSymbols(Locale)'
     46      */
     47     public void testDecimalFormatSymbolsLocale() {
     48         DecimalFormatSymbols dfs = new DecimalFormatSymbols(Locale.US);
     49         assertTrue(-1 != dfs.getDecimalSeparator());
     50     }
     51 
     52     /*
     53      * Test method for 'com.ibm.icu.text.DecimalFormatSymbols.DecimalFormatSymbols(ULocale)'
     54      */
     55     public void testDecimalFormatSymbolsULocale() {
     56         DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
     57         assertTrue(-1 != dfs.getDecimalSeparator());
     58     }
     59 
     60     /*
     61      * Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getZeroDigit()'
     62      */
     63     public void testGetZeroDigit() {
     64         DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
     65         assertEquals('0', dfs.getZeroDigit());
     66     }
     67 
     68     /*
     69      * Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setZeroDigit(char)'
     70      */
     71     public void testSetZeroDigit() {
     72         DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
     73         char value = dfs.getZeroDigit();
     74         char value1 = (char)(value + 1);
     75         dfs.setZeroDigit(value1);
     76         char result = dfs.getZeroDigit();
     77         assertNotEqual(value, result);
     78         assertEquals(value1, result);
     79     }
     80 
     81     /*
     82      * Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getGroupingSeparator()'
     83      */
     84     public void testGetGroupingSeparator() {
     85         DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
     86         assertEquals(',', dfs.getGroupingSeparator());
     87     }
     88 
     89     /*
     90      * Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setGroupingSeparator(char)'
     91      */
     92     public void testSetGroupingSeparator() {
     93         DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
     94         char value = dfs.getGroupingSeparator();
     95         char value1 = (char)(value + 1);
     96         dfs.setGroupingSeparator(value1);
     97         char result = dfs.getGroupingSeparator();
     98         assertNotEqual(value, result);
     99         assertEquals(value1, result);
    100     }
    101 
    102     /*
    103      * Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getDecimalSeparator()'
    104      */
    105     public void testGetDecimalSeparator() {
    106         DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
    107         assertEquals('.', dfs.getDecimalSeparator());
    108     }
    109 
    110     /*
    111      * Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setDecimalSeparator(char)'
    112      */
    113     public void testSetDecimalSeparator() {
    114         DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
    115         char value = dfs.getDecimalSeparator();
    116         char value1 = (char)(value + 1);
    117         dfs.setDecimalSeparator(value1);
    118         char result = dfs.getDecimalSeparator();
    119         assertNotEqual(value, result);
    120         assertEquals(value1, result);
    121     }
    122 
    123     /*
    124      * Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getPerMill()'
    125      */
    126     public void testGetPerMill() {
    127         DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
    128         assertEquals('\u2030', dfs.getPerMill());
    129     }
    130 
    131     /*
    132      * Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setPerMill(char)'
    133      */
    134     public void testSetPerMill() {
    135         DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
    136         char value = dfs.getPerMill();
    137         char value1 = (char)(value + 1);
    138         dfs.setPerMill(value1);
    139         char result = dfs.getPerMill();
    140         assertNotEqual(value, result);
    141         assertEquals(value1, result);
    142     }
    143 
    144     /*
    145      * Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getPercent()'
    146      */
    147     public void testGetPercent() {
    148         DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
    149         assertEquals('%', dfs.getPercent());
    150     }
    151 
    152     /*
    153      * Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setPercent(char)'
    154      */
    155     public void testSetPercent() {
    156         DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
    157         char value = dfs.getPercent();
    158         char value1 = (char)(value + 1);
    159         dfs.setPercent(value1);
    160         char result = dfs.getPercent();
    161         assertNotEqual(value, result);
    162         assertEquals(value1, result);
    163     }
    164 
    165     /*
    166      * Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getDigit()'
    167      */
    168     public void testGetDigit() {
    169         DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
    170         assertEquals('#', dfs.getDigit());
    171     }
    172 
    173     /*
    174      * Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setDigit(char)'
    175      */
    176     public void testSetDigit() {
    177         DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
    178         char value = dfs.getDigit();
    179         char value1 = (char)(value + 1);
    180         dfs.setDigit(value1);
    181         char result = dfs.getDigit();
    182         assertNotEqual(value, result);
    183         assertEquals(value1, result);
    184     }
    185 
    186     /*
    187      * Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getPatternSeparator()'
    188      */
    189     public void testGetPatternSeparator() {
    190         DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
    191         assertEquals(';', dfs.getPatternSeparator());
    192     }
    193 
    194     /*
    195      * Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setPatternSeparator(char)'
    196      */
    197     public void testSetPatternSeparator() {
    198         DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
    199         char value = dfs.getPatternSeparator();
    200         char value1 = (char)(value + 1);
    201         dfs.setPatternSeparator(value1);
    202         char result = dfs.getPatternSeparator();
    203         assertNotEqual(value, result);
    204         assertEquals(value1, result);
    205     }
    206 
    207     /*
    208      * Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getInfinity()'
    209      */
    210     public void testGetInfinity() {
    211         DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
    212         assertEquals("\u221e", dfs.getInfinity());
    213     }
    214 
    215     /*
    216      * Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setInfinity(String)'
    217      */
    218     public void testSetInfinity() {
    219         DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
    220         String value = dfs.getInfinity();
    221         String value1 = value + "!";
    222         dfs.setInfinity(value1);
    223         String result = dfs.getInfinity();
    224         assertNotEqual(value, result);
    225         assertEquals(value1, result);
    226     }
    227 
    228     /*
    229      * Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getNaN()'
    230      */
    231     public void testGetNaN() {
    232         DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
    233         assertNotNull(dfs.getNaN()); // java returns missing character???
    234     }
    235 
    236     /*
    237      * Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setNaN(String)'
    238      */
    239     public void testSetNaN() {
    240         DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
    241         String value = dfs.getNaN();
    242         String value1 = value + "!";
    243         dfs.setNaN(value1);
    244         String result = dfs.getNaN();
    245         assertNotEqual(value, result);
    246         assertEquals(value1, result);
    247     }
    248 
    249     /*
    250      * Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getMinusSign()'
    251      */
    252     public void testGetMinusSign() {
    253         DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
    254         assertEquals('-', dfs.getMinusSign());
    255     }
    256 
    257     /*
    258      * Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setMinusSign(char)'
    259      */
    260     public void testSetMinusSign() {
    261         DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
    262         char value = dfs.getMinusSign();
    263         char value1 = (char)(value + 1);
    264         dfs.setMinusSign(value1);
    265         char result = dfs.getMinusSign();
    266         assertNotEqual(value, result);
    267         assertEquals(value1, result);
    268     }
    269 
    270     /*
    271      * Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getCurrencySymbol()'
    272      */
    273     public void testGetCurrencySymbol() {
    274         DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
    275         assertEquals("$", dfs.getCurrencySymbol());
    276     }
    277 
    278     /*
    279      * Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setCurrencySymbol(String)'
    280      */
    281     public void testSetCurrencySymbol() {
    282         DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
    283         String value = dfs.getCurrencySymbol();
    284         String value1 = value + "!";
    285         dfs.setCurrencySymbol(value1);
    286         String result = dfs.getCurrencySymbol();
    287         assertNotEqual(value, result);
    288         assertEquals(value1, result);
    289     }
    290 
    291     /*
    292      * Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getInternationalCurrencySymbol()'
    293      */
    294     public void testGetInternationalCurrencySymbol() {
    295         DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
    296         assertEquals("USD", dfs.getInternationalCurrencySymbol());
    297     }
    298 
    299     /*
    300      * Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setInternationalCurrencySymbol(String)'
    301      */
    302     public void testSetInternationalCurrencySymbol() {
    303         DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
    304         String value = dfs.getInternationalCurrencySymbol();
    305         String value1 = value + "!";
    306         dfs.setInternationalCurrencySymbol(value1);
    307         String result = dfs.getInternationalCurrencySymbol();
    308         assertNotEqual(value, result);
    309         assertEquals(value1, result);
    310     }
    311 
    312     /*
    313      * Test method for 'com.ibm.icu.text.DecimalFormatSymbols.getMonetaryDecimalSeparator()'
    314      */
    315     public void testGetMonetaryDecimalSeparator() {
    316         DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
    317         assertEquals('.', dfs.getMonetaryDecimalSeparator());
    318     }
    319 
    320     /*
    321      * Test method for 'com.ibm.icu.text.DecimalFormatSymbols.setMonetaryDecimalSeparator(char)'
    322      */
    323     public void testSetMonetaryDecimalSeparator() {
    324         DecimalFormatSymbols dfs = new DecimalFormatSymbols(ULocale.US);
    325         char value = dfs.getMonetaryDecimalSeparator();
    326         char value1 = (char)(value + 1);
    327         dfs.setMonetaryDecimalSeparator(value1);
    328         char result = dfs.getMonetaryDecimalSeparator();
    329         assertNotEqual(value, result);
    330         assertEquals(value1, result);
    331     }
    332 
    333     /*
    334      * Test method for 'com.ibm.icu.text.DecimalFormatSymbols.clone()'
    335      */
    336     public void testClone() {
    337         // tested in testHashcode
    338     }
    339 
    340     /*
    341      * Test method for 'com.ibm.icu.text.DecimalFormatSymbols.equals(Object)'
    342      */
    343     public void testEqualsObject() {
    344         // tested in testHashcode
    345     }
    346 }
    347