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 <climits>
17 #include <gtest/gtest.h>
18 #include "UnitNumberTest.h"
19 
20 using namespace std;
21 using namespace testing::ext;
22 namespace OHOS {
23 using namespace I18N;
24 using namespace testing;
25 
26 class NumberTest : public ::testing::TestWithParam<LocaleInfo> {
27 public:
28     static const int ILLEGAL_NUMBERFORMATTYPE = 2;
29 };
30 
31 class NumberConstructionTest : public testing::Test {};
32 
33 
34 /* *
35  * get locale index
36  *
37  * expectResult return locale index
38  */
GetLocaleIndex(LocaleInfo locale, vector<LocaleInfo> locales)39 static int GetLocaleIndex(LocaleInfo locale, vector<LocaleInfo> locales)
40 {
41     for (unsigned int index = 0; index < locales.size(); index++) {
42         if (locale == locales[index]) {
43             return index;
44         }
45     }
46     return -1;
47 }
48 
49 /* *
50  * @tc.number   SUB_GLOBAL_GLOBALIZATIONBUSINESS_NUMBER_FORMAT_CONSTRUCTIION_0100
51  * @tc.name     test NumberFormat Construction,locale is null
52  * @tc.desc     [C- SOFTWARE -0200]
53  */
HWTEST_F(NumberConstructionTest, GLOBAL_NumberFormat_Construction_0100, Function | MediumTest | Level0)54 HWTEST_F(NumberConstructionTest, GLOBAL_NumberFormat_Construction_0100, Function | MediumTest | Level0)
55 {
56     LocaleInfo *localeInfo = new LocaleInfo();
57     int status = I18nStatus::ISUCCESS;
58     NumberFormat *numberForm = new OHOS::I18N::NumberFormat(*localeInfo, status);
59     EXPECT_TRUE(numberForm != nullptr);
60     EXPECT_EQ(status, I18nStatus::IERROR);
61     free(numberForm);
62     free(localeInfo);
63 }
64 
65 /* *
66  * @tc.number   SUB_GLOBAL_GLOBALIZATIONBUSINESS_NUMBER_FORMAT_CONSTRUCTIION_0200
67  * @tc.name     test NumberFormat Construction,locale is normal,script is Latn
68  * @tc.desc     [C- SOFTWARE -0200]
69  */
HWTEST_F(NumberConstructionTest, GLOBAL_NumberFormat_Construction_0200, Function | MediumTest | Level0)70 HWTEST_F(NumberConstructionTest, GLOBAL_NumberFormat_Construction_0200, Function | MediumTest | Level0)
71 {
72     LocaleInfo localeInfo("as", "Latn", "IN");
73     int status = I18nStatus::ISUCCESS;
74     NumberFormat *numberForm = new OHOS::I18N::NumberFormat(localeInfo, status);
75     EXPECT_TRUE(numberForm != nullptr);
76     free(numberForm);
77 }
78 
79 /* *
80  * @tc.number   SUB_GLOBAL_GLOBALIZATIONBUSINESS_NUMBER_FORMAT_CONSTRUCTIION_0300
81  * @tc.name     test NumberFormat Construction,locale is normal
82  * @tc.desc     [C- SOFTWARE -0200]
83  */
HWTEST_F(NumberConstructionTest, GLOBAL_NumberFormat_Construction_0300, Function | MediumTest | Level0)84 HWTEST_F(NumberConstructionTest, GLOBAL_NumberFormat_Construction_0300, Function | MediumTest | Level0)
85 {
86     LocaleInfo localeInfo("es", "US");
87     int status = I18nStatus::ISUCCESS;
88     NumberFormat *numberForm = new OHOS::I18N::NumberFormat(localeInfo, status);
89     EXPECT_TRUE(numberForm != nullptr);
90     free(numberForm);
91 }
92 
93 /* *
94  * @tc.number   SUB_GLOBAL_GLOBALIZATIONBUSINESS_NUMBER_FORMAT_CONSTRUCTIION_0400
95  * @tc.name     test NumberFormat Construction,locale is copy
96  * @tc.desc     [C- SOFTWARE -0200]
97  */
HWTEST_F(NumberConstructionTest, GLOBAL_NumberFormat_Construction_0400, Function | MediumTest | Level0)98 HWTEST_F(NumberConstructionTest, GLOBAL_NumberFormat_Construction_0400, Function | MediumTest | Level0)
99 {
100     LocaleInfo *localeInfo = new LocaleInfo("es", "US");
101     LocaleInfo &localeInfo1 = *localeInfo;
102     int status = I18nStatus::ISUCCESS;
103     NumberFormat *numberForm = new NumberFormat(localeInfo1, status);
104     EXPECT_TRUE(numberForm != nullptr);
105     free(numberForm);
106     free(localeInfo);
107 }
108 
109 /* *
110  * @tc.number   SUB_GLOBAL_GLOBALIZATIONBUSINESS_NUMBER_FORMAT_DOUBLEFORMAT_0100
111  * @tc.name     test NumberFormat Format API,type is DECIMAL
112  * @tc.desc     [C- SOFTWARE -0200]
113  */
HWTEST_P(NumberTest, GLOBAL_NumberFormat_DoubleFormat_0100, Function | MediumTest | Level0)114 HWTEST_P(NumberTest, GLOBAL_NumberFormat_DoubleFormat_0100, Function | MediumTest | Level0)
115 {
116     double doubleNum1 = 8234567.56;
117     double doubleNum2 = 8.23456789567E8;
118     double doubleNum3 = 8234.0;
119     LocaleInfo localeInfo = GetParam();
120     int localeIndex = GetLocaleIndex(localeInfo, g_locales);
121     if (localeIndex >= 0) {
122         int status = I18nStatus::ISUCCESS;
123         NumberFormat *numberForm = new NumberFormat(localeInfo, status);
124         std::string numberFormOut1 = numberForm->Format(doubleNum1, NumberFormatType::DECIMAL, status);
125         std::string numberFormOut2 = numberForm->Format(doubleNum2, NumberFormatType::DECIMAL, status);
126         std::string numberFormOut3 = numberForm->Format(doubleNum3, NumberFormatType::DECIMAL, status);
127         EXPECT_EQ(numberFormOut1, g_numberFormExpect[localeIndex][6]);
128         EXPECT_EQ(numberFormOut2, g_numberFormExpect[localeIndex][7]);
129         EXPECT_EQ(numberFormOut3, g_numberFormExpect[localeIndex][8]);
130         free(numberForm);
131     }
132 }
133 
134 /* *
135  * @tc.number   SUB_GLOBAL_GLOBALIZATIONBUSINESS_NUMBER_FORMAT_DOUBLEFORMAT_0200
136  * @tc.name     test NumberFormat Format API,type is PERCENT
137  * @tc.desc     [C- SOFTWARE -0200]
138  */
HWTEST_P(NumberTest, GLOBAL_NumberFormat_DoubleFormat_0200, Function | MediumTest | Level0)139 HWTEST_P(NumberTest, GLOBAL_NumberFormat_DoubleFormat_0200, Function | MediumTest | Level0)
140 {
141     double percentNum1 = 0.1234;
142     double percentNum2 = 0.123456;
143     LocaleInfo localeInfo = GetParam();
144     int localeIndex = GetLocaleIndex(localeInfo, g_locales);
145     if (localeIndex >= 0) {
146         int status = I18nStatus::ISUCCESS;
147         NumberFormat *numberForm = new NumberFormat(localeInfo, status);
148         std::string numberFormOut1 = numberForm->Format(percentNum1, NumberFormatType::PERCENT, status);
149         std::string numberFormOut2 = numberForm->Format(percentNum2, NumberFormatType::PERCENT, status);
150         EXPECT_EQ(numberFormOut1, g_numberFormExpect[localeIndex][18]);
151         EXPECT_EQ(numberFormOut2, g_numberFormExpect[localeIndex][19]);
152         free(numberForm);
153     }
154 }
155 
156 
157 /* *
158  * @tc.number   SUB_GLOBAL_GLOBALIZATIONBUSINESS_NUMBER_FORMAT_INTFORMAT_0100
159  * @tc.name     test NumberFormat Format API
160  * @tc.desc     [C- SOFTWARE -0200]
161  */
HWTEST_P(NumberTest, GLOBAL_NumberFormat_IntFormat_0100, Function | MediumTest | Level0)162 HWTEST_P(NumberTest, GLOBAL_NumberFormat_IntFormat_0100, Function | MediumTest | Level0)
163 {
164     int intNum1 = 1234567;
165     int intNum2 = 123456789;
166     int intNum3 = 1234;
167     LocaleInfo localeInfo = GetParam();
168     int localeIndex = GetLocaleIndex(localeInfo, g_locales);
169     if (localeIndex >= 0) {
170         int status = I18nStatus::ISUCCESS;
171         NumberFormat *numberForm = new NumberFormat(localeInfo, status);
172         std::string numberFormOut1 = numberForm->Format(intNum1, status);
173         std::string numberFormOut2 = numberForm->Format(intNum2, status);
174         std::string numberFormOut3 = numberForm->Format(intNum3, status);
175         EXPECT_EQ(numberFormOut1, g_numberFormExpect[localeIndex][0]);
176         EXPECT_EQ(numberFormOut2, g_numberFormExpect[localeIndex][1]);
177         EXPECT_EQ(numberFormOut3, g_numberFormExpect[localeIndex][2]);
178         free(numberForm);
179     }
180 }
181 
182 /* *
183  * @tc.number   SUB_GLOBAL_GLOBALIZATIONBUSINESS_NUMBER_FORMAT_DOUBLEFORMATNOGROUP_0100
184  * @tc.name     test NumberFormat FormatNoGroup API
185  * @tc.desc     [C- SOFTWARE -0200]
186  */
HWTEST_P(NumberTest, GLOBAL_NumberFormat_DoubleFormatNoGroup_0100, Function | MediumTest | Level0)187 HWTEST_P(NumberTest, GLOBAL_NumberFormat_DoubleFormatNoGroup_0100, Function | MediumTest | Level0)
188 {
189     double doubleNum1 = 8234567.56;
190     double doubleNum2 = 8.23456789567E8;
191     double doubleNum3 = 8234.0;
192     LocaleInfo localeInfo = GetParam();
193     int localeIndex = GetLocaleIndex(localeInfo, g_locales);
194     if (localeIndex >= 0) {
195         int status = I18nStatus::ISUCCESS;
196         NumberFormat *numberForm = new NumberFormat(localeInfo, status);
197         std::string numberFormOut1 = numberForm->FormatNoGroup(doubleNum1, NumberFormatType::DECIMAL, status);
198         std::string numberFormOut2 = numberForm->FormatNoGroup(doubleNum2, NumberFormatType::DECIMAL, status);
199         std::string numberFormOut3 = numberForm->FormatNoGroup(doubleNum3, NumberFormatType::DECIMAL, status);
200         EXPECT_EQ(numberFormOut1, g_numberFormExpect[localeIndex][9]);
201         EXPECT_EQ(numberFormOut2, g_numberFormExpect[localeIndex][10]);
202         EXPECT_EQ(numberFormOut3, g_numberFormExpect[localeIndex][11]);
203         free(numberForm);
204     }
205 }
206 
207 
208 /* *
209  * @tc.number   SUB_GLOBAL_GLOBALIZATIONBUSINESS_NUMBER_FORMAT_INTFORMATNOGROUP_0100
210  * @tc.name     test NumberFormat FormatNoGroup API,illegal NumberFormatType type
211  * @tc.desc     [C- SOFTWARE -0200]
212  */
HWTEST_P(NumberTest, GLOBAL_NumberFormat_IntFormatNoGroup_0100, Function | MediumTest | Level0)213 HWTEST_P(NumberTest, GLOBAL_NumberFormat_IntFormatNoGroup_0100, Function | MediumTest | Level0)
214 {
215     int intNum1 = 1234567;
216     int intNum2 = 123456789;
217     int intNum3 = 1234;
218     LocaleInfo localeInfo = GetParam();
219     int localeIndex = GetLocaleIndex(localeInfo, g_locales);
220     if (localeIndex >= 0) {
221         int status = I18nStatus::ISUCCESS;
222         NumberFormat *numberForm = new NumberFormat(localeInfo, status);
223         std::string numberFormOut1 = numberForm->FormatNoGroup(intNum1, status);
224         std::string numberFormOut2 = numberForm->FormatNoGroup(intNum2, status);
225         std::string numberFormOut3 = numberForm->FormatNoGroup(intNum3, status);
226         EXPECT_EQ(numberFormOut1, g_numberFormExpect[localeIndex][3]);
227         EXPECT_EQ(numberFormOut2, g_numberFormExpect[localeIndex][4]);
228         EXPECT_EQ(numberFormOut3, g_numberFormExpect[localeIndex][5]);
229         free(numberForm);
230     }
231 }
232 
233 /* *
234  * @tc.number   SUB_GLOBAL_GLOBALIZATIONBUSINESS_NUMBER_FORMAT_INT_SETMAXDECIMALLENGTH_0100
235  * @tc.name     test NumberFormat SetMaxDecimalLength API,length is -1
236  * @tc.desc     [C- SOFTWARE -0200]
237  */
HWTEST_P(NumberTest, GLOBAL_NumberFormat_SetMaxDecimalLength_0100, Function | MediumTest | Level0)238 HWTEST_P(NumberTest, GLOBAL_NumberFormat_SetMaxDecimalLength_0100, Function | MediumTest | Level0)
239 {
240     double doubleNum1 = 8234567.56;
241     double doubleNum2 = 8.23456789567E8;
242     double doubleNum3 = 8234.0;
243     LocaleInfo localeInfo = GetParam();
244     int localeIndex = GetLocaleIndex(localeInfo, g_locales);
245     if (localeIndex >= 0) {
246         int status = I18nStatus::ISUCCESS;
247         NumberFormat *numberForm = new NumberFormat(localeInfo, status);
248         numberForm->SetMaxDecimalLength(-1);
249         std::string numberFormOut1 = numberForm->Format(doubleNum1, NumberFormatType::DECIMAL, status);
250         std::string numberFormOut2 = numberForm->Format(doubleNum2, NumberFormatType::DECIMAL, status);
251         std::string numberFormOut3 = numberForm->Format(doubleNum3, NumberFormatType::DECIMAL, status);
252         EXPECT_EQ(numberFormOut1, g_numberFormExpect[localeIndex][12]);
253         EXPECT_EQ(numberFormOut2, g_numberFormExpect[localeIndex][13]);
254         EXPECT_EQ(numberFormOut3, g_numberFormExpect[localeIndex][14]);
255         free(numberForm);
256     }
257 }
258 
259 /* *
260  * @tc.number   SUB_GLOBAL_GLOBALIZATIONBUSINESS_NUMBER_FORMAT_INT_SETMAXDECIMALLENGTH_0200
261  * @tc.name     test NumberFormat SetMaxDecimalLength API,length is 0
262  * @tc.desc     [C- SOFTWARE -0200]
263  */
HWTEST_P(NumberTest, GLOBAL_NumberFormat_SetMaxDecimalLength_0200, Function | MediumTest | Level0)264 HWTEST_P(NumberTest, GLOBAL_NumberFormat_SetMaxDecimalLength_0200, Function | MediumTest | Level0)
265 {
266     double doubleNum1 = 8234567.56;
267     double doubleNum2 = 8.23456789567E8;
268     double doubleNum3 = 8234.0;
269     LocaleInfo localeInfo = GetParam();
270     int localeIndex = GetLocaleIndex(localeInfo, g_locales);
271     if (localeIndex >= 0) {
272         int status = I18nStatus::ISUCCESS;
273         NumberFormat *numberForm = new NumberFormat(localeInfo, status);
274         numberForm->SetMaxDecimalLength(0);
275         std::string numberFormOut1 = numberForm->Format(doubleNum1, NumberFormatType::DECIMAL, status);
276         std::string numberFormOut2 = numberForm->Format(doubleNum2, NumberFormatType::DECIMAL, status);
277         std::string numberFormOut3 = numberForm->Format(doubleNum3, NumberFormatType::DECIMAL, status);
278         EXPECT_EQ(numberFormOut1, g_numberMaxLengthZeroExpect[localeIndex][12]);
279         EXPECT_EQ(numberFormOut2, g_numberMaxLengthZeroExpect[localeIndex][13]);
280         EXPECT_EQ(numberFormOut3, g_numberMaxLengthZeroExpect[localeIndex][14]);
281         free(numberForm);
282     }
283 }
284 
285 /* *
286  * @tc.number   SUB_GLOBAL_GLOBALIZATIONBUSINESS_NUMBER_FORMAT_INT_SETMAXDECIMALLENGTH_0300
287  * @tc.name     test NumberFormat SetMaxDecimalLength API,length is 10
288  * @tc.desc     [C- SOFTWARE -0200]
289  */
HWTEST_P(NumberTest, GLOBAL_NumberFormat_SetMaxDecimalLength_0300, Function | MediumTest | Level0)290 HWTEST_P(NumberTest, GLOBAL_NumberFormat_SetMaxDecimalLength_0300, Function | MediumTest | Level0)
291 {
292     double doubleNum1 = 8234567.56;
293     double doubleNum2 = 8.23456789567E8;
294     double doubleNum3 = 8234.0;
295     LocaleInfo localeInfo = GetParam();
296     int localeIndex = GetLocaleIndex(localeInfo, g_locales);
297     if (localeIndex >= 0) {
298         int status = I18nStatus::ISUCCESS;
299         NumberFormat *numberForm = new NumberFormat(localeInfo, status);
300         numberForm->SetMaxDecimalLength(10);
301         std::string numberFormOut1 = numberForm->Format(doubleNum1, NumberFormatType::DECIMAL, status);
302         std::string numberFormOut2 = numberForm->Format(doubleNum2, NumberFormatType::DECIMAL, status);
303         std::string numberFormOut3 = numberForm->Format(doubleNum3, NumberFormatType::DECIMAL, status);
304         EXPECT_EQ(numberFormOut1, g_numberFormExpect[localeIndex][12]);
305         EXPECT_EQ(numberFormOut2, g_numberFormExpect[localeIndex][13]);
306         EXPECT_EQ(numberFormOut3, g_numberFormExpect[localeIndex][14]);
307         free(numberForm);
308     }
309 }
310 
311 /* *
312  * @tc.number   SUB_GLOBAL_GLOBALIZATIONBUSINESS_NUMBER_FORMAT_INT_SETMAXDECIMALLENGTH_0400
313  * @tc.name     test NumberFormat SetMaxDecimalLength API,length is 2
314  * @tc.desc     [C- SOFTWARE -0200]
315  */
HWTEST_P(NumberTest, GLOBAL_NumberFormat_SetMaxDecimalLength_0400, Function | MediumTest | Level0)316 HWTEST_P(NumberTest, GLOBAL_NumberFormat_SetMaxDecimalLength_0400, Function | MediumTest | Level0)
317 {
318     double doubleNum1 = 8234567.5678;
319     LocaleInfo localeInfo = GetParam();
320     int localeIndex = GetLocaleIndex(localeInfo, g_locales);
321     if (localeIndex >= 0) {
322         int status = I18nStatus::ISUCCESS;
323         NumberFormat *numberForm = new NumberFormat(localeInfo, status);
324         numberForm->SetMaxDecimalLength(2);
325         std::string numberFormOut1 = numberForm->Format(doubleNum1, NumberFormatType::DECIMAL, status);
326         EXPECT_EQ(numberFormOut1, g_numberMaxLengthTwoExpect[localeIndex][12]);
327         free(numberForm);
328     }
329 }
330 
331 /* *
332  * @tc.number   SUB_GLOBAL_GLOBALIZATIONBUSINESS_NUMBER_FORMAT_INT_SETMINDECIMALLENGTH_0100
333  * @tc.name     test NumberFormat SetMinDecimalLength API,length is -1
334  * @tc.desc     [C- SOFTWARE -0200]
335  */
HWTEST_P(NumberTest, GLOBAL_NumberFormat_SetMinDecimalLength_0100, Function | MediumTest | Level0)336 HWTEST_P(NumberTest, GLOBAL_NumberFormat_SetMinDecimalLength_0100, Function | MediumTest | Level0)
337 {
338     double doubleNum1 = 8234567.56;
339     LocaleInfo localeInfo = GetParam();
340     int localeIndex = GetLocaleIndex(localeInfo, g_locales);
341     if (localeIndex >= 0) {
342         int status = I18nStatus::ISUCCESS;
343         NumberFormat *numberForm = new NumberFormat(localeInfo, status);
344         numberForm->SetMinDecimalLength(-1);
345         std::string numberFormOut1 = numberForm->Format(doubleNum1, NumberFormatType::DECIMAL, status);
346         EXPECT_EQ(numberFormOut1, g_numberFormExpect[localeIndex][12]);
347         free(numberForm);
348     }
349 }
350 
351 /* *
352  * @tc.number   SUB_GLOBAL_GLOBALIZATIONBUSINESS_NUMBER_FORMAT_INT_SETMINDECIMALLENGTH_0200
353  * @tc.name     test NumberFormat SetMinDecimalLength API,length is 0
354  * @tc.desc     [C- SOFTWARE -0200]
355  */
HWTEST_P(NumberTest, GLOBAL_NumberFormat_SetMinDecimalLength_0200, Function | MediumTest | Level0)356 HWTEST_P(NumberTest, GLOBAL_NumberFormat_SetMinDecimalLength_0200, Function | MediumTest | Level0)
357 {
358     double doubleNum1 = 8234567.56;
359     LocaleInfo localeInfo = GetParam();
360     int localeIndex = GetLocaleIndex(localeInfo, g_locales);
361     if (localeIndex >= 0) {
362         int status = I18nStatus::ISUCCESS;
363         NumberFormat *numberForm = new NumberFormat(localeInfo, status);
364         numberForm->SetMinDecimalLength(0);
365         std::string numberFormOut1 = numberForm->Format(doubleNum1, NumberFormatType::DECIMAL, status);
366         EXPECT_EQ(numberFormOut1, g_numberFormExpect[localeIndex][12]);
367         free(numberForm);
368     }
369 }
370 
371 /* *
372  * @tc.number   SUB_GLOBAL_GLOBALIZATIONBUSINESS_NUMBER_FORMAT_INT_SETMINDECIMALLENGTH_0300
373  * @tc.name     test NumberFormat SetMinDecimalLength API,length is 3
374  * @tc.desc     [C- SOFTWARE -0200]
375  */
HWTEST_P(NumberTest, GLOBAL_NumberFormat_SetMinDecimalLength_0300, Function | MediumTest | Level0)376 HWTEST_P(NumberTest, GLOBAL_NumberFormat_SetMinDecimalLength_0300, Function | MediumTest | Level0)
377 {
378     double doubleNum1 = 8234567.56;
379     LocaleInfo localeInfo = GetParam();
380     int localeIndex = GetLocaleIndex(localeInfo, g_locales);
381     if (localeIndex >= 0) {
382         int status = I18nStatus::ISUCCESS;
383         NumberFormat *numberForm = new NumberFormat(localeInfo, status);
384         numberForm->SetMinDecimalLength(3);
385         std::string numberFormOut1 = numberForm->Format(doubleNum1, NumberFormatType::DECIMAL, status);
386         EXPECT_EQ(numberFormOut1, g_numberFormExpect[localeIndex][15]);
387         free(numberForm);
388     }
389 }
390 
391 /* *
392  * @tc.number   SUB_GLOBAL_GLOBALIZATIONBUSINESS_NUMBER_FORMAT_INT_SETMINDECIMALLENGTH_0400
393  * @tc.name     test NumberFormat SetMinDecimalLength API,length is 2
394  * @tc.desc     [C- SOFTWARE -0200]
395  */
HWTEST_P(NumberTest, GLOBAL_NumberFormat_SetMinDecimalLength_0400, Function | MediumTest | Level0)396 HWTEST_P(NumberTest, GLOBAL_NumberFormat_SetMinDecimalLength_0400, Function | MediumTest | Level0)
397 {
398     double doubleNum1 = 8.23456789567E8;
399     LocaleInfo localeInfo = GetParam();
400     int localeIndex = GetLocaleIndex(localeInfo, g_locales);
401     if (localeIndex >= 0) {
402         int status = I18nStatus::ISUCCESS;
403         NumberFormat *numberForm = new NumberFormat(localeInfo, status);
404         numberForm->SetMinDecimalLength(2);
405         std::string numberFormOut1 = numberForm->Format(doubleNum1, NumberFormatType::DECIMAL, status);
406         EXPECT_EQ(numberFormOut1, g_numberFormExpect[localeIndex][16]);
407         free(numberForm);
408     }
409 }
410 
411 INSTANTIATE_TEST_CASE_P(AllNumberTest, NumberTest,
412     Values(LocaleInfo("ar", "", ""), LocaleInfo("ar", "AE"), LocaleInfo("ar", "EG"), LocaleInfo("as", "Latn", "IN"),
413     LocaleInfo("de", "DE"), LocaleInfo("en", "", ""), LocaleInfo("en", "GB"), LocaleInfo("en", "Qaag", ""),
414     LocaleInfo("en", "US"), LocaleInfo("es", "ES"), LocaleInfo("es", "US"), LocaleInfo("fr", "FR"),
415     LocaleInfo("it", "IT"), LocaleInfo("ka", "GE"), LocaleInfo("mai", "Deva", ""), LocaleInfo("my", "MM"),
416     LocaleInfo("pa", "Guru", ""), LocaleInfo("pt", "BR"), LocaleInfo("pt", "PT"), LocaleInfo("sr", "Cyrl", ""),
417     LocaleInfo("th", "TH"), LocaleInfo("zh", "", ""), LocaleInfo("zh", "Hans", "CN"), LocaleInfo("zh", "Hans", "HK"),
418     LocaleInfo("zh", "Hans", "MO"), LocaleInfo("zh", "Hant", "TW")));
419 } // namespace OHOS