mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-07 22:44:49 +00:00
ICU-4051 Remove tabs
X-SVN-Rev: 18457
This commit is contained in:
parent
7dab5ba98b
commit
b9aa59d976
2 changed files with 92 additions and 91 deletions
|
@ -3,30 +3,31 @@
|
|||
* Copyright (c) 2005, International Business Machines Corporation and
|
||||
* others. All Rights Reserved.
|
||||
********************************************************************/
|
||||
|
||||
#include "aliastst.h"
|
||||
#include <unicode/calendar.h>
|
||||
#include <unicode/smpdtfmt.h>
|
||||
#include <unicode/datefmt.h>
|
||||
#include <unicode/unistr.h>
|
||||
#include <unicode/coll.h>
|
||||
#include <unicode/resbund.h>
|
||||
#include "unicode/calendar.h"
|
||||
#include "unicode/smpdtfmt.h"
|
||||
#include "unicode/datefmt.h"
|
||||
#include "unicode/unistr.h"
|
||||
#include "unicode/coll.h"
|
||||
#include "unicode/resbund.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
const char* _LOCALE_ALIAS[][2] = {
|
||||
{"in", "id"},
|
||||
{"in_ID", "id_ID"},
|
||||
{"iw", "he"},
|
||||
{"iw_IL", "he_IL"},
|
||||
{"ji", "yi"},
|
||||
{"en_BU", "en_MM"},
|
||||
{"en_DY", "en_BJ"},
|
||||
{"en_HV", "en_BF"},
|
||||
{"en_NH", "en_VU"},
|
||||
{"en_RH", "en_ZW"},
|
||||
{"en_TP", "en_TL"},
|
||||
{"en_ZR", "en_CD"}
|
||||
{"in", "id"},
|
||||
{"in_ID", "id_ID"},
|
||||
{"iw", "he"},
|
||||
{"iw_IL", "he_IL"},
|
||||
{"ji", "yi"},
|
||||
{"en_BU", "en_MM"},
|
||||
{"en_DY", "en_BJ"},
|
||||
{"en_HV", "en_BF"},
|
||||
{"en_NH", "en_VU"},
|
||||
{"en_RH", "en_ZW"},
|
||||
{"en_TP", "en_TL"},
|
||||
{"en_ZR", "en_CD"}
|
||||
};
|
||||
|
||||
const int _LOCALE_NUMBER = 12;
|
||||
|
@ -54,20 +55,20 @@ void LocaleAliasTest::runIndexedTest( int32_t index, UBool exec, const char* &na
|
|||
|
||||
void LocaleAliasTest::TestCalendar() {
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
for (int i=0; i<_LOCALE_NUMBER; i++) {
|
||||
for (int i=0; i<_LOCALE_NUMBER; i++) {
|
||||
Locale* oldLoc = new Locale(_LOCALE_ALIAS[i][0]);
|
||||
Locale* newLoc = new Locale(_LOCALE_ALIAS[i][1]);
|
||||
if(!isLocaleAvailable(_LOCALE_ALIAS[i][1])){
|
||||
logln(UnicodeString(newLoc->getName())+" is not available. Skipping!");
|
||||
continue;
|
||||
}
|
||||
logln("\nold locale:%s new locale:%s",oldLoc->getName(),newLoc->getName());
|
||||
Calendar* c1 = Calendar::createInstance(*oldLoc, status);
|
||||
Calendar* c2 = Calendar::createInstance(*newLoc, status);
|
||||
logln("\nold locale:%s new locale:%s",oldLoc->getName(),newLoc->getName());
|
||||
Calendar* c1 = Calendar::createInstance(*oldLoc, status);
|
||||
Calendar* c2 = Calendar::createInstance(*newLoc, status);
|
||||
|
||||
//Test function "getLocale(ULocale.VALID_LOCALE)"
|
||||
const char* l1 = c1->getLocaleID(ULOC_VALID_LOCALE, status);
|
||||
const char* l2 = c2->getLocaleID(ULOC_VALID_LOCALE, status);
|
||||
//Test function "getLocale(ULocale.VALID_LOCALE)"
|
||||
const char* l1 = c1->getLocaleID(ULOC_VALID_LOCALE, status);
|
||||
const char* l2 = c2->getLocaleID(ULOC_VALID_LOCALE, status);
|
||||
if (strcmp(newLoc->getName(), l1)!=0) {
|
||||
errln("CalendarTest: newLoc!=l1: newLoc= "+UnicodeString(newLoc->getName()) +" l1= "+UnicodeString(l1));
|
||||
}
|
||||
|
@ -79,7 +80,7 @@ void LocaleAliasTest::TestCalendar() {
|
|||
}
|
||||
logln("Calendar(getLocale) old:"+UnicodeString(l1)+" new:"+UnicodeString(l2));
|
||||
delete c1;
|
||||
delete c2;
|
||||
delete c2;
|
||||
}
|
||||
}
|
||||
void LocaleAliasTest::TestDateFormat() {
|
||||
|
@ -93,9 +94,9 @@ void LocaleAliasTest::TestDateFormat() {
|
|||
}
|
||||
logln("\nold locale:%s new locale:%s",oldLoc->getName(),newLoc->getName());
|
||||
|
||||
DateFormat* df1 = DateFormat::createDateInstance(DateFormat::FULL, *oldLoc);
|
||||
DateFormat* df2 = DateFormat::createDateInstance(DateFormat::FULL, *newLoc);
|
||||
|
||||
DateFormat* df1 = DateFormat::createDateInstance(DateFormat::FULL, *oldLoc);
|
||||
DateFormat* df2 = DateFormat::createDateInstance(DateFormat::FULL, *newLoc);
|
||||
|
||||
//Test function "getLocale"
|
||||
const char* l1 = df1->getLocaleID(ULOC_VALID_LOCALE, status);
|
||||
const char* l2 = df2->getLocaleID(ULOC_VALID_LOCALE, status);
|
||||
|
@ -108,29 +109,29 @@ void LocaleAliasTest::TestDateFormat() {
|
|||
if(!(df1==df2)){
|
||||
errln("TestDateFormat: c1!=c2. newLoc= "+UnicodeString(newLoc->getName()) +" oldLoc= "+UnicodeString(oldLoc->getName()));
|
||||
}
|
||||
logln("DateFormat(getLocale) old:%s new:%s",l1,l2);
|
||||
logln("DateFormat(getLocale) old:%s new:%s",l1,l2);
|
||||
|
||||
delete df1;
|
||||
delete df2;
|
||||
delete df1;
|
||||
delete df2;
|
||||
}
|
||||
}
|
||||
void LocaleAliasTest::TestCollation() {
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
for (int i=0; i<_LOCALE_NUMBER; i++) {
|
||||
for (int i=0; i<_LOCALE_NUMBER; i++) {
|
||||
Locale* oldLoc = new Locale(_LOCALE_ALIAS[i][0]);
|
||||
Locale* newLoc = new Locale(_LOCALE_ALIAS[i][1]);
|
||||
if(!isLocaleAvailable(_LOCALE_ALIAS[i][1])){
|
||||
logln(UnicodeString(newLoc->getName())+" is not available. Skipping!");
|
||||
continue;
|
||||
}
|
||||
logln("\nold locale:%s new locale:%s",oldLoc->getName(),newLoc->getName());
|
||||
logln("\nold locale:%s new locale:%s",oldLoc->getName(),newLoc->getName());
|
||||
|
||||
Collator* c1 = Collator::createInstance(*oldLoc, status);
|
||||
Collator* c2 = Collator::createInstance(*newLoc, status);
|
||||
|
||||
Collator* c1 = Collator::createInstance(*oldLoc, status);
|
||||
Collator* c2 = Collator::createInstance(*newLoc, status);
|
||||
|
||||
Locale l1 = c1->getLocale(ULOC_VALID_LOCALE, status);
|
||||
Locale l2 = c2->getLocale(ULOC_VALID_LOCALE, status);
|
||||
|
||||
|
||||
if (strcmp(newLoc->getName(), l1.getName())!=0) {
|
||||
errln("CalendarTest: newLoc!=l1: newLoc= "+UnicodeString(newLoc->getName()) +" l1= "+UnicodeString(l1.getName()));
|
||||
}
|
||||
|
@ -140,31 +141,31 @@ void LocaleAliasTest::TestCollation() {
|
|||
if(!(c1==c2)){
|
||||
errln("CollationTest: c1!=c2. newLoc= "+UnicodeString(newLoc->getName()) +" oldLoc= "+UnicodeString(oldLoc->getName()));
|
||||
}
|
||||
logln("Collator(getLocale) old:%s new:%s", l1.getName(), l2.getName());
|
||||
delete c1;
|
||||
delete c2;
|
||||
logln("Collator(getLocale) old:%s new:%s", l1.getName(), l2.getName());
|
||||
delete c1;
|
||||
delete c2;
|
||||
}
|
||||
}
|
||||
void LocaleAliasTest::TestULocale() {
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
for (int i=0; i<_LOCALE_NUMBER; i++) {
|
||||
for (int i=0; i<_LOCALE_NUMBER; i++) {
|
||||
Locale* oldLoc = new Locale(_LOCALE_ALIAS[i][0]);
|
||||
Locale* newLoc = new Locale(_LOCALE_ALIAS[i][1]);
|
||||
if(!isLocaleAvailable(_LOCALE_ALIAS[i][1])){
|
||||
logln(UnicodeString(newLoc->getName())+" is not available. Skipping!");
|
||||
continue;
|
||||
}
|
||||
logln("\nold locale:%s new locale:%s",oldLoc->getName(),newLoc->getName());
|
||||
logln("\nold locale:%s new locale:%s",oldLoc->getName(),newLoc->getName());
|
||||
|
||||
UnicodeString name1, name2;
|
||||
oldLoc->getDisplayName(name1);
|
||||
oldLoc->getDisplayName(name1);
|
||||
newLoc->getDisplayName(name2);
|
||||
if (name1!=name2) {
|
||||
}
|
||||
log("ULocale(getDisplayName) old:");
|
||||
log(name1);
|
||||
log(" new:");
|
||||
logln(name2);
|
||||
log("ULocale(getDisplayName) old:");
|
||||
log(name1);
|
||||
log(" new:");
|
||||
logln(name2);
|
||||
}
|
||||
}
|
||||
LocaleAliasTest::LocaleAliasTest(){
|
||||
|
@ -174,13 +175,13 @@ LocaleAliasTest::LocaleAliasTest(){
|
|||
errln("Could not open res_index.res. Exiting. Error: %s\n", u_errorName(status));
|
||||
resIndex=NULL;
|
||||
}
|
||||
defLocale = Locale::getDefault();
|
||||
Locale::setDefault(DEFAULT_LOCALE, status);
|
||||
defLocale = Locale::getDefault();
|
||||
Locale::setDefault(DEFAULT_LOCALE, status);
|
||||
}
|
||||
LocaleAliasTest::~LocaleAliasTest(){
|
||||
/* reset the default locale */
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
Locale::setDefault(defLocale, status);
|
||||
Locale::setDefault(defLocale, status);
|
||||
ures_close(resIndex);
|
||||
if(U_FAILURE(status)){
|
||||
errln("Could not reset the default locale. Exiting. Error: %s\n", u_errorName(status));
|
||||
|
@ -215,7 +216,7 @@ void LocaleAliasTest::TestDisplayName() {
|
|||
const UnicodeString newCountry = newLoc->getDisplayCountry(dipLocName);
|
||||
const UnicodeString oldLang = oldLoc->getDisplayLanguage(dipLocName);
|
||||
const UnicodeString newLang = newLoc->getDisplayLanguage(dipLocName);
|
||||
|
||||
|
||||
// is there display name for the current country ID
|
||||
if(newCountry != newLoc->getCountry()){
|
||||
if(oldCountry!=newCountry){
|
||||
|
@ -232,50 +233,50 @@ void LocaleAliasTest::TestDisplayName() {
|
|||
}
|
||||
}
|
||||
void LocaleAliasTest::TestUResourceBundle() {
|
||||
|
||||
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
for (int i=0; i<_LOCALE_NUMBER; i++) {
|
||||
for (int i=0; i<_LOCALE_NUMBER; i++) {
|
||||
Locale* oldLoc = new Locale(_LOCALE_ALIAS[i][0]);
|
||||
Locale* newLoc = new Locale(_LOCALE_ALIAS[i][1]);
|
||||
if(!isLocaleAvailable(_LOCALE_ALIAS[i][1])){
|
||||
logln(UnicodeString(newLoc->getName())+" is not available. Skipping!");
|
||||
continue;
|
||||
}
|
||||
logln("\nold locale:%s new locale:%s",oldLoc->getName(),newLoc->getName());
|
||||
logln("\nold locale:%s new locale:%s",oldLoc->getName(),newLoc->getName());
|
||||
|
||||
ResourceBundle* rb1 = NULL;
|
||||
ResourceBundle* rb2 = NULL;
|
||||
ResourceBundle* rb1 = NULL;
|
||||
ResourceBundle* rb2 = NULL;
|
||||
|
||||
const char* testdatapath=loadTestData(status);
|
||||
|
||||
UnicodeString us1("NULL");
|
||||
UnicodeString us2("NULL");
|
||||
rb1 = new ResourceBundle(testdatapath, *oldLoc, status);
|
||||
if (U_FAILURE(U_ZERO_ERROR)) {
|
||||
const char* testdatapath=loadTestData(status);
|
||||
|
||||
} else {
|
||||
us1 = rb1->getStringEx("locale", status);
|
||||
}
|
||||
rb2 = new ResourceBundle(testdatapath, *newLoc, status);
|
||||
UnicodeString us1("NULL");
|
||||
UnicodeString us2("NULL");
|
||||
rb1 = new ResourceBundle(testdatapath, *oldLoc, status);
|
||||
if (U_FAILURE(U_ZERO_ERROR)) {
|
||||
|
||||
} else {
|
||||
us1 = rb1->getStringEx("locale", status);
|
||||
}
|
||||
rb2 = new ResourceBundle(testdatapath, *newLoc, status);
|
||||
if (U_FAILURE(U_ZERO_ERROR)){
|
||||
|
||||
} else {
|
||||
us2 = rb2->getStringEx("locale", status);
|
||||
}
|
||||
UnicodeString uNewLoc(newLoc->getName());
|
||||
if (us1.compare(uNewLoc)!=0 || us1.compare(us2)!=0 || status!=U_ZERO_ERROR) {
|
||||
} else {
|
||||
us2 = rb2->getStringEx("locale", status);
|
||||
}
|
||||
UnicodeString uNewLoc(newLoc->getName());
|
||||
if (us1.compare(uNewLoc)!=0 || us1.compare(us2)!=0 || status!=U_ZERO_ERROR) {
|
||||
|
||||
}
|
||||
log("UResourceBundle(getStringEx) old:");
|
||||
log(us1);
|
||||
log(" new:");
|
||||
logln(us2);
|
||||
|
||||
if (rb1!=NULL) {
|
||||
delete rb1;
|
||||
}
|
||||
if (rb2!=NULL) {
|
||||
delete rb2;
|
||||
}
|
||||
}
|
||||
log("UResourceBundle(getStringEx) old:");
|
||||
log(us1);
|
||||
log(" new:");
|
||||
logln(us2);
|
||||
|
||||
if (rb1!=NULL) {
|
||||
delete rb1;
|
||||
}
|
||||
if (rb2!=NULL) {
|
||||
delete rb2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,11 +12,11 @@
|
|||
|
||||
class LocaleAliasTest: public IntlTest {
|
||||
public:
|
||||
void TestCalendar();
|
||||
void TestDateFormat();
|
||||
void TestCollation();
|
||||
void TestULocale();
|
||||
void TestUResourceBundle();
|
||||
void TestCalendar();
|
||||
void TestDateFormat();
|
||||
void TestCollation();
|
||||
void TestULocale();
|
||||
void TestUResourceBundle();
|
||||
void TestDisplayName();
|
||||
void runIndexedTest( int32_t index, UBool exec, const char* &name, char* par = NULL );
|
||||
LocaleAliasTest();
|
||||
|
@ -24,7 +24,7 @@ public:
|
|||
private:
|
||||
UResourceBundle* resIndex;
|
||||
UBool isLocaleAvailable(const char*);
|
||||
Locale defLocale;
|
||||
Locale defLocale;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue