Home | History | Annotate | Download | only in intltest
      1 /********************************************************************
      2  * COPYRIGHT:
      3  * Copyright (c) 1997-2008, International Business Machines Corporation and
      4  * others. All Rights Reserved.
      5  ********************************************************************/
      6 
      7 #include "intltest.h"
      8 #include "unicode/locid.h"
      9 
     10 /**
     11  * Tests for the Locale class
     12  **/
     13 class LocaleTest: public IntlTest {
     14 public:
     15     LocaleTest();
     16     virtual ~LocaleTest();
     17 
     18     void runIndexedTest( int32_t index, UBool exec, const char* &name, char* par = NULL );
     19 
     20     /**
     21      * Test methods to set and get data fields
     22      **/
     23     void TestBasicGetters(void);
     24     /**
     25      * Test methods to set and get data fields
     26      **/
     27     void TestParallelAPIValues(void);
     28     /**
     29      * Use Locale to access Resource file data and compare against expected values
     30      **/
     31     void TestSimpleResourceInfo(void);
     32     /**
     33      * Use Locale to access Resource file display names and compare against expected values
     34      **/
     35     void TestDisplayNames(void);
     36     /**
     37      * Test methods for basic object behaviour
     38      **/
     39     void TestSimpleObjectStuff(void);
     40     /**
     41      * Test methods for POSIX parsing behavior
     42      **/
     43     void TestPOSIXParsing(void);
     44     /**
     45      * Test Locale::getAvailableLocales
     46      **/
     47     void TestGetAvailableLocales(void);
     48     /**
     49      * Test methods to set and access a custom data directory
     50      **/
     51     void TestDataDirectory(void);
     52 
     53     void TestISO3Fallback(void);
     54     void TestGetLangsAndCountries(void);
     55     void TestSimpleDisplayNames(void);
     56     void TestUninstalledISO3Names(void);
     57     void TestAtypicalLocales(void);
     58 #if !UCONFIG_NO_FORMATTING
     59     void TestThaiCurrencyFormat(void);
     60     void TestEuroSupport(void);
     61 #endif
     62     void TestToString(void);
     63 #if !UCONFIG_NO_FORMATTING
     64     void Test4139940(void);
     65     void Test4143951(void);
     66 #endif
     67     void Test4147315(void);
     68     void Test4147317(void);
     69     void Test4147552(void);
     70 
     71     void TestVariantParsing(void);
     72 
     73    /* Test getting keyword enumeratin */
     74    void TestKeywordVariants(void);
     75 
     76    /* Test getting keyword values */
     77    void TestKeywordVariantParsing(void);
     78 
     79    /* Test getting the locale base name */
     80    void TestGetBaseName(void);
     81 
     82 #if !UCONFIG_NO_FORMATTING
     83     void Test4105828(void) ;
     84 #endif
     85 
     86     void TestSetIsBogus(void);
     87 
     88     void TestGetLocale(void);
     89 
     90     void TestVariantWithOutCountry(void);
     91 
     92     void TestCanonicalization(void);
     93 
     94 #if !UCONFIG_NO_FORMATTING
     95     static UDate date(int32_t y, int32_t m, int32_t d, int32_t hr = 0, int32_t min = 0, int32_t sec = 0);
     96 #endif
     97 
     98     void TestCurrencyByDate(void);
     99 
    100 private:
    101     void _checklocs(const char* label,
    102                     const char* req,
    103                     const Locale& validLoc,
    104                     const Locale& actualLoc,
    105                     const char* expReqValid="gt",
    106                     const char* expValidActual="ge");
    107 
    108     /**
    109      * routine to perform subtests, used by TestDisplayNames
    110      **/
    111     void doTestDisplayNames(Locale& inLocale, int32_t compareIndex);
    112     /**
    113      * additional intialization for datatables storing expected values
    114      **/
    115     void setUpDataTable(void);
    116 
    117     UnicodeString** dataTable;
    118 
    119     enum {
    120         ENGLISH = 0,
    121         FRENCH = 1,
    122         CROATIAN = 2,
    123         GREEK = 3,
    124         NORWEGIAN = 4,
    125         ITALIAN = 5,
    126         XX = 6,
    127         CHINESE = 7,
    128         MAX_LOCALES = 7
    129     };
    130 
    131     enum {
    132         LANG = 0,
    133         SCRIPT,
    134         CTRY,
    135         VAR,
    136         NAME,
    137         LANG3,
    138         CTRY3,
    139         LCID,
    140         DLANG_EN,
    141         DSCRIPT_EN,
    142         DCTRY_EN,
    143         DVAR_EN,
    144         DNAME_EN,
    145         DLANG_FR,
    146         DSCRIPT_FR,
    147         DCTRY_FR,
    148         DVAR_FR,
    149         DNAME_FR,
    150         DLANG_CA,
    151         DSCRIPT_CA,
    152         DCTRY_CA,
    153         DVAR_CA,
    154         DNAME_CA,
    155         DLANG_EL,
    156         DSCRIPT_EL,
    157         DCTRY_EL,
    158         DVAR_EL,
    159         DNAME_EL,
    160         DLANG_NO,
    161         DSCRIPT_NO,
    162         DCTRY_NO,
    163         DVAR_NO,
    164         DNAME_NO
    165     };
    166 };
    167 
    168 
    169 
    170