!31 修改因icu数据初始化顺序靠后导致的测试用例不通过问题

Merge pull request !31 from 多肉包包与旺旺肉松/2107292227
This commit is contained in:
openharmony_ci 2021-07-30 01:41:08 +00:00 committed by Gitee
commit 080553b38f
4 changed files with 34 additions and 33 deletions

View File

@ -61,7 +61,6 @@ public:
std::string GetFormatMatcher() const;
std::string GetFractionalSecondDigits() const;
private:
static std::map<std::string, icu::DateFormat::EStyle> dateTimeStyle;
std::string localeTag;
std::string dateStyle;
std::string timeStyle;
@ -119,6 +118,7 @@ private:
static bool Init();
static std::set<std::string> allValidLocales;
static std::set<std::string> GetValidLocales();
static std::map<std::string, icu::DateFormat::EStyle> dateTimeStyle;
void ParseConfigsPartOne(std::map<std::string, std::string> &configs);
void ParseConfigsPartTwo(std::map<std::string, std::string> &configs);
void AddOptions(std::string option, char16_t optionChar);

View File

@ -83,6 +83,8 @@ private:
UNumberSignDisplay signDisplay = UNumberSignDisplay::UNUM_SIGN_AUTO;
static const int MAX_UNIT_NUM = 500;
icu::MeasureUnit unitArray[MAX_UNIT_NUM];
static bool icuInitialized;
static bool Init();
static std::map<std::string, UNumberUnitWidth> unitStyle;
static std::map<std::string, UNumberUnitWidth> currencyStyle;
static std::map<std::string, UNumberSignDisplay> signAutoStyle;
@ -94,8 +96,6 @@ private:
void GetDigitsResolvedOptions(std::map<std::string, std::string> &map);
void InitProperties();
void InitDigitsProperties();
static bool icuInitialized;
static bool Init();
};
} // namespace I18n
} // namespace Global

View File

@ -22,6 +22,22 @@ namespace OHOS {
namespace Global {
namespace I18n {
using namespace icu;
bool DateTimeFormat::icuInitialized = DateTimeFormat::Init();
std::set<std::string> DateTimeFormat::allValidLocales = GetValidLocales();
std::set<std::string> DateTimeFormat::GetValidLocales()
{
int32_t validCount = 1;
const Locale *validLocales = Locale::getAvailableLocales(validCount);
std::set<std::string> allValidLocales;
for (int i = 0; i < validCount; i++) {
allValidLocales.insert(validLocales[i].getLanguage());
}
return allValidLocales;
}
std::map<std::string, DateFormat::EStyle> DateTimeFormat::dateTimeStyle = {
{ "full", DateFormat::EStyle::kFull },
{ "long", DateFormat::EStyle::kLong },
@ -48,19 +64,6 @@ DateTimeFormat::DateTimeFormat(std::string localeTag)
dateFormat->setCalendar(*calendar);
}
std::set<std::string> DateTimeFormat::allValidLocales = GetValidLocales();
std::set<std::string> DateTimeFormat::GetValidLocales()
{
int32_t validCount = 1;
const Locale *validLocales = Locale::getAvailableLocales(validCount);
std::set<std::string> allValidLocales;
for (int i = 0; i < validCount; i++) {
allValidLocales.insert(validLocales[i].getLanguage());
}
return allValidLocales;
}
DateTimeFormat::DateTimeFormat(const std::vector<std::string> &localeTags, std::map<std::string, std::string> &configs)
{
UErrorCode status = U_ZERO_ERROR;
@ -330,8 +333,6 @@ void DateTimeFormat::ComputeWeekdayOrEraOfPattern(std::string option, char16_t c
}
}
bool DateTimeFormat::icuInitialized = DateTimeFormat::Init();
std::string DateTimeFormat::Format(int64_t *date)
{
UErrorCode status = U_ZERO_ERROR;

View File

@ -22,6 +22,21 @@ namespace OHOS {
namespace Global {
namespace I18n {
bool NumberFormat::icuInitialized = NumberFormat::Init();
std::set<std::string> NumberFormat::allValidLocales = GetValidLocales();
std::set<std::string> NumberFormat::GetValidLocales()
{
int32_t validCount = 1;
const icu::Locale *validLocales = icu::Locale::getAvailableLocales(validCount);
std::set<std::string> allValidLocales;
for (int i = 0; i < validCount; i++) {
allValidLocales.insert(validLocales[i].getLanguage());
}
return allValidLocales;
}
std::map<std::string, UNumberUnitWidth> NumberFormat::unitStyle = {
{ "long", UNumberUnitWidth::UNUM_UNIT_WIDTH_FULL_NAME },
{ "short", UNumberUnitWidth::UNUM_UNIT_WIDTH_SHORT },
@ -77,19 +92,6 @@ NumberFormat::~NumberFormat()
}
}
std::set<std::string> NumberFormat::allValidLocales = GetValidLocales();
std::set<std::string> NumberFormat::GetValidLocales()
{
int32_t validCount = 1;
const icu::Locale *validLocales = icu::Locale::getAvailableLocales(validCount);
std::set<std::string> allValidLocales;
for (int i = 0; i < validCount; i++) {
allValidLocales.insert(validLocales[i].getLanguage());
}
return allValidLocales;
}
void NumberFormat::InitProperties()
{
if (!currency.empty()) {
@ -229,8 +231,6 @@ void NumberFormat::ParseDigitsConfigs(std::map<std::string, std::string> &config
}
}
bool NumberFormat::icuInitialized = NumberFormat::Init();
std::string NumberFormat::Format(double number)
{
std::string result;