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 #ifndef UNIT_NUMBER_TEST_H 17 #define UNIT_NUMBER_TEST_H 18 19 #include <string> 20 #include <vector> 21 #include <algorithm> 22 #include "locale_info.h" 23 #include "number_format.h" 24 25 namespace testing { 26 using namespace OHOS; 27 using ::std::string; 28 using ::std::vector; 29 using namespace I18N; 30 vector<LocaleInfo> g_locales = { 31 LocaleInfo("ar", "", ""), LocaleInfo("ar", "AE"), LocaleInfo("ar", "EG"), 32 LocaleInfo("as", "Latn", "IN"), LocaleInfo("de", "DE"), LocaleInfo("en", "", ""), 33 LocaleInfo("en", "GB"), LocaleInfo("en", "Qaag", ""), LocaleInfo("en", "US"), 34 LocaleInfo("es", "ES"), LocaleInfo("es", "US"), LocaleInfo("fr", "FR"), 35 LocaleInfo("it", "IT"), LocaleInfo("ka", "GE"), LocaleInfo("mai", "Deva", ""), 36 LocaleInfo("my", "MM"), LocaleInfo("pa", "Guru", ""), LocaleInfo("pt", "BR"), 37 LocaleInfo("pt", "PT"), LocaleInfo("sr", "Cyrl", ""), LocaleInfo("th", "TH"), 38 LocaleInfo("zh", "", ""), LocaleInfo("zh", "Hans", ""), LocaleInfo("zh", "Hans", "CN"), 39 LocaleInfo("zh", "Hans", "HK"), LocaleInfo("zh", "Hans", "MO"), LocaleInfo("zh", "Hant", "TW") 40 }; 41 42 string g_numberFormExpect[][20] = { 43 { "١٬٢٣٤٬٥٦٧", "١٢٣٬٤٥٦٬٧٨٩", "١٬٢٣٤", 44 "١٢٣٤٥٦٧", "١٢٣٤٥٦٧٨٩", "١٢٣٤", "٨٬٢٣٤٬٥٦٧٫٥٦٨", "٨٢٣٬٤٥٦٬٧٨٩٫٥٦٧", "٨٬٢٣٤", 45 "٨٢٣٤٥٦٧٫٥٦٨", "٨٢٣٤٥٦٧٨٩٫٥٦٧", "٨٢٣٤", "٨٬٢٣٤٬٥٦٧٫٥٧", "٨٢٣٬٤٥٦٬٧٨٩٫٥٧", 46 "٨٬٢٣٤", "٨٬٢٣٤٬٥٦٧٫٥٦٧٨", "٨٢٣٬٤٥٦٬٧٨٩٫٥٦٧", "٨٬٢٣٤٫٠٠٠", "١٢٪", "١٢٪" }, 47 { "١٬٢٣٤٬٥٦٧", "١٢٣٬٤٥٦٬٧٨٩", "١٬٢٣٤", 48 "١٢٣٤٥٦٧", "١٢٣٤٥٦٧٨٩", "١٢٣٤", "٨٬٢٣٤٬٥٦٧٫٥٦٨", "٨٢٣٬٤٥٦٬٧٨٩٫٥٦٧", "٨٬٢٣٤", 49 "٨٢٣٤٥٦٧٫٥٦٨", "٨٢٣٤٥٦٧٨٩٫٥٦٧", "٨٢٣٤", "٨٬٢٣٤٬٥٦٧٫٥٧", "٨٢٣٬٤٥٦٬٧٨٩٫٥٧", 50 "٨٬٢٣٤", "٨٬٢٣٤٬٥٦٧٫٥٦٧٨", "٨٢٣٬٤٥٦٬٧٨٩٫٥٦٧", "٨٬٢٣٤٫٠٠٠", "١٢٪", "١٢٪" }, 51 { "١٬٢٣٤٬٥٦٧", "١٢٣٬٤٥٦٬٧٨٩", "١٬٢٣٤", 52 "١٢٣٤٥٦٧", "١٢٣٤٥٦٧٨٩", "١٢٣٤", "٨٬٢٣٤٬٥٦٧٫٥٦٨", "٨٢٣٬٤٥٦٬٧٨٩٫٥٦٧", "٨٬٢٣٤", 53 "٨٢٣٤٥٦٧٫٥٦٨", "٨٢٣٤٥٦٧٨٩٫٥٦٧", "٨٢٣٤", "٨٬٢٣٤٬٥٦٧٫٥٧", "٨٢٣٬٤٥٦٬٧٨٩٫٥٧", 54 "٨٬٢٣٤", "٨٬٢٣٤٬٥٦٧٫٥٦٧٨", "٨٢٣٬٤٥٦٬٧٨٩٫٥٦٧", "٨٬٢٣٤٫٠٠٠", "١٢٪", "١٢٪" }, 55 { "১২,৩৪,৫৬৭", "১২,৩৪,৫৬,৭৮৯", "১,২৩৪", "১২৩৪৫৬৭", "১২৩৪৫৬৭৮৯", "১২৩৪", 56 "৮২,৩৪,৫৬৭.৫৬৮", "৮২,৩৪,৫৬,৭৮৯.৫৬৭", "৮,২৩৪", "৮২৩৪৫৬৭.৫৬৮", "৮২৩৪৫৬৭৮৯.৫৬৭", 57 "৮২৩৪", "৮২,৩৪,৫৬৭.৫৭", "৮২,৩৪,৫৬,৭৮৯.৫৭", "৮,২৩৪", "৮২,৩৪,৫৬৭.৫৬৭৮", 58 "৮২,৩৪,৫৬,৭৮৯.৫৬৭", "৮,২৩৪.০০০", "১২%", "১২%" }, 59 { "1.234.567", "123.456.789", "1.234", "1234567", "123456789", "1234", "8.234.567,568", 60 "823.456.789,567", "8.234", "8234567,568", "823456789,567", "8234", "8.234.567,57", 61 "823.456.789,57", "8.234", "8.234.567,5678", "823.456.789,567", "8.234,000", "12 %", "12 %" }, 62 { "1,234,567", "123,456,789", "1,234", "1234567", "123456789", "1234", "8,234,567.568", 63 "823,456,789.567", "8,234", "8234567.568", "823456789.567", "8234", "8,234,567.57", 64 "823,456,789.57", "8,234", "8,234,567.5678", "823,456,789.567", "8,234.000", "12%", "12%" }, 65 { "1,234,567", "123,456,789", "1,234", "1234567", "123456789", "1234", "8,234,567.568", 66 "823,456,789.567", "8,234", "8234567.568", "823456789.567", "8234", "8,234,567.57", 67 "823,456,789.57", "8,234", "8,234,567.5678", "823,456,789.567", "8,234.000", "12%", "12%" }, 68 { "1,234,567", "123,456,789", "1,234", "1234567", "123456789", "1234", "8,234,567.568", 69 "823,456,789.567", "8,234", "8234567.568", "823456789.567", "8234", "8,234,567.57", 70 "823,456,789.57", "8,234", "8,234,567.5678", "823,456,789.567", "8,234.000", "12%", "12%" }, 71 { "1,234,567", "123,456,789", "1,234", "1234567", "123456789", "1234", "8,234,567.568", 72 "823,456,789.567", "8,234", "8234567.568", "823456789.567", "8234", "8,234,567.57", 73 "823,456,789.57", "8,234", "8,234,567.5678", "823,456,789.567", "8,234.000", "12%", "12%" }, 74 { "1.234.567", "123.456.789", "1.234", "1234567", "123456789", "1234", "8.234.567,568", 75 "823.456.789,567", "8.234", "8234567,568", "823456789,567", "8234", "8.234.567,57", 76 "823.456.789,57", "8.234", "8.234.567,5678", "823.456.789,567", "8.234,000", "12 %", "12 %" }, 77 { "1,234,567", "123,456,789", "1,234", "1234567", "123456789", "1234", "8,234,567.568", 78 "823,456,789.567", "8,234", "8234567.568", "823456789.567", "8234", "8,234,567.57", 79 "823,456,789.57", "8,234", "8,234,567.5678", "823,456,789.567", "8,234.000", "12 %", "12 %" }, 80 { "1 234 567", "123 456 789", "1 234", "1234567", "123456789", "1234", "8 234 567,568", 81 "823 456 789,567", "8 234", "8234567,568", "823456789,567", "8234", "8 234 567,57", 82 "823 456 789,57", "8 234", "8 234 567,5678", "823 456 789,567", "8 234,000", "12 %", "12 %" }, 83 { "1.234.567", "123.456.789", "1.234", "1234567", "123456789", "1234", "8.234.567,568", 84 "823.456.789,567", "8.234", "8234567,568", "823456789,567", "8234", "8.234.567,57", 85 "823.456.789,57", "8.234", "8.234.567,5678", "823.456.789,567", "8.234,000", "12%", "12%" }, 86 { "1 234 567", "123 456 789", "1 234", "1234567", "123456789", "1234", "8 234 567,568", 87 "823 456 789,567", "8 234", "8234567,568", "823456789,567", "8234", "8 234 567,57", 88 "823 456 789,57", "8 234", "8 234 567,5678", "823 456 789,567", "8 234,000", "12%", "12%" }, 89 { "1,234,567", "123,456,789", "1,234", "1234567", "123456789", "1234", "8,234,567.568", 90 "823,456,789.567", "8,234", "8234567.568", "823456789.567", "8234", "8,234,567.57", 91 "823,456,789.57", "8,234", "8,234,567.5678", "823,456,789.567", "8,234.000", "12%", "12%" }, 92 { "၁,၂၃၄,၅၆၇", "၁၂၃,၄၅၆,၇၈၉", "၁,၂၃၄", "၁၂၃၄၅၆၇", "၁၂၃၄၅၆၇၈၉", "၁၂၃၄", "၈,၂၃၄,၅၆၇.၅၆၈", 93 "၈၂၃,၄၅၆,၇၈၉.၅၆၇", "၈,၂၃၄", "၈၂၃၄၅၆၇.၅၆၈", "၈၂၃၄၅၆၇၈၉.၅၆၇", "၈၂၃၄", "၈,၂၃၄,၅၆၇.၅၇", 94 "၈၂၃,၄၅၆,၇၈၉.၅၇", "၈,၂၃၄", "၈,၂၃၄,၅၆၇.၅၆၇၈", "၈၂၃,၄၅၆,၇၈၉.၅၆၇", "၈,၂၃၄.၀၀၀", "၁၂%", "၁၂%" }, 95 { "12,34,567", "12,34,56,789", "1,234", "1234567", "123456789", "1234", "82,34,567.568", 96 "82,34,56,789.567", "8,234", "8234567.568", "823456789.567", "8234", "82,34,567.57", 97 "82,34,56,789.57", "8,234", "82,34,567.5678", "82,34,56,789.567", "8,234.000", "12%", "12%" }, 98 { "1.234.567", "123.456.789", "1.234", "1234567", "123456789", "1234", "8.234.567,568", 99 "823.456.789,567", "8.234", "8234567,568", "823456789,567", "8234", "8.234.567,57", 100 "823.456.789,57", "8.234", "8.234.567,5678", "823.456.789,567", "8.234,000", "12%", "12%" }, 101 { "1 234 567", "123 456 789", "1 234", "1234567", "123456789", "1234", "8 234 567,568", 102 "823 456 789,567", "8 234", "8234567,568", "823456789,567", "8234", "8 234 567,57", 103 "823 456 789,57", "8 234", "8 234 567,5678", "823 456 789,567", "8 234,000", "12%", "12%" }, 104 { "1.234.567", "123.456.789", "1.234", "1234567", "123456789", "1234", "8.234.567,568", 105 "823.456.789,567", "8.234", "8234567,568", "823456789,567", "8234", "8.234.567,57", 106 "823.456.789,57", "8.234", "8.234.567,5678", "823.456.789,567", "8.234,000", "12%", "12%" }, 107 { "1,234,567", "123,456,789", "1,234", "1234567", "123456789", "1234", "8,234,567.568", 108 "823,456,789.567", "8,234", "8234567.568", "823456789.567", "8234", "8,234,567.57", 109 "823,456,789.57", "8,234", "8,234,567.5678", "823,456,789.567", "8,234.000", "12%", "12%" }, 110 { "1,234,567", "123,456,789", "1,234", "1234567", "123456789", "1234", "8,234,567.568", 111 "823,456,789.567", "8,234", "8234567.568", "823456789.567", "8234", "8,234,567.57", 112 "823,456,789.57", "8,234", "8,234,567.5678", "823,456,789.567", "8,234.000", "12%", "12%" }, 113 { "1,234,567", "123,456,789", "1,234", "1234567", "123456789", "1234", "8,234,567.568", 114 "823,456,789.567", "8,234", "8234567.568", "823456789.567", "8234", "8,234,567.57", 115 "823,456,789.57", "8,234", "8,234,567.5678", "823,456,789.567", "8,234.000", "12%", "12%" }, 116 { "1,234,567", "123,456,789", "1,234", "1234567", "123456789", "1234", "8,234,567.568", 117 "823,456,789.567", "8,234", "8234567.568", "823456789.567", "8234", "8,234,567.57", 118 "823,456,789.57", "8,234", "8,234,567.5678", "823,456,789.567", "8,234.000", "12%", "12%" }, 119 { "1,234,567", "123,456,789", "1,234", "1234567", "123456789", "1234", "8,234,567.568", 120 "823,456,789.567", "8,234", "8234567.568", "823456789.567", "8234", "8,234,567.57", 121 "823,456,789.57", "8,234", "8,234,567.5678", "823,456,789.567", "8,234.000", "12%", "12%" }, 122 { "1,234,567", "123,456,789", "1,234", "1234567", "123456789", "1234", "8,234,567.568", 123 "823,456,789.567", "8,234", "8234567.568", "823456789.567", "8234", "8,234,567.57", 124 "823,456,789.57", "8,234", "8,234,567.5678", "823,456,789.567", "8,234.000", "12%", "12%" }, 125 { "1,234,567", "123,456,789", "1,234", "1234567", "123456789", "1234", "8,234,567.568", 126 "823,456,789.567", "8,234", "8234567.568", "823456789.567", "8234", "8,234,567.57", 127 "823,456,789.57", "8,234", "8,234,567.5678", "823,456,789.567", "8,234.000", "12%", "12%" } 128 }; 129 } // namespace testing 130 131 #endif // UNIT_NUMBER_TEST_H 132