ICU-1735 added setBogus and isBogus APIs

X-SVN-Rev: 7810
This commit is contained in:
Vladimir Weinstein 2002-02-28 21:32:28 +00:00
parent 4cd7a296e0
commit b57a64b909
4 changed files with 46 additions and 0 deletions

View File

@ -382,6 +382,7 @@ Locale::operator==( const Locale& other) const
/*This function initializes a Locale from a C locale ID*/
Locale& Locale::init(const char* localeID)
{
fIsBogus = FALSE;
/* Free our current storage */
if(fullName != fullNameBuffer) {
uprv_free(fullName);

View File

@ -626,6 +626,20 @@ public:
*/
int32_t hashCode(void) const;
/**
* Sets the bogus state
* @param isBogus TRUE if bogus, FALSE if normal
* @draft ICU 2.1
*/
void setBogus(UBool isBogus);
/**
* Gets the bogus state. Locale object can be bogus if it doesn't exist
* @return FALSE if it is a real locale, TRUE if it is a bogus locale
* @draft ICU 2.1
*/
UBool isBogus(void) const;
/**
* Returns a list of all installed locales.
* @param count Receives the number of locales in the list.
@ -680,6 +694,8 @@ private:
char* fullName;
char fullNameBuffer[ULOC_FULLNAME_CAPACITY];
UBool fIsBogus;
// static Locale *localeList;
// static int32_t localeListCount;
@ -724,6 +740,17 @@ Locale::getName() const
return fullName;
}
inline void
Locale::setBogus(UBool isBogus) {
fIsBogus = isBogus;
}
inline UBool
Locale::isBogus(void) const {
return fIsBogus;
}
#ifndef ICU_LOCID_USE_DEPRECATES
/* Proxy functions */
inline const char *Locale::LocaleProxy::getLanguage( ) const

View File

@ -183,6 +183,7 @@ void LocaleTest::runIndexedTest( int32_t index, UBool exec, const char* &name, c
CASE(21, Test4147552)
CASE(22, TestVariantParsing)
CASE(23, Test4105828)
CASE(24, TestSetIsBogus)
default: name = ""; break; //needed to end loop
}
@ -1535,3 +1536,18 @@ LocaleTest::Test4105828()
delete fmt;
}
}
// Tests setBogus and isBogus APIs for Locale
// Jitterbug 1735
void
LocaleTest::TestSetIsBogus() {
Locale l("en_US");
l.setBogus(TRUE);
if(l.isBogus() != TRUE) {
errln("After setting bogus, didn't return TRUE");
}
l.setBogus(FALSE);
if(l.isBogus() != FALSE) {
errln("After resetting bogus, didn't return FALSE");
}
}

View File

@ -67,6 +67,8 @@ public:
void Test4105828(void) ;
void TestSetIsBogus(void);
static UDate date(int32_t y, int32_t m, int32_t d, int32_t hr = 0, int32_t min = 0, int32_t sec = 0);
private: