• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include <gtest/gtest.h>
17 #include <map>
18 #include <vector>
19 
20 #include "accesstoken_kit.h"
21 #include "character.h"
22 #include "collator.h"
23 #include "date_time_filter.h"
24 #include "date_time_format.h"
25 #include "date_time_rule.h"
26 #include "holiday_manager.h"
27 #include "i18n_break_iterator.h"
28 #include "i18n_calendar.h"
29 #include "i18n_service_ability_client.h"
30 #include "i18n_timezone.h"
31 #include "i18n_types.h"
32 #include "index_util.h"
33 #include "locale_compare.h"
34 #include "locale_config.h"
35 #include "locale_info.h"
36 #include "nativetoken_kit.h"
37 #include "measure_data.h"
38 #include "number_format.h"
39 #include "plural_rules.h"
40 #include "preferred_language.h"
41 #include "regex_rule.h"
42 #include "relative_time_format.h"
43 #include "system_locale_manager.h"
44 #include "taboo_utils.h"
45 #include "taboo.h"
46 #include "token_setproc.h"
47 #include "utils.h"
48 #include "intl_test.h"
49 #include "generate_ics_file.h"
50 #include <unistd.h>
51 #include "zone_offset_transition.h"
52 #include "zone_rules.h"
53 
54 using namespace OHOS::Global::I18n;
55 using testing::ext::TestSize;
56 using namespace std;
57 
58 namespace OHOS {
59 namespace Global {
60 namespace I18n {
61 static const uint64_t SELF_TOKEN_ID = GetSelfTokenID();
62 static constexpr int32_t I18N_UID = 3013;
63 static constexpr int32_t ROOT_UID = 0;
64 
65 string IntlTest::originalLanguage;
66 string IntlTest::originalRegion;
67 string IntlTest::originalLocale;
68 string IntlTest::deviceType;
69 
SetUpTestCase(void)70 void IntlTest::SetUpTestCase(void)
71 {
72     originalLanguage = LocaleConfig::GetSystemLanguage();
73     originalRegion = LocaleConfig::GetSystemRegion();
74     originalLocale = LocaleConfig::GetSystemLocale();
75     LocaleConfig::SetSystemLanguage("zh-Hans");
76     LocaleConfig::SetSystemRegion("CN");
77     LocaleConfig::SetSystemLocale("zh-Hans-CN");
78     IntlTest::deviceType = ReadSystemParameter("const.product.devicetype", LocaleConfig::CONFIG_LEN);
79 }
80 
TearDownTestCase(void)81 void IntlTest::TearDownTestCase(void)
82 {
83     LocaleConfig::SetSystemLanguage(originalLanguage);
84     LocaleConfig::SetSystemRegion(originalRegion);
85     LocaleConfig::SetSystemLocale(originalLocale);
86 }
87 
SetUp(void)88 void IntlTest::SetUp(void)
89 {}
90 
TearDown(void)91 void IntlTest::TearDown(void)
92 {}
93 
RemoveTokenAndPermissions()94 void RemoveTokenAndPermissions()
95 {
96     SetSelfTokenID(SELF_TOKEN_ID);
97     seteuid(ROOT_UID);
98     OHOS::Security::AccessToken::AccessTokenKit::ReloadNativeTokenInfo();
99     seteuid(I18N_UID);
100 }
101 
AddTokenAndPermissions()102 void AddTokenAndPermissions()
103 {
104     const char* i18nPermissions[] = {
105         "ohos.permission.UPDATE_CONFIGURATION"
106     };
107     NativeTokenInfoParams i18nInfoInstance = {
108         .dcapsNum = 0,
109         .permsNum = sizeof(i18nPermissions) / sizeof(i18nPermissions[0]),
110         .aclsNum = 0,
111         .dcaps = nullptr,
112         .perms = i18nPermissions,
113         .acls = nullptr,
114         .aplStr = "system_basic",
115     };
116     i18nInfoInstance.processName = "I18nTest";
117     SetSelfTokenID(GetAccessTokenId(&i18nInfoInstance));
118     seteuid(ROOT_UID);
119     OHOS::Security::AccessToken::AccessTokenKit::ReloadNativeTokenInfo();
120     seteuid(I18N_UID);
121 }
122 
InitTestEnvironment()123 void InitTestEnvironment()
124 {
125     AddTokenAndPermissions();
126     I18nServiceAbilityClient::SetSystemLocale("zh-Hans-CN");
127     RemoveTokenAndPermissions();
128 }
129 
RestoreEnvironment(const std::string & originLocaleTag)130 void RestoreEnvironment(const std::string &originLocaleTag)
131 {
132     AddTokenAndPermissions();
133     I18nServiceAbilityClient::SetSystemLocale(originLocaleTag);
134     RemoveTokenAndPermissions();
135 }
136 
137 /**
138  * @tc.name: IntlFuncTest001
139  * @tc.desc: Test Intl DateTimeFormat.format
140  * @tc.type: FUNC
141  */
142 HWTEST_F(IntlTest, IntlFuncTest001, TestSize.Level1)
143 {
144     string locale = "zh-CN-u-hc-h12";
145     string expects = "公元1970年1月1日星期四 上午8:20:34";
146     vector<string> locales;
147     locales.push_back("jessie");
148     locales.push_back(locale);
149     map<string, string> options = { { "year", "numeric" },
150                                     { "month", "narrow" },
151                                     { "day", "numeric" },
152                                     { "hour", "numeric" },
153                                     { "minute", "2-digit" },
154                                     { "second", "numeric" },
155                                     { "weekday", "long" },
156                                     { "era", "short"} };
157     DateTimeFormat *dateFormat = new (std::nothrow) DateTimeFormat(locales, options);
158     ASSERT_TRUE(dateFormat != nullptr);
159     int64_t milliseconds = 1234567;
160     string out = dateFormat->Format(milliseconds);
161     EXPECT_EQ(out, expects);
162     EXPECT_EQ(dateFormat->GetYear(), "numeric");
163     EXPECT_EQ(dateFormat->GetMonth(), "narrow");
164     EXPECT_EQ(dateFormat->GetDay(), "numeric");
165     EXPECT_EQ(dateFormat->GetHour(), "numeric");
166     EXPECT_EQ(dateFormat->GetMinute(), "2-digit");
167     EXPECT_EQ(dateFormat->GetSecond(), "numeric");
168     EXPECT_EQ(dateFormat->GetWeekday(), "long");
169     EXPECT_EQ(dateFormat->GetEra(), "short");
170     EXPECT_EQ(dateFormat->GetHourCycle(), "h12");
171     delete dateFormat;
172 }
173 
174 /**
175  * @tc.name: IntlFuncTest002
176  * @tc.desc: Test Intl LocaleInfo
177  * @tc.type: FUNC
178  */
179 HWTEST_F(IntlTest, IntlFuncTest002, TestSize.Level0)
180 {
181     string locale = "ja-Jpan-JP-u-ca-japanese-hc-h12-co-emoji";
182     map<string, string> options = { { "hourCycle", "h11" },
183                                     { "numeric", "true" },
184                                     { "numberingSystem", "jpan" } };
185     LocaleInfo *loc = new (std::nothrow) LocaleInfo(locale, options);
186     ASSERT_TRUE(loc != nullptr);
187     EXPECT_EQ(loc->GetLanguage(), "ja");
188     EXPECT_EQ(loc->GetScript(), "Jpan");
189     EXPECT_EQ(loc->GetRegion(), "JP");
190     EXPECT_EQ(loc->GetBaseName(), "ja-Jpan-JP");
191     EXPECT_EQ(loc->GetCalendar(), "japanese");
192     EXPECT_EQ(loc->GetHourCycle(), "h11");
193     EXPECT_EQ(loc->GetNumberingSystem(), "jpan");
194     EXPECT_EQ(loc->Minimize(), "ja-u-hc-h11-nu-jpan-ca-japanese-co-emoji-kn-true");
195     EXPECT_EQ(loc->Maximize(), "ja-Jpan-JP-u-hc-h11-nu-jpan-ca-japanese-co-emoji-kn-true");
196     EXPECT_EQ(loc->GetNumeric(), "true");
197     EXPECT_EQ(loc->GetCaseFirst(), "");
198     delete loc;
199 }
200 
201 /**
202  * @tc.name: IntlFuncTest003
203  * @tc.desc: Test Intl LocaleInfo
204  * @tc.type: FUNC
205  */
206 HWTEST_F(IntlTest, IntlFuncTest003, TestSize.Level1)
207 {
208     string locale = "en-GB";
209     LocaleInfo *loc = new (std::nothrow) LocaleInfo(locale);
210     ASSERT_TRUE(loc != nullptr);
211     string language = "en";
212     string script = "";
213     string region = "GB";
214     string baseName = "en-GB";
215     EXPECT_EQ(loc->GetLanguage(), language);
216     EXPECT_EQ(loc->GetScript(), script);
217     EXPECT_EQ(loc->GetRegion(), region);
218     EXPECT_EQ(loc->GetBaseName(), baseName);
219     locale = "ja-u-hc-h12-nu-Jpan-JP-kf-japanese-co-emoji-kn-true";
220     LocaleInfo *localeInfo = new (std::nothrow) LocaleInfo(locale);
221     EXPECT_EQ(localeInfo->GetBaseName(), "ja");
222     delete localeInfo;
223     delete loc;
224 }
225 
226 /**
227  * @tc.name: IntlFuncTest004
228  * @tc.desc: Test Intl DateTimeFormat.format
229  * @tc.type: FUNC
230  */
231 HWTEST_F(IntlTest, IntlFuncTest004, TestSize.Level1)
232 {
233     string locale = "en-GB";
234     string expects = "2 January 1970, 18:17 – 12 January 1970, 18:20";
235     vector<string> locales;
236     locales.push_back(locale);
237     string dateStyle = "long";
238     string timeStyle = "short";
239     string hourCycle = "h24";
240     string hour12 = "false";
241     map<string, string> options = { { "dateStyle", dateStyle },
242                                     { "hour12", hour12 },
243                                     { "hourCycle", hourCycle },
244                                     { "timeStyle", timeStyle } };
245     DateTimeFormat *dateFormat = new (std::nothrow) DateTimeFormat(locales, options);
246     ASSERT_TRUE(dateFormat != nullptr);
247     int64_t fromMilliseconds = 123456789;
248     int64_t toMilliseconds = 987654321;
249     string out = dateFormat->FormatRange(fromMilliseconds, toMilliseconds);
250     EXPECT_EQ(out, expects);
251     EXPECT_EQ(dateFormat->GetDateStyle(), dateStyle);
252     EXPECT_EQ(dateFormat->GetTimeStyle(), timeStyle);
253     delete dateFormat;
254 }
255 
256 /**
257  * @tc.name: IntlFuncTest005
258  * @tc.desc: Test Intl DateTimeFormat.format
259  * @tc.type: FUNC
260  */
261 HWTEST_F(IntlTest, IntlFuncTest005, TestSize.Level1)
262 {
263     string locale = "ja";
264     string expects = "1970年1月2日金曜日";
265     vector<string> locales;
266     locales.push_back(locale);
267     map<string, string> options = { { "year", "numeric" },
268                                     { "month", "long" },
269                                     { "day", "numeric" },
270                                     { "weekday", "long"} };
271     DateTimeFormat *dateFormat = new (std::nothrow) DateTimeFormat(locales, options);
272     ASSERT_TRUE(dateFormat != nullptr);
273     int64_t milliseconds = 123456789;
274     string out = dateFormat->Format(milliseconds);
275     EXPECT_EQ(out, expects);
276     int64_t fromMilliseconds = 123456789;
277     int64_t toMilliseconds = 987654321;
278     expects = "1970/01/02(金曜日)~1970/01/12(月曜日)";
279     out = dateFormat->FormatRange(fromMilliseconds, toMilliseconds);
280     EXPECT_EQ(out, expects);
281     delete dateFormat;
282 }
283 
284 /**
285  * @tc.name: IntlFuncTest006
286  * @tc.desc: Test Intl NumberFormat.format
287  * @tc.type: FUNC
288  */
289 HWTEST_F(IntlTest, IntlFuncTest006, TestSize.Level1)
290 {
291     string locale = "en-IN";
292     string expects = "+1,23,456.79 euros";
293     vector<string> locales;
294     locales.push_back(locale);
295     string useGrouping = "true";
296     string minimumIntegerDigits = "7";
297     string maximumFractionDigits = "2";
298     string style = "currency";
299     string currency = "EUR";
300     map<string, string> options = { { "useGrouping", useGrouping },
301                                     { "style", style },
302                                     { "currency", currency },
303                                     { "currencyDisplay", "name" },
304                                     { "currencySign", "accounting" },
305                                     { "signDisplay", "always" } };
306     NumberFormat *numFmt = new (std::nothrow) NumberFormat(locales, options);
307     ASSERT_TRUE(numFmt != nullptr);
308     string out = numFmt->Format(123456.789);
309     EXPECT_EQ(out, expects);
310     EXPECT_EQ(numFmt->GetUseGrouping(), useGrouping);
311     EXPECT_EQ(numFmt->GetStyle(), style);
312     EXPECT_EQ(numFmt->GetCurrency(), currency);
313     delete numFmt;
314 }
315 
316 /**
317  * @tc.name: IntlFuncTest007
318  * @tc.desc: Test Intl NumberFormat.format
319  * @tc.type: FUNC
320  */
321 HWTEST_F(IntlTest, IntlFuncTest007, TestSize.Level1)
322 {
323     string locale = "zh-CN";
324     string expects = "0,123,456.79米";
325     vector<string> locales;
326     locales.push_back("ban");
327     locales.push_back(locale);
328     string minimumIntegerDigits = "7";
329     string maximumFractionDigits = "2";
330     string style = "unit";
331     map<string, string> options = { { "style", style },
332                                     { "minimumIntegerDigits", minimumIntegerDigits },
333                                     { "maximumFractionDigits", maximumFractionDigits },
334                                     { "unit", "meter" },
335                                     { "unitDisplay", "long"} };
336     NumberFormat *numFmt = new (std::nothrow) NumberFormat(locales, options);
337     ASSERT_TRUE(numFmt != nullptr);
338     string out = numFmt->Format(123456.789);
339     EXPECT_EQ(out, expects);
340     EXPECT_EQ(numFmt->GetStyle(), style);
341     delete numFmt;
342 }
343 
344 /**
345  * @tc.name: IntlFuncTest008
346  * @tc.desc: Test Intl NumberFormat.format
347  * @tc.type: FUNC
348  */
349 HWTEST_F(IntlTest, IntlFuncTest008, TestSize.Level1)
350 {
351     string locale = "en-CN";
352     string expects = "12,345,678.9%";
353     vector<string> locales;
354     locales.push_back(locale);
355     string minimumIntegerDigits = "7";
356     string maximumFractionDigits = "2";
357     string style = "percent";
358     map<string, string> options = { { "style", style },
359                                     { "minimumIntegerDigits", minimumIntegerDigits },
360                                     { "maximumFractionDigits", maximumFractionDigits } };
361     NumberFormat *numFmt = new (std::nothrow) NumberFormat(locales, options);
362     ASSERT_TRUE(numFmt != nullptr);
363     string out = numFmt->Format(123456.789);
364     EXPECT_EQ(out, expects);
365     EXPECT_EQ(numFmt->GetStyle(), style);
366     delete numFmt;
367 }
368 
369 /**
370  * @tc.name: IntlFuncTest009
371  * @tc.desc: Test Intl NumberFormat.format
372  * @tc.type: FUNC
373  */
374 HWTEST_F(IntlTest, IntlFuncTest009, TestSize.Level1)
375 {
376     string locale = "en-CN";
377     string expects = "0,123,456.79";
378     vector<string> locales;
379     locales.push_back(locale);
380     string minimumIntegerDigits = "7";
381     string maximumFractionDigits = "2";
382     string style = "decimal";
383     map<string, string> options = { { "style", style },
384                                     { "minimumIntegerDigits", minimumIntegerDigits },
385                                     { "maximumFractionDigits", maximumFractionDigits } };
386     NumberFormat *numFmt = new (std::nothrow) NumberFormat(locales, options);
387     ASSERT_TRUE(numFmt != nullptr);
388     string out = numFmt->Format(123456.789);
389     EXPECT_EQ(out, expects);
390     EXPECT_EQ(numFmt->GetStyle(), style);
391     options = { { "style", "unit" },
392                 { "unit", "meter" },
393                 { "currency", "USD" },
394                 { "currencyDisplay", "symbol" },
395                 { "compactDisplay", "long" },
396                 { "useGrouping", "true" },
397                 { "unitUsage", "length-person" },
398                 { "unitDisplay", "long" } };
399     NumberFormat *numFormat = new (std::nothrow) NumberFormat(locales, options);
400     map<string, string> res;
401     numFormat->GetResolvedOptions(res);
402     delete numFormat;
403     delete numFmt;
404 }
405 
406 /**
407  * @tc.name: IntlFuncTest0010
408  * @tc.desc: Test Intl NumberFormat.format
409  * @tc.type: FUNC
410  */
411 HWTEST_F(IntlTest, IntlFuncTest010, TestSize.Level1)
412 {
413     string locale = "en-CN";
414     string expects = "1.234568E5";
415     vector<string> locales;
416     locales.push_back(locale);
417     string style = "decimal";
418     map<string, string> options = { { "style", style },
419                                     { "notation", "scientific" } };
420     NumberFormat *numFmt = new (std::nothrow) NumberFormat(locales, options);
421     ASSERT_TRUE(numFmt != nullptr);
422     string out = numFmt->Format(123456.789);
423     EXPECT_EQ(out, expects);
424     EXPECT_EQ(numFmt->GetStyle(), style);
425     delete numFmt;
426 }
427 
428 /**
429  * @tc.name: IntlFuncTest0011
430  * @tc.desc: Test Intl NumberFormat.format
431  * @tc.type: FUNC
432  */
433 HWTEST_F(IntlTest, IntlFuncTest011, TestSize.Level1)
434 {
435     string locale = "en-CN";
436     string expects = "123 thousand";
437     vector<string> locales;
438     locales.push_back(locale);
439     string style = "decimal";
440     map<string, string> options = { { "style", style },
441                                     { "notation", "compact" },
442                                     { "compactDisplay", "long" } };
443     NumberFormat *numFmt = new (std::nothrow) NumberFormat(locales, options);
444     ASSERT_TRUE(numFmt != nullptr);
445     string out = numFmt->Format(123456.789);
446     EXPECT_EQ(out, expects);
447     EXPECT_EQ(numFmt->GetStyle(), style);
448     delete numFmt;
449 }
450 
451 /**
452  * @tc.name: IntlFuncTest0012
453  * @tc.desc: Test Intl DateTimeFormat
454  * @tc.type: FUNC
455  */
456 HWTEST_F(IntlTest, IntlFuncTest0012, TestSize.Level1)
457 {
458     string locale = "en";
459     map<string, string> options = {
460         { "dateStyle", "short" }
461     };
462     vector<string> locales;
463     locales.push_back(locale);
464     std::string expects = "3/11/82";
465     DateTimeFormat *dateFormat = new (std::nothrow) DateTimeFormat(locales, options);
466     ASSERT_TRUE(dateFormat != nullptr);
467     int64_t milliseconds = 123456789123456;
468     string out = dateFormat->Format(milliseconds);
469     EXPECT_EQ(out, expects);
470     options = {
471         { "dateStyle", "long" },
472         { "hourCycle", "h11" }
473     };
474     DateTimeFormat *dateFormatH11 = new (std::nothrow) DateTimeFormat(locales, options);
475     options.insert({ "hourCycle", "h12" });
476     DateTimeFormat *dateFormatH12 = new (std::nothrow) DateTimeFormat(locales, options);
477     options.insert({ "hourCycle", "h23" });
478     DateTimeFormat *dateFormatH23 = new (std::nothrow) DateTimeFormat(locales, options);
479     options.insert({ "hourCycle", "h24" });
480     DateTimeFormat *dateFormatH24 = new (std::nothrow) DateTimeFormat(locales, options);
481     delete dateFormatH11;
482     delete dateFormatH12;
483     delete dateFormatH23;
484     delete dateFormatH24;
485     locales.clear();
486     std::unique_ptr<DateTimeFormat> dateFormatEmpty = std::make_unique<DateTimeFormat>(locales, options);
487     locales.push_back("@@@&&");
488     options = {
489         { "dateStyle", "long" },
490         { "dayPeriod", "short" }
491     };
492     std::unique_ptr<DateTimeFormat> dateFormatFake = std::make_unique<DateTimeFormat>(locales, options);
493     options.insert({ "dayPeriod", "long" });
494     std::unique_ptr<DateTimeFormat> dateFormatDayPeriod = std::make_unique<DateTimeFormat>(locales, options);
495     options.insert({ "dayPeriod", "narrow" });
496     std::unique_ptr<DateTimeFormat> dateFormatDayPeriod2 = std::make_unique<DateTimeFormat>(locales, options);
497     options.insert({ "dateStyle", "long" });
498     std::unique_ptr<DateTimeFormat> dateFormatFake2 = std::make_unique<DateTimeFormat>(locales, options);
499     delete dateFormat;
500 }
501 
502 /**
503  * @tc.name: IntlFuncTest0013
504  * @tc.desc: Test Intl LocaleInfo
505  * @tc.type: FUNC
506  */
507 HWTEST_F(IntlTest, IntlFuncTest0013, TestSize.Level1)
508 {
509     string locale = "en-CN";
510     vector<string> locales;
511     locales.push_back(locale);
512     map<string, string> options = {};
513     std::string expects = "123,456.789";
514     NumberFormat *numFmt = new (std::nothrow) NumberFormat(locales, options);
515     ASSERT_TRUE(numFmt != nullptr);
516     string out = numFmt->Format(123456.789);
517     EXPECT_EQ(out, expects);
518     delete numFmt;
519 }
520 
521 /**
522  * @tc.name: IntlFuncTest0014
523  * @tc.desc: Test Intl LocaleInfo
524  * @tc.type: FUNC
525  */
526 HWTEST_F(IntlTest, IntlFuncTest0014, TestSize.Level1)
527 {
528     string locale = "zh-CN-u-hc-h12";
529     string expects = "北美太平洋标准时间";
530     vector<string> locales;
531     locales.push_back("jessie");
532     locales.push_back(locale);
533     map<string, string> options = { { "timeZone", "America/Los_Angeles"  }, { "timeZoneName", "long" } };
534     DateTimeFormat *dateFormat = new (std::nothrow) DateTimeFormat(locales, options);
535     ASSERT_TRUE(dateFormat != nullptr);
536     int64_t milliseconds = 123456789;
537     string out = dateFormat->Format(milliseconds);
538     EXPECT_TRUE(out.find(expects) != out.npos);
539     delete dateFormat;
540 }
541 
542 /**
543  * @tc.name: IntlFuncTest0015
544  * @tc.desc: Test Intl LocaleInfo
545  * @tc.type: FUNC
546  */
547 HWTEST_F(IntlTest, IntlFuncTest0015, TestSize.Level1)
548 {
549     string locale = "zh-CN-u-hc-h12";
550     vector<string> locales;
551     locales.push_back("jessie");
552     locales.push_back(locale);
553     map<string, string> options = {
554         { "timeZone", "America/Los_Angeles" },
555         { "timeZoneName", "short" }
556     };
557     DateTimeFormat *dateFormat = new (std::nothrow) DateTimeFormat(locales, options);
558     ASSERT_TRUE(dateFormat != nullptr);
559     EXPECT_EQ(dateFormat->GetTimeZone(), "America/Los_Angeles");
560     EXPECT_EQ(dateFormat->GetTimeZoneName(), "short");
561     delete dateFormat;
562 }
563 
564 /**
565  * @tc.name: IntlFuncTest0016
566  * @tc.desc: Test Intl Collator
567  * @tc.type: FUNC
568  */
569 HWTEST_F(IntlTest, IntlFuncTest0016, TestSize.Level1)
570 {
571     // normal test case
572     vector<string> locales;
573     locales.push_back("en-US");
574     map<string, string> inputOptions;
575     std::unique_ptr<Collator> collator = std::make_unique<Collator>(locales, inputOptions);
576     const string param1 = "abc";
577     const string param2 = "cba";
578     CompareResult result = collator->Compare(param1, param2);
579     EXPECT_EQ(result, CompareResult::SMALLER);
580     vector<string> localeVec;
581     localeVec.push_back("en-US-u-co-$$@");
582     std::unique_ptr<Collator> collatorPtr = std::make_unique<Collator>(localeVec, inputOptions);
583 
584     map<string, string> options;
585     collator->ResolvedOptions(options);
586     EXPECT_EQ(options.size(), 8);
587     map<string, string>::iterator it = options.find("localeMatcher");
588     if (it != options.end()) {
589         EXPECT_EQ(it->second, "best fit");
590     }
591     it = options.find("locale");
592     if (it != options.end()) {
593         EXPECT_EQ(it->second, "en-US");
594     }
595     it = options.find("usage");
596     if (it != options.end()) {
597         EXPECT_EQ(it->second, "sort");
598     }
599     it = options.find("sensitivity");
600     if (it != options.end()) {
601         EXPECT_EQ(it->second, "variant");
602     }
603     it = options.find("ignorePunctuation");
604     if (it != options.end()) {
605         EXPECT_EQ(it->second, "false");
606     }
607     it = options.find("numeric");
608     if (it != options.end()) {
609         EXPECT_EQ(it->second, "false");
610     }
611     it = options.find("caseFirst");
612     if (it != options.end()) {
613         EXPECT_EQ(it->second, "false");
614     }
615     it = options.find("collation");
616     if (it != options.end()) {
617         EXPECT_EQ(it->second, "default");
618     }
619 }
620 
621 /**
622  * @tc.name: IntlFuncTest0017
623  * @tc.desc: Test Intl Collator
624  * @tc.type: FUNC
625  */
626 HWTEST_F(IntlTest, IntlFuncTest0017, TestSize.Level1)
627 {
628     // normal test case
629     vector<string> locales;
630     locales.push_back("zh-Hans");
631     locales.push_back("en-US");
632     map<string, string> inputOptions = {
633         { "localeMatcher", "lookup" },
634         { "usage", "search"},
635         { "sensitivity", "case"},
636         { "ignorePunctuation", "true" },
637         { "collation", "pinyin"},
638         { "numeric", "true"},
639         { "caseFirst", "upper"}
640     };
641     Collator *collator = new Collator(locales, inputOptions);
642     const string param1 = "啊";
643     const string param2 = "播";
644     CompareResult result = collator->Compare(param1, param2);
645     EXPECT_EQ(result, CompareResult::SMALLER);
646     map<string, string> options;
647     collator->ResolvedOptions(options);
648     EXPECT_EQ(options.size(), 8);
649     map<string, string>::iterator it = options.find("localeMatcher");
650     if (it != options.end()) {
651         EXPECT_EQ(it->second, "lookup");
652     }
653     it = options.find("locale");
654     if (it != options.end()) {
655         EXPECT_EQ(it->second, "zh-Hans");
656     }
657     it = options.find("usage");
658     if (it != options.end()) {
659         EXPECT_EQ(it->second, "search");
660     }
661     it = options.find("sensitivity");
662     if (it != options.end()) {
663         EXPECT_EQ(it->second, "case");
664     }
665     delete collator;
666 }
667 
668 /**
669  * @tc.name: IntlFuncTest0018
670  * @tc.desc: Test Intl Collator
671  * @tc.type: FUNC
672  */
673 HWTEST_F(IntlTest, IntlFuncTest0018, TestSize.Level1)
674 {
675     // normal test case
676     vector<string> locales;
677     locales.push_back("zh-Hans-u-co-pinyin");
678     locales.push_back("en-US");
679     map<string, string> inputOptions = {
680         { "ignorePunctuation", "true" },
681         { "collation", "pinyin"},
682         { "numeric", "true"},
683         { "caseFirst", "upper"}
684     };
685     Collator *collator = new Collator(locales, inputOptions);
686     map<string, string> options;
687     collator->ResolvedOptions(options);
688     map<string, string>::iterator it = options.find("ignorePunctuation");
689     if (it != options.end()) {
690         EXPECT_EQ(it->second, "true");
691     }
692     it = options.find("numeric");
693     if (it != options.end()) {
694         EXPECT_EQ(it->second, "true");
695     }
696     it = options.find("caseFirst");
697     if (it != options.end()) {
698         EXPECT_EQ(it->second, "upper");
699     }
700     it = options.find("collation");
701     if (it != options.end()) {
702         EXPECT_EQ(it->second, "pinyin");
703     }
704     inputOptions = {
705         { "sensitivity", "base"},
706         { "caseFirst", "lower"}
707     };
708     Collator *collator2 = new Collator(locales, inputOptions);
709     inputOptions = {
710         { "sensitivity", "accent"},
711         { "caseFirst", "lower"}
712     };
713     Collator *collator3 = new Collator(locales, inputOptions);
714     delete collator;
715     delete collator2;
716     delete collator3;
717 }
718 
719 /**
720  * @tc.name: IntlFuncTest0019
721  * @tc.desc: Test Intl Collator
722  * @tc.type: FUNC
723  */
724 HWTEST_F(IntlTest, IntlFuncTest0019, TestSize.Level1)
725 {
726     // abnormal test case
727     vector<string> locales;
728     locales.push_back("7776@");
729     map<string, string> inputOptions = {
730         { "localeMatcher", "fake value" },
731         { "usage", "fake value"},
732         { "sensitivity", "fake value"},
733         { "ignorePunctuation", "fake value" },
734         { "collation", "fake value"},
735         { "numeric", "fake value"},
736         { "caseFirst", "fake value"},
737         { "fake key", "fake value"}
738     };
739     Collator *collator = new Collator(locales, inputOptions);
740     const string param1 = "abc";
741     const string param2 = "cba";
742     CompareResult result = collator->Compare(param1, param2);
743     EXPECT_EQ(result, CompareResult::SMALLER);
744 
745     map<string, string> options;
746     collator->ResolvedOptions(options);
747     EXPECT_EQ(options.size(), 8);
748     map<string, string>::iterator it = options.find("localeMatcher");
749     if (it != options.end()) {
750         EXPECT_EQ(it->second, "fake value");
751     }
752     std::string systemLocale = LocaleConfig::GetSystemLocale();
753     it = options.find("locale");
754     if (it != options.end()) {
755         EXPECT_EQ(it->second, systemLocale);
756     }
757     it = options.find("usage");
758     if (it != options.end()) {
759         EXPECT_EQ(it->second, "fake value");
760     }
761     it = options.find("sensitivity");
762     if (it != options.end()) {
763         EXPECT_EQ(it->second, "fake value");
764     }
765     delete collator;
766 }
767 
768 /**
769  * @tc.name: IntlFuncTest0020
770  * @tc.desc: Test Intl Collator
771  * @tc.type: FUNC
772  */
773 HWTEST_F(IntlTest, IntlFuncTest0020, TestSize.Level1)
774 {
775     // abnormal test case
776     vector<string> locales;
777     locales.push_back("$$##");
778     map<string, string> inputOptions = {
779         { "ignorePunctuation", "fake value" },
780         { "collation", "fake value"},
781         { "numeric", "fake value"},
782         { "caseFirst", "fake value"},
783         { "fake key", "fake value"}
784     };
785     Collator *collator = new Collator(locales, inputOptions);
786     map<string, string> options;
787     collator->ResolvedOptions(options);
788     map<string, string>::iterator it = options.find("ignorePunctuation");
789     if (it != options.end()) {
790         EXPECT_EQ(it->second, "fake value");
791     }
792     it = options.find("numeric");
793     if (it != options.end()) {
794         EXPECT_EQ(it->second, "fake value");
795     }
796     it = options.find("caseFirst");
797     if (it != options.end()) {
798         EXPECT_EQ(it->second, "fake value");
799     }
800     it = options.find("collation");
801     if (it != options.end()) {
802         EXPECT_EQ(it->second, "default");
803     }
804     delete collator;
805 }
806 
807 /**
808  * @tc.name: IntlFuncTest0021
809  * @tc.desc: Test Intl PluralRules
810  * @tc.type: FUNC
811  */
812 HWTEST_F(IntlTest, IntlFuncTest0021, TestSize.Level1)
813 {
814     // normal test case
815     vector<string> locales;
816     locales.push_back("en-US");
817     map<string, string> options;
818     PluralRules *plurals = new PluralRules(locales, options);
819     string res = plurals->Select(0);
820     EXPECT_EQ(res, "other");
821     res = plurals->Select(1);
822     EXPECT_EQ(res, "one");
823     res = plurals->Select(2);
824     EXPECT_EQ(res, "other");
825     res = plurals->Select(5);
826     EXPECT_EQ(res, "other");
827     res = plurals->Select(20);
828     EXPECT_EQ(res, "other");
829     res = plurals->Select(200);
830     EXPECT_EQ(res, "other");
831     res = plurals->Select(12.34);
832     EXPECT_EQ(res, "other");
833     delete plurals;
834 }
835 
836 /**
837  * @tc.name: IntlFuncTest0022
838  * @tc.desc: Test Intl PluralRules
839  * @tc.type: FUNC
840  */
841 HWTEST_F(IntlTest, IntlFuncTest0022, TestSize.Level1)
842 {
843     // normal test case
844     vector<string> locales;
845     locales.push_back("ar");
846     map<string, string> options;
847     PluralRules *plurals = new PluralRules(locales, options);
848     string res = plurals->Select(0);
849     EXPECT_EQ(res, "zero");
850     res = plurals->Select(1);
851     EXPECT_EQ(res, "one");
852     res = plurals->Select(2);
853     EXPECT_EQ(res, "two");
854     res = plurals->Select(5);
855     EXPECT_EQ(res, "few");
856     res = plurals->Select(20);
857     EXPECT_EQ(res, "many");
858     res = plurals->Select(200);
859     EXPECT_EQ(res, "other");
860     res = plurals->Select(12.34);
861     EXPECT_EQ(res, "other");
862     options = {
863         { "localeMatcher", "best fit" },
864         { "type", "cardinal" },
865         { "minimumIntegerDigits", "1" },
866         { "minimumFractionDigits", "0" },
867         { "maximumFractionDigits", "21" },
868     };
869     PluralRules *pluralRules = new PluralRules(locales, options);
870     delete pluralRules;
871     delete plurals;
872 }
873 
874 /**
875  * @tc.name: IntlFuncTest0023
876  * @tc.desc: Test Intl PluralRules
877  * @tc.type: FUNC
878  */
879 HWTEST_F(IntlTest, IntlFuncTest0023, TestSize.Level1)
880 {
881     // normal test case
882     vector<string> locales;
883     locales.push_back("ar");
884     map<string, string> options = {
885         { "localeMatcher", "best fit" },
886         { "type", "cardinal" },
887         { "minimumIntegerDigits", "1" },
888         { "minimumFractionDigits", "0" },
889         { "maximumFractionDigits", "21" },
890         { "minimumSignificantDigits", "21" },
891         { "maximumSignificantDigits", "21" },
892     };
893     PluralRules *plurals = new PluralRules(locales, options);
894     string res = plurals->Select(0);
895     EXPECT_EQ(res, "zero");
896     res = plurals->Select(1);
897     EXPECT_EQ(res, "one");
898     res = plurals->Select(2);
899     EXPECT_EQ(res, "two");
900     res = plurals->Select(5);
901     EXPECT_EQ(res, "few");
902     res = plurals->Select(20);
903     EXPECT_EQ(res, "many");
904     res = plurals->Select(200);
905     EXPECT_EQ(res, "other");
906     res = plurals->Select(12.34);
907     EXPECT_EQ(res, "other");
908     delete plurals;
909 }
910 
911 /**
912  * @tc.name: IntlFuncTest0024
913  * @tc.desc: Test Intl PluralRules
914  * @tc.type: FUNC
915  */
916 HWTEST_F(IntlTest, IntlFuncTest0024, TestSize.Level1)
917 {
918     // abnormal test cast
919     // normal test case
920     std::string currentSystemLocale = LocaleConfig::GetSystemLocale();
921     InitTestEnvironment();
922     vector<string> locales;
923     locales.push_back("$$$###");
924     map<string, string> options = {
925         { "fake_localeMatcher", "best fit" },
926         { "type", "fake_cardinal" },
927         { "minimumIntegerDigits", "11111" },
928         { "minimumFractionDigits", "-111" },
929         { "maximumFractionDigits", "-111" },
930         { "minimumSignificantDigits", "11111" },
931         { "maximumSignificantDigits", "11111" },
932     };
933     PluralRules *plurals = new PluralRules(locales, options);
934     string res = plurals->Select(0);
935     EXPECT_EQ(res, "other");
936     res = plurals->Select(1);
937     EXPECT_EQ(res, "other");
938     res = plurals->Select(2);
939     EXPECT_EQ(res, "other");
940     res = plurals->Select(5);
941     EXPECT_EQ(res, "other");
942     res = plurals->Select(20);
943     EXPECT_EQ(res, "other");
944     res = plurals->Select(200);
945     EXPECT_EQ(res, "other");
946     res = plurals->Select(12.34);
947     EXPECT_EQ(res, "other");
948     delete plurals;
949     RestoreEnvironment(currentSystemLocale);
950 }
951 
952 /**
953  * @tc.name: IntlFuncTest0025
954  * @tc.desc: Test Intl RelativeTimeFormat
955  * @tc.type: FUNC
956  */
957 HWTEST_F(IntlTest, IntlFuncTest0025, TestSize.Level1)
958 {
959     vector<string> locales;
960     locales.push_back("en-US");
961     map<string, string> options;
962     RelativeTimeFormat *formatter = new RelativeTimeFormat(locales, options);
963 
964     double number = 2022;
965     string unit = "year";
966     string resultOfYear = formatter->Format(number, unit);
967     string fakeUnit = "abc";
968     EXPECT_EQ(formatter->Format(number, fakeUnit), "");
969     vector<vector<string>> timeVector;
970     formatter->FormatToParts(number, unit, timeVector);
971     EXPECT_EQ(timeVector.size(), 5);
972 
973     number = 3;
974     unit = "quarter";
975     std::string resultOfQuarter = formatter->Format(number, unit);
976     formatter->FormatToParts(number, unit, timeVector);
977     EXPECT_EQ(timeVector.size(), 8);
978 
979     number = 11;
980     unit = "month";
981     std::string resultOfMonth = formatter->Format(number, unit);
982     formatter->FormatToParts(number, unit, timeVector);
983     EXPECT_EQ(timeVector.size(), 11);
984 
985     number = 2;
986     unit = "week";
987     std::string resultOfWeek = formatter->Format(number, unit);
988     formatter->FormatToParts(number, unit, timeVector);
989     EXPECT_EQ(timeVector.size(), 14);
990     delete formatter;
991 
992     if (IntlTest::deviceType == "wearable" || IntlTest::deviceType == "liteWearable" ||
993         IntlTest::deviceType == "watch") {
994         EXPECT_EQ(resultOfYear, "in 2,022 yr.");
995         EXPECT_EQ(resultOfQuarter, "in 3 qtrs.");
996         EXPECT_EQ(resultOfMonth, "in 11 mo.");
997         EXPECT_EQ(resultOfWeek, "in 2 wk.");
998     } else if (IntlTest::deviceType == "tablet" || IntlTest::deviceType == "2in1" || IntlTest::deviceType == "tv" ||
999         IntlTest::deviceType == "pc") {
1000         EXPECT_EQ(resultOfYear, "in 2,022 years");
1001         EXPECT_EQ(resultOfQuarter, "in 3 quarters");
1002         EXPECT_EQ(resultOfMonth, "in 11 months");
1003         EXPECT_EQ(resultOfWeek, "in 2 weeks");
1004     } else {
1005         EXPECT_EQ(resultOfYear, "in 2,022 years");
1006         EXPECT_EQ(resultOfQuarter, "in 3 quarters");
1007         EXPECT_EQ(resultOfMonth, "in 11 months");
1008         EXPECT_EQ(resultOfWeek, "in 2 weeks");
1009     }
1010 }
1011 
1012 /**
1013  * @tc.name: IntlFuncTest0026
1014  * @tc.desc: Test Intl RelativeTimeFormat
1015  * @tc.type: FUNC
1016  */
1017 HWTEST_F(IntlTest, IntlFuncTest0026, TestSize.Level1)
1018 {
1019     vector<string> locales;
1020     locales.push_back("en-US");
1021     map<string, string> options;
1022     RelativeTimeFormat *formatter = new RelativeTimeFormat(locales, options);
1023 
1024     double number = 23;
1025     string unit = "hour";
1026     string resultOfHour = formatter->Format(number, unit);
1027     vector<vector<string>> timeVector;
1028     formatter->FormatToParts(number, unit, timeVector);
1029     EXPECT_EQ(timeVector.size(), 3);
1030 
1031     number = 59;
1032     unit = "minute";
1033     std::string resultOfMinute = formatter->Format(number, unit);
1034     formatter->FormatToParts(number, unit, timeVector);
1035     EXPECT_EQ(timeVector.size(), 6);
1036 
1037     number = 1;
1038     unit = "second";
1039     std::string resultOfSecond = formatter->Format(number, unit);
1040     formatter->FormatToParts(number, unit, timeVector);
1041     EXPECT_EQ(timeVector.size(), 9);
1042     string fakeUnit = "abc";
1043     vector<vector<string>> fakeVector;
1044     formatter->FormatToParts(number, fakeUnit, fakeVector);
1045     EXPECT_EQ(fakeVector.size(), 0);
1046 
1047     delete formatter;
1048 
1049     if (IntlTest::deviceType == "wearable" || IntlTest::deviceType == "liteWearable" ||
1050         IntlTest::deviceType == "watch") {
1051         EXPECT_EQ(resultOfHour, "in 23 hr.");
1052         EXPECT_EQ(resultOfMinute, "in 59 min.");
1053         EXPECT_EQ(resultOfSecond, "in 1 sec.");
1054     } else if (IntlTest::deviceType == "tablet" || IntlTest::deviceType == "2in1" || IntlTest::deviceType == "tv" ||
1055         IntlTest::deviceType == "pc") {
1056         EXPECT_EQ(resultOfHour, "in 23 hours");
1057         EXPECT_EQ(resultOfMinute, "in 59 minutes");
1058         EXPECT_EQ(resultOfSecond, "in 1 second");
1059     } else {
1060         EXPECT_EQ(resultOfHour, "in 23 hours");
1061         EXPECT_EQ(resultOfMinute, "in 59 minutes");
1062         EXPECT_EQ(resultOfSecond, "in 1 second");
1063     }
1064 }
1065 
1066 /**
1067  * @tc.name: IntlFuncTest0027
1068  * @tc.desc: Test Intl RelativeTimeFormat
1069  * @tc.type: FUNC
1070  */
1071 HWTEST_F(IntlTest, IntlFuncTest0027, TestSize.Level1)
1072 {
1073     vector<string> locales;
1074     locales.push_back("zh-Hans");
1075     map<string, string> options = {
1076         { "localeMatcher", "best fit" },
1077         { "numeric", "auto" },
1078         { "style", "long" }
1079     };
1080     RelativeTimeFormat *formatter = new RelativeTimeFormat(locales, options);
1081 
1082     double number = 2022;
1083     string unit = "year";
1084     string res = formatter->Format(number, unit);
1085     EXPECT_EQ(res, "2,022年后");
1086     vector<vector<string>> timeVector;
1087     formatter->FormatToParts(number, unit, timeVector);
1088     EXPECT_EQ(timeVector.size(), 4);
1089 
1090     number = 3;
1091     unit = "quarter";
1092     res = formatter->Format(number, unit);
1093     EXPECT_EQ(res, "3个季度后");
1094     formatter->FormatToParts(number, unit, timeVector);
1095     EXPECT_EQ(timeVector.size(), 6);
1096 
1097     number = 11;
1098     unit = "month";
1099     res = formatter->Format(number, unit);
1100     EXPECT_EQ(res, "11个月后");
1101     formatter->FormatToParts(number, unit, timeVector);
1102     EXPECT_EQ(timeVector.size(), 8);
1103 
1104     number = 2;
1105     unit = "week";
1106     res = formatter->Format(number, unit);
1107     EXPECT_EQ(res, "2周后");
1108     formatter->FormatToParts(number, unit, timeVector);
1109     EXPECT_EQ(timeVector.size(), 10);
1110     delete formatter;
1111     locales.clear();
1112     locales.push_back("##$$");
1113     RelativeTimeFormat *fmt = new RelativeTimeFormat(locales, options);
1114     delete fmt;
1115 }
1116 
1117 /**
1118  * @tc.name: IntlFuncTest0028
1119  * @tc.desc: Test Intl RelativeTimeFormat
1120  * @tc.type: FUNC
1121  */
1122 HWTEST_F(IntlTest, IntlFuncTest0028, TestSize.Level1)
1123 {
1124     vector<string> locales;
1125     locales.push_back("zh-Hans");
1126     map<string, string> options = {
1127         { "localeMatcher", "lookup" },
1128         { "numeric", "auto" },
1129         { "style", "long" }
1130     };
1131     RelativeTimeFormat *formatter = new RelativeTimeFormat(locales, options);
1132 
1133     double number = 18;
1134     string unit = "day";
1135     string res = formatter->Format(number, unit);
1136     EXPECT_EQ(res, "18天后");
1137     vector<vector<string>> timeVector;
1138     formatter->FormatToParts(number, unit, timeVector);
1139     EXPECT_EQ(timeVector.size(), 2);
1140 
1141     number = 23;
1142     unit = "hour";
1143     res = formatter->Format(number, unit);
1144     EXPECT_EQ(res, "23小时后");
1145     formatter->FormatToParts(number, unit, timeVector);
1146     EXPECT_EQ(timeVector.size(), 4);
1147 
1148     number = 59;
1149     unit = "minute";
1150     res = formatter->Format(number, unit);
1151     EXPECT_EQ(res, "59分钟后");
1152     formatter->FormatToParts(number, unit, timeVector);
1153     EXPECT_EQ(timeVector.size(), 6);
1154 
1155     number = 1;
1156     unit = "second";
1157     res = formatter->Format(number, unit);
1158     EXPECT_EQ(res, "1秒钟后");
1159     formatter->FormatToParts(number, unit, timeVector);
1160     EXPECT_EQ(timeVector.size(), 8);
1161 
1162     delete formatter;
1163 }
1164 
1165 /**
1166  * @tc.name: IntlFuncTest0029
1167  * @tc.desc: Test Intl RelativeTimeFormat
1168  * @tc.type: FUNC
1169  */
1170 HWTEST_F(IntlTest, IntlFuncTest0029, TestSize.Level1)
1171 {
1172     vector<string> locales;
1173     locales.push_back("####");
1174     locales.push_back("zh-Hans-u-nu-latn");
1175     map<string, string> options = {
1176         { "localeMatcher", "best fit" },
1177         { "numeric", "auto" },
1178         { "style", "long" }
1179     };
1180     RelativeTimeFormat *formatter = new RelativeTimeFormat(locales, options);
1181     map<string, string> res;
1182     formatter->GetResolvedOptions(res);
1183     EXPECT_EQ(res.size(), 4);
1184 
1185     map<string, string>::iterator it = res.find("locale");
1186     if (it != res.end()) {
1187         EXPECT_EQ(it->second, "zh-Hans");
1188     }
1189     it = res.find("style");
1190     if (it != res.end()) {
1191         EXPECT_EQ(it->second, "long");
1192     }
1193     it = res.find("numeric");
1194     if (it != res.end()) {
1195         EXPECT_EQ(it->second, "auto");
1196     }
1197     it = res.find("numberingSystem");
1198     if (it != res.end()) {
1199         EXPECT_EQ(it->second, "latn");
1200     }
1201     delete formatter;
1202 }
1203 
1204 /**
1205  * @tc.name: IntlFuncTest0030
1206  * @tc.desc: Test Intl NumberFormat
1207  * @tc.type: FUNC
1208  */
1209 HWTEST_F(IntlTest, IntlFuncTest0030, TestSize.Level1)
1210 {
1211     vector<string> locales;
1212     locales.push_back("en-US");
1213     map<string, string> options = {
1214         { "unitUsage", "default" }
1215     };
1216     NumberFormat *formatter = new NumberFormat(locales, options);
1217 
1218     string res = formatter->Format(123);
1219     EXPECT_EQ(res, "123");
1220     res = formatter->Format(123.456);
1221     EXPECT_EQ(res, "123.456");
1222     locales.clear();
1223     locales.push_back("$$@@");
1224     NumberFormat *formatter2 = new NumberFormat(locales, options);
1225     string res2 = formatter2->Format(123);
1226     EXPECT_EQ(res2, "123");
1227     delete formatter;
1228     delete formatter2;
1229 }
1230 
1231 /**
1232  * @tc.name: IntlFuncTest0031
1233  * @tc.desc: Test Intl NumberFormat
1234  * @tc.type: FUNC
1235  */
1236 HWTEST_F(IntlTest, IntlFuncTest0031, TestSize.Level1)
1237 {
1238     vector<string> locales;
1239     locales.push_back("zh-Hans");
1240     map<string, string> options = {
1241         { "locale", "zh-Hans" },
1242         { "currency", "EUR" },
1243         { "currencySign", "narrowSymbol" },
1244         { "currencyDisplay", "symbol" },
1245         { "unit", "meter" },
1246         { "unitDisplay", "long" },
1247         { "unitUsage", "length-person" },
1248         { "signDisplay", "always" },
1249         { "compactDisplay", "long" },
1250         { "notation", "standard" },
1251         { "localeMatcher", "lookup" },
1252         { "style", "decimal" },
1253         { "numberingSystem", "latn" },
1254         { "useGroup", "true" },
1255         { "minimumIntegerDigits", "1" },
1256         { "minimumFractionDigits", "0" },
1257         { "maximumFractionDigits", "20" },
1258         { "minimumSignificantDigits", "1" },
1259         { "maximumSignificantDigits", "20" }
1260     };
1261     NumberFormat *formatter = new NumberFormat(locales, options);
1262 
1263     string formatRes = formatter->Format(123);
1264     EXPECT_EQ(formatRes, "+123");
1265     formatRes = formatter->Format(123.456);
1266     EXPECT_EQ(formatRes, "+123.456");
1267 
1268     map<string, string> res;
1269     formatter->GetResolvedOptions(res);
1270     EXPECT_EQ(res.size(), 12);
1271     map<string, string>::iterator it = res.find("locale");
1272     if (it != res.end()) {
1273         EXPECT_EQ(it->second, "zh-Hans");
1274     }
1275     it = res.find("signDisplay");
1276     if (it != res.end()) {
1277         EXPECT_EQ(it->second, "always");
1278     }
1279     it = res.find("notation");
1280     if (it != res.end()) {
1281         EXPECT_EQ(it->second, "standard");
1282     }
1283     delete formatter;
1284 }
1285 
1286 /**
1287  * @tc.name: IntlFuncTest0032
1288  * @tc.desc: Test Intl NumberFormat
1289  * @tc.type: FUNC
1290  */
1291 HWTEST_F(IntlTest, IntlFuncTest0032, TestSize.Level1)
1292 {
1293     vector<string> locales;
1294     locales.push_back("zh-Hans");
1295     map<string, string> options = {
1296         { "locale", "zh-Hans" },
1297         { "currency", "CNY" },
1298         { "currencySign", "symbol" },
1299         { "currencyDisplay", "symbol" },
1300         { "unit", "meter" },
1301         { "unitDisplay", "long" },
1302         { "unitUsage", "length-person" },
1303         { "signDisplay", "always" },
1304         { "compactDisplay", "long" },
1305         { "notation", "standard" },
1306         { "localeMatcher", "best fit" },
1307         { "style", "decimal" },
1308         { "numberingSystem", "latn" },
1309         { "useGroup", "true" },
1310         { "minimumIntegerDigits", "1" },
1311         { "minimumFractionDigits", "0" },
1312         { "maximumFractionDigits", "21" },
1313         { "minimumSignificantDigits", "1" },
1314         { "maximumSignificantDigits", "21" }
1315     };
1316     NumberFormat *formatter = new NumberFormat(locales, options);
1317     map<string, string> res;
1318     formatter->GetResolvedOptions(res);
1319     map<string, string>::iterator it = res.find("style");
1320     if (it != res.end()) {
1321         EXPECT_EQ(it->second, "decimal");
1322     }
1323     it = res.find("numberingSystem");
1324     if (it != res.end()) {
1325         EXPECT_EQ(it->second, "latn");
1326     }
1327     it = res.find("useGrouping");
1328     if (it != res.end()) {
1329         EXPECT_EQ(it->second, "true");
1330     }
1331     it = res.find("minimumIntegerDigits");
1332     if (it != res.end()) {
1333         EXPECT_EQ(it->second, "1");
1334     }
1335     it = res.find("minimumFractionDigits");
1336     if (it != res.end()) {
1337         EXPECT_EQ(it->second, "0");
1338     }
1339     delete formatter;
1340 }
1341 
1342 /**
1343  * @tc.name: IntlFuncTest0033
1344  * @tc.desc: Test Intl NumberFormat
1345  * @tc.type: FUNC
1346  */
1347 HWTEST_F(IntlTest, IntlFuncTest0033, TestSize.Level1)
1348 {
1349     vector<string> locales;
1350     locales.push_back("zh-Hans");
1351     map<string, string> options = {
1352         { "locale", "@@##" },
1353         { "currency", "fake currency" },
1354         { "currencySign", "fake sign" },
1355         { "currencyDisplay", "symbol" },
1356         { "unit", "meter" },
1357         { "unitDisplay", "fake value" },
1358         { "unitUsage", "length-person" },
1359         { "signDisplay", "always" },
1360         { "compactDisplay", "long" },
1361         { "notation", "fake value" },
1362         { "localeMatcher", "best fit" },
1363         { "style", "decimal" },
1364         { "numberingSystem", "latn" },
1365         { "useGroup", "fake value" },
1366         { "minimumIntegerDigits", "1" },
1367         { "minimumFractionDigits", "0" },
1368         { "maximumFractionDigits", "21" },
1369         { "minimumSignificantDigits", "1" },
1370         { "maximumSignificantDigits", "21" }
1371     };
1372     NumberFormat *formatter = new NumberFormat(locales, options);
1373     map<string, string> res;
1374     formatter->GetResolvedOptions(res);
1375     map<string, string>::iterator it = res.find("maximumFractionDigits");
1376     if (it != res.end()) {
1377         EXPECT_EQ(it->second, "21");
1378     }
1379     it = res.find("minimumSignificantDigits");
1380     if (it != res.end()) {
1381         EXPECT_EQ(it->second, "1");
1382     }
1383     it = res.find("maximumSignificantDigits");
1384     if (it != res.end()) {
1385         EXPECT_EQ(it->second, "21");
1386     }
1387     delete formatter;
1388 }
1389 
1390 /**
1391  * @tc.name: IntlFuncTest0034
1392  * @tc.desc: Test Intl NumberFormat
1393  * @tc.type: FUNC
1394  */
1395 HWTEST_F(IntlTest, IntlFuncTest0034, TestSize.Level1)
1396 {
1397     vector<string> locales;
1398     locales.push_back("en-US");
1399     map<string, string> options = {
1400         { "locale", "$$$##43" },
1401         { "currency", "USD" },
1402         { "currencySign", "symbol" },
1403         { "currencyDisplay", "symbol" },
1404         { "unit", "fake unit" },
1405         { "unitDisplay", "long" },
1406         { "unitUsage", "fake usage" },
1407         { "signDisplay", "always" },
1408         { "compactDisplay", "long" },
1409         { "notation", "standard" },
1410         { "localeMatcher", "lookup" },
1411         { "style", "currency" },
1412         { "numberingSystem", "latn" },
1413         { "useGrouping", "true" },
1414         { "minimumIntegerDigits", "1" },
1415         { "minimumFractionDigits", "0" },
1416         { "maximumFractionDigits", "20" },
1417         { "minimumSignificantDigits", "1" },
1418         { "maximumSignificantDigits", "20" }
1419     };
1420     NumberFormat *formatter = new NumberFormat(locales, options);
1421     string res = formatter->Format(123);
1422     EXPECT_EQ(res, "+$123");
1423     res = formatter->Format(123.456);
1424     EXPECT_EQ(res, "+$123.456");
1425     res = formatter->GetCurrency();
1426     EXPECT_EQ(res, "USD");
1427     res = formatter->GetCurrencySign();
1428     EXPECT_EQ(res, "symbol");
1429     res = formatter->GetStyle();
1430     EXPECT_EQ(res, "currency");
1431     res = formatter->GetNumberingSystem();
1432     EXPECT_EQ(res, "latn");
1433     delete formatter;
1434 }
1435 
1436 /**
1437  * @tc.name: IntlFuncTest0035
1438  * @tc.desc: Test Intl NumberFormat
1439  * @tc.type: FUNC
1440  */
1441 HWTEST_F(IntlTest, IntlFuncTest0035, TestSize.Level1)
1442 {
1443     vector<string> locales;
1444     locales.push_back("en-US");
1445     map<string, string> options = {
1446         { "locale", "fake locale" },
1447         { "currency", "USD" },
1448         { "currencySign", "fake sign" },
1449         { "currencyDisplay", "symbol" },
1450         { "unit", "fake unit" },
1451         { "unitDisplay", "long" },
1452         { "unitUsage", "length-person" },
1453         { "signDisplay", "fake display" },
1454         { "compactDisplay", "long" },
1455         { "notation", "standard" },
1456         { "localeMatcher", "lookup" },
1457         { "style", "currency" },
1458         { "numberingSystem", "latn" },
1459         { "useGrouping", "false" },
1460         { "minimumIntegerDigits", "1" },
1461         { "minimumFractionDigits", "0" },
1462         { "maximumFractionDigits", "17" },
1463         { "minimumSignificantDigits", "1" },
1464         { "maximumSignificantDigits", "17" }
1465     };
1466     NumberFormat *formatter = new NumberFormat(locales, options);
1467     string res = formatter->GetUseGrouping();
1468     EXPECT_EQ(res, "false");
1469     res = formatter->GetMinimumIntegerDigits();
1470     EXPECT_EQ(res, "1");
1471     res = formatter->GetMinimumFractionDigits();
1472     EXPECT_EQ(res, "0");
1473     res = formatter->GetMaximumFractionDigits();
1474     EXPECT_EQ(res, "17");
1475     res = formatter->GetMinimumSignificantDigits();
1476     EXPECT_EQ(res, "1");
1477     res = formatter->GetMaximumSignificantDigits();
1478     EXPECT_EQ(res, "17");
1479     delete formatter;
1480 }
1481 
1482 /**
1483  * @tc.name: IntlFuncTest0036
1484  * @tc.desc: Test Intl DateTimeFormat
1485  * @tc.type: FUNC
1486  */
1487 HWTEST_F(IntlTest, IntlFuncTest0036, TestSize.Level1)
1488 {
1489     vector<string> locales;
1490     locales.push_back("en-US");
1491     map<string, string> options = {
1492         { "dateStyle", "short" }
1493     };
1494     DateTimeFormat *formatter = new DateTimeFormat(locales, options);
1495 
1496     int64_t milliseconds = 123456789;
1497     string res = formatter->Format(milliseconds);
1498     EXPECT_EQ(res, "1/2/70");
1499 
1500     int64_t milliseconds2 = 987654321;
1501     res = formatter->FormatRange(milliseconds, milliseconds2);
1502     EXPECT_EQ(res, "1/2/70 \xE2\x80\x93 1/12/70");
1503     delete formatter;
1504 }
1505 
1506 /**
1507  * @tc.name: IntlFuncTest0037
1508  * @tc.desc: Test Intl DateTimeFormat
1509  * @tc.type: FUNC
1510  */
1511 HWTEST_F(IntlTest, IntlFuncTest0037, TestSize.Level1)
1512 {
1513     vector<string> locales;
1514     locales.push_back("zh-CN");
1515     map<string, string> options = {
1516         { "locale", "zh-CN" },
1517         { "dateStyle", "medium" },
1518         { "timeStyle", "long" },
1519         { "hourCycle", "h24" },
1520         { "timeZone", "Asia/Shanghai" },
1521         { "numberingSystem", "latn" },
1522         { "hour12", "false" },
1523         { "weekday", "long" },
1524         { "era", "long" },
1525         { "year", "2-digit" },
1526         { "month", "2-digit" },
1527         { "day", "2-digit" },
1528         { "hour", "2-digit" },
1529         { "minute", "2-digit" },
1530         { "second", "2-digit" },
1531         { "timeZoneName", "long" },
1532         { "dayPeriod", "long" },
1533         { "localeMatcher", "lookup" },
1534         { "formatMatcher", "basic" }
1535     };
1536     DateTimeFormat *formatter = new DateTimeFormat(locales, options);
1537 
1538     int64_t milliseconds = 123456789;
1539     string res = formatter->Format(milliseconds);
1540     // 2022年12月19日 GMT+8 15:18:24
1541     EXPECT_TRUE(res.length() > 0);
1542 
1543     int64_t milliseconds2 = 987654321;
1544     res = formatter->FormatRange(milliseconds, milliseconds2);
1545     // 2022/12/19 GMT+8 15:18:24 \xE2\x80\x93 2023/11/18 GMT+8 14:17:23
1546     EXPECT_TRUE(res.length() > 0);
1547 
1548     res = formatter->GetDateStyle();
1549     EXPECT_EQ(res, "medium");
1550     res = formatter->GetTimeStyle();
1551     EXPECT_EQ(res, "long");
1552     res = formatter->GetHourCycle();
1553     EXPECT_EQ(res, "h24");
1554     res = formatter->GetTimeZone();
1555     EXPECT_EQ(res, "Asia/Shanghai");
1556     res = formatter->GetTimeZoneName();
1557     EXPECT_EQ(res, "long");
1558     delete formatter;
1559 }
1560 
1561 /**
1562  * @tc.name: IntlFuncTest0038
1563  * @tc.desc: Test Intl DateTimeFormat
1564  * @tc.type: FUNC
1565  */
1566 HWTEST_F(IntlTest, IntlFuncTest0038, TestSize.Level1)
1567 {
1568     vector<string> locales;
1569     locales.push_back("zh-CN");
1570     map<string, string> options = {
1571         { "locale", "zh-CN" },
1572         { "dateStyle", "full" },
1573         { "timeStyle", "full" },
1574         { "hourCycle", "h24" },
1575         { "timeZone", "Asia/Shanghai" },
1576         { "numberingSystem", "latn" },
1577         { "hour12", "false" },
1578         { "weekday", "long" },
1579         { "era", "long" },
1580         { "year", "numeric" },
1581         { "month", "numeric" },
1582         { "day", "numeric" },
1583         { "hour", "numeric" },
1584         { "minute", "numeric" },
1585         { "second", "numeric" },
1586         { "timeZoneName", "long" },
1587         { "dayPeriod", "long" },
1588         { "localeMatcher", "lookup" },
1589         { "formatMatcher", "basic" }
1590     };
1591     DateTimeFormat *formatter = new DateTimeFormat(locales, options);
1592     string res = formatter->GetNumberingSystem();
1593     EXPECT_EQ(res, "latn");
1594     res = formatter->GetHour12();
1595     EXPECT_EQ(res, "false");
1596     res = formatter->GetWeekday();
1597     EXPECT_EQ(res, "long");
1598     res = formatter->GetEra();
1599     EXPECT_EQ(res, "long");
1600     res = formatter->GetYear();
1601     EXPECT_EQ(res, "numeric");
1602     res = formatter->GetMonth();
1603     EXPECT_EQ(res, "numeric");
1604     res = formatter->GetDay();
1605     EXPECT_EQ(res, "numeric");
1606     res = formatter->GetHour();
1607     EXPECT_EQ(res, "numeric");
1608     res = formatter->GetMinute();
1609     EXPECT_EQ(res, "numeric");
1610     res = formatter->GetSecond();
1611     EXPECT_EQ(res, "numeric");
1612     delete formatter;
1613 }
1614 
1615 /**
1616  * @tc.name: IntlFuncTest0039
1617  * @tc.desc: Test Intl DateTimeFormat
1618  * @tc.type: FUNC
1619  */
1620 HWTEST_F(IntlTest, IntlFuncTest0039, TestSize.Level1)
1621 {
1622     vector<string> locales;
1623     locales.push_back("en-US");
1624     map<string, string> inputOptions = {
1625         { "locale", "en-US" },
1626         { "dateStyle", "medium" },
1627         { "timeStyle", "long" },
1628         { "hourCycle", "h12" },
1629         { "numberingSystem", "latn" },
1630         { "hour12", "true" },
1631         { "weekday", "long" },
1632         { "era", "long" },
1633         { "year", "2-digit" },
1634         { "month", "2-digit" },
1635         { "day", "2-digit" },
1636         { "hour", "2-digit" },
1637         { "minute", "2-digit" },
1638         { "second", "2-digit" },
1639         { "timeZoneName", "long" },
1640         { "dayPeriod", "long" },
1641         { "localeMatcher", "lookup" },
1642         { "formatMatcher", "basic" }
1643     };
1644     std::unique_ptr<DateTimeFormat> formatter = DateTimeFormat::CreateInstance(locales, inputOptions);
1645     int64_t milliseconds = 123456789;
1646     string res = formatter->Format(milliseconds);
1647     // Dec 19, 2022, 3:18:24 PM GMT+8
1648     EXPECT_TRUE(res.length() > 0);
1649     int64_t milliseconds2 = 987654321;
1650     res = formatter->FormatRange(milliseconds, milliseconds2);
1651     // Dec 19, 2022, 3:18:24 PM GMT+8 \xE2\x80\x93 Nov 18, 2023, 2:17:23 PM GMT+8
1652     EXPECT_TRUE(res.length() > 0);
1653     map<string, string> options;
1654     formatter->GetResolvedOptions(options);
1655     EXPECT_EQ(options.size(), 20);
1656     map<string, string>::iterator it = options.find("locale");
1657     if (it != options.end()) {
1658         EXPECT_EQ(it->second, "en-US");
1659     }
1660     it = options.find("dateStyle");
1661     if (it != options.end()) {
1662         EXPECT_EQ(it->second, "medium");
1663     }
1664     it = options.find("timeStyle");
1665     if (it != options.end()) {
1666         EXPECT_EQ(it->second, "long");
1667     }
1668 }
1669 
1670 /**
1671  * @tc.name: IntlFuncTest0040
1672  * @tc.desc: Test Intl DateTimeFormat
1673  * @tc.type: FUNC
1674  */
1675 HWTEST_F(IntlTest, IntlFuncTest0040, TestSize.Level1)
1676 {
1677     vector<string> locales;
1678     locales.push_back("en-GB");
1679     map<string, string> inputOptions = {
1680         { "locale", "en-GB" },
1681         { "dateStyle", "medium" },
1682         { "timeStyle", "long" },
1683         { "hourCycle", "h12" },
1684         { "timeZone", "Asia/Shanghai" },
1685         { "numberingSystem", "latn" },
1686         { "hour12", "true" },
1687         { "weekday", "long" },
1688         { "era", "long" },
1689         { "year", "numeric" },
1690         { "month", "numeric" },
1691         { "day", "numeric" },
1692         { "hour", "numeric" },
1693         { "minute", "numeric" },
1694         { "second", "numeric" },
1695         { "timeZoneName", "long" },
1696         { "dayPeriod", "long" },
1697         { "localeMatcher", "lookup" },
1698         { "formatMatcher", "basic" }
1699     };
1700     std::unique_ptr<DateTimeFormat> formatter = DateTimeFormat::CreateInstance(locales, inputOptions);
1701     map<string, string> options;
1702     formatter->GetResolvedOptions(options);
1703     map<string, string>::iterator it = options.find("hourCycle");
1704     if (it != options.end()) {
1705         EXPECT_EQ(it->second, "h12");
1706     }
1707     it = options.find("timeZone");
1708     if (it != options.end()) {
1709         EXPECT_EQ(it->second, "Asia/Shanghai");
1710     }
1711     it = options.find("numberingSystem");
1712     if (it != options.end()) {
1713         EXPECT_EQ(it->second, "latn");
1714     }
1715     it = options.find("hour12");
1716     if (it != options.end()) {
1717         EXPECT_EQ(it->second, "true");
1718     }
1719     it = options.find("weekday");
1720     if (it != options.end()) {
1721         EXPECT_EQ(it->second, "long");
1722     }
1723 }
1724 
1725 /**
1726  * @tc.name: IntlFuncTest0041
1727  * @tc.desc: Test Intl DateTimeFormat
1728  * @tc.type: FUNC
1729  */
1730 HWTEST_F(IntlTest, IntlFuncTest0041, TestSize.Level1)
1731 {
1732     vector<string> locales;
1733     locales.push_back("en-US");
1734     map<string, string> inputOptions = {
1735         { "locale", "en-US" },
1736         { "dateStyle", "medium" },
1737         { "timeStyle", "medium" },
1738         { "hourCycle", "h24" },
1739         { "timeZone", "Asia/Shanghai" },
1740         { "numberingSystem", "latn" },
1741         { "hour12", "false" },
1742         { "weekday", "long" },
1743         { "era", "long" },
1744         { "year", "2-digit" },
1745         { "month", "2-digit" },
1746         { "day", "2-digit" },
1747         { "hour", "2-digit" },
1748         { "minute", "2-digit" },
1749         { "second", "2-digit" },
1750         { "timeZoneName", "long" },
1751         { "dayPeriod", "long" },
1752         { "localeMatcher", "best fit" },
1753         { "formatMatcher", "best fit" }
1754     };
1755     std::unique_ptr<DateTimeFormat> formatter = DateTimeFormat::CreateInstance(locales, inputOptions);
1756     map<string, string> options;
1757     formatter->GetResolvedOptions(options);
1758     map<string, string>::iterator it = options.find("era");
1759     if (it != options.end()) {
1760         EXPECT_EQ(it->second, "long");
1761     }
1762     it = options.find("year");
1763     if (it != options.end()) {
1764         EXPECT_EQ(it->second, "2-digit");
1765     }
1766     it = options.find("month");
1767     if (it != options.end()) {
1768         EXPECT_EQ(it->second, "2-digit");
1769     }
1770     it = options.find("day");
1771     if (it != options.end()) {
1772         EXPECT_EQ(it->second, "2-digit");
1773     }
1774     it = options.find("hour");
1775     if (it != options.end()) {
1776         EXPECT_EQ(it->second, "2-digit");
1777     }
1778 }
1779 
1780 /**
1781  * @tc.name: IntlFuncTest0042
1782  * @tc.desc: Test Intl DateTimeFormat
1783  * @tc.type: FUNC
1784  */
1785 HWTEST_F(IntlTest, IntlFuncTest0042, TestSize.Level1)
1786 {
1787     vector<string> locales;
1788     locales.push_back("en-US");
1789     map<string, string> inputOptions = {
1790         { "locale", "en-US" },
1791         { "dateStyle", "full" },
1792         { "timeStyle", "long" },
1793         { "hourCycle", "h12" },
1794         { "timeZone", "Asia/Singapore" },
1795         { "numberingSystem", "latn" },
1796         { "hour12", "true" },
1797         { "weekday", "long" },
1798         { "era", "long" },
1799         { "year", "2-digit" },
1800         { "month", "2-digit" },
1801         { "day", "2-digit" },
1802         { "hour", "numeric" },
1803         { "minute", "numeric" },
1804         { "second", "numeric" },
1805         { "timeZoneName", "long" },
1806         { "dayPeriod", "long" },
1807         { "localeMatcher", "lookup" },
1808         { "formatMatcher", "basic" }
1809     };
1810     std::unique_ptr<DateTimeFormat> formatter = DateTimeFormat::CreateInstance(locales, inputOptions);
1811     map<string, string> options;
1812     formatter->GetResolvedOptions(options);
1813     map<string, string>::iterator it = options.find("minute");
1814     if (it != options.end()) {
1815         EXPECT_EQ(it->second, "numeric");
1816     }
1817     it = options.find("second");
1818     if (it != options.end()) {
1819         EXPECT_EQ(it->second, "numeric");
1820     }
1821     it = options.find("timeZoneName");
1822     if (it != options.end()) {
1823         EXPECT_EQ(it->second, "long");
1824     }
1825     it = options.find("dayPeriod");
1826     if (it != options.end()) {
1827         EXPECT_EQ(it->second, "long");
1828     }
1829 }
1830 
1831 /**
1832  * @tc.name: IntlFuncTest0043
1833  * @tc.desc: Test Intl DateTimeFormat
1834  * @tc.type: FUNC
1835  */
1836 HWTEST_F(IntlTest, IntlFuncTest0043, TestSize.Level1)
1837 {
1838     vector<string> locales;
1839     locales.push_back("en-US");
1840     map<string, string> inputOptions = {
1841         { "locale", "en-US" },
1842         { "dateStyle", "long" },
1843         { "timeStyle", "long" },
1844         { "hourCycle", "h12" },
1845         { "timeZone", "America/Los_Angeles" },
1846         { "numberingSystem", "latn" },
1847         { "hour12", "true" },
1848         { "weekday", "long" },
1849         { "era", "long" },
1850         { "year", "numeric" },
1851         { "month", "numeric" },
1852         { "day", "numeric" },
1853         { "hour", "2-digit" },
1854         { "minute", "2-digit" },
1855         { "second", "2-digit" },
1856         { "timeZoneName", "long" },
1857         { "dayPeriod", "long" },
1858         { "localeMatcher", "lookup" },
1859         { "formatMatcher", "basic" }
1860     };
1861     std::unique_ptr<DateTimeFormat> formatter = DateTimeFormat::CreateInstance(locales, inputOptions);
1862     map<string, string> options;
1863     formatter->GetResolvedOptions(options);
1864     map<string, string>::iterator it = options.find("localeMatcher");
1865     if (it != options.end()) {
1866         EXPECT_EQ(it->second, "lookup");
1867     }
1868     it = options.find("formatMatcher");
1869     if (it != options.end()) {
1870         EXPECT_EQ(it->second, "basic");
1871     }
1872 }
1873 
1874 /**
1875  * @tc.name: IntlFuncTest0044
1876  * @tc.desc: Test Intl LocaleInfo
1877  * @tc.type: FUNC
1878  */
1879 HWTEST_F(IntlTest, IntlFuncTest0044, TestSize.Level1)
1880 {
1881     string localeTag = "zh-Hans-CN";
1882     map<string, string> configs = {
1883         { "calendar", "chinese" },
1884         { "collation", "pinyin" },
1885         { "hourCycle", "h12" },
1886         { "numberingSystem", "latn" },
1887         { "numeric", "true" },
1888         { "caseFirst", "upper" }
1889     };
1890     LocaleInfo *locale = new LocaleInfo(localeTag, configs);
1891     string res = locale->GetLanguage();
1892     EXPECT_EQ(res, "zh");
1893     res = locale->GetScript();
1894     EXPECT_EQ(res, "Hans");
1895     res = locale->GetRegion();
1896     EXPECT_EQ(res, "CN");
1897     res = locale->GetBaseName();
1898     EXPECT_EQ(res, "zh-Hans-CN");
1899     res = locale->GetCalendar();
1900     EXPECT_EQ(res, "chinese");
1901     res = locale->GetCollation();
1902     EXPECT_EQ(res, "pinyin");
1903     res = locale->GetHourCycle();
1904     EXPECT_EQ(res, "h12");
1905     res = locale->GetNumberingSystem();
1906     EXPECT_EQ(res, "latn");
1907     res = locale->GetNumeric();
1908     EXPECT_EQ(res, "true");
1909     res = locale->GetCaseFirst();
1910     EXPECT_EQ(res, "upper");
1911     icu::Locale icuLocale = locale->GetLocale();
1912     res = locale->ToString();
1913     EXPECT_EQ(res, "zh-Hans-CN-u-hc-h12-nu-latn-ca-chinese-co-pinyin-kf-upper-kn-true");
1914     delete locale;
1915 }
1916 
1917 /**
1918  * @tc.name: IntlFuncTest0045
1919  * @tc.desc: Test Intl ReadSystemParameter
1920  * @tc.type: FUNC
1921  */
1922 HWTEST_F(IntlTest, IntlFuncTest0045, TestSize.Level1)
1923 {
1924     string paramKey = "const.global.language";
1925     int paramLength = 128;
1926     string res = ReadSystemParameter(paramKey.c_str(), paramLength);
1927     EXPECT_TRUE(res.length() > 0);
1928 
1929     paramKey = "fake system param";
1930     res = ReadSystemParameter(paramKey.c_str(), paramLength);
1931     EXPECT_TRUE(res.length() == 0);
1932 }
1933 
1934 /**
1935  * @tc.name: IntlFuncTest0046
1936  * @tc.desc: Test Intl NextTransition
1937  * @tc.type: FUNC
1938  */
1939 HWTEST_F(IntlTest, IntlFuncTest0046, TestSize.Level1)
1940 {
1941     std::string tzId = "America/Tijuana";
1942     std::unique_ptr<ZoneRules> zoneRules = std::make_unique<ZoneRules>(tzId);
1943     ASSERT_TRUE(zoneRules != nullptr);
1944     double date = 1738339200000.0; // 2025/2/1
1945     std::unique_ptr<ZoneOffsetTransition> zoneTrans = zoneRules->NextTransition(date);
1946     ASSERT_TRUE(zoneTrans != nullptr);
1947     vector<string> locales;
1948     locales.push_back("en-US");
1949     string dateStyle = "long";
1950     string timeStyle = "long";
1951     string hourCycle = "h24";
1952     string hour12 = "false";
1953     map<string, string> options = { { "dateStyle", dateStyle },
1954                                     { "hour12", hour12 },
1955                                     { "hourCycle", hourCycle },
1956                                     { "timeStyle", timeStyle },
1957                                     { "timeZone", tzId } };
1958     DateTimeFormat *dateFormat = new (std::nothrow) DateTimeFormat(locales, options);
1959     double milliseconds = zoneTrans->GetMilliseconds();
1960     std::string result = dateFormat->Format(static_cast<int64_t>(milliseconds));
1961     EXPECT_EQ(result, "March 9, 2025, 3:00:00 PDT");
1962 
1963     std::unique_ptr<ZoneOffsetTransition> zoneOffsetTrans = zoneRules->NextTransition(milliseconds);
1964     ASSERT_TRUE(zoneOffsetTrans != nullptr);
1965     milliseconds = zoneOffsetTrans->GetMilliseconds();
1966     result = dateFormat->Format(static_cast<int64_t>(milliseconds));
1967     EXPECT_EQ(result, "November 2, 2025, 1:00:00 PST");
1968 
1969     tzId = "America/Santiago";
1970     options["timeZone"] = tzId;
1971     DateTimeFormat *dateFormat2 = new (std::nothrow) DateTimeFormat(locales, options);
1972     std::unique_ptr<ZoneRules> zoneRules2 = std::make_unique<ZoneRules>(tzId);
1973     ASSERT_TRUE(zoneRules2 != nullptr);
1974     std::unique_ptr<ZoneOffsetTransition> zoneTrans2 = zoneRules2->NextTransition(date);
1975     ASSERT_TRUE(zoneTrans2 != nullptr);
1976     milliseconds = zoneTrans2->GetMilliseconds();
1977     result = dateFormat2->Format(static_cast<int64_t>(milliseconds));
1978     EXPECT_EQ(result, "April 5, 2025, 23:00:00 GMT-4");
1979     std::unique_ptr<ZoneOffsetTransition> zoneOffsetTrans2 = zoneRules2->NextTransition(milliseconds);
1980     ASSERT_TRUE(zoneOffsetTrans2 != nullptr);
1981     milliseconds = zoneOffsetTrans2->GetMilliseconds();
1982     result = dateFormat2->Format(static_cast<int64_t>(milliseconds));
1983     EXPECT_EQ(result, "September 7, 2025, 1:00:00 GMT-3");
1984     EXPECT_EQ(zoneOffsetTrans2->GetOffsetAfter(), -10800000);
1985     EXPECT_EQ(zoneOffsetTrans2->GetOffsetBefore(), -14400000);
1986     delete dateFormat;
1987     delete dateFormat2;
1988 }
1989 } // namespace I18n
1990 } // namespace Global
1991 } // namespace OHOS