1/* 2 * Copyright (C) 2023 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 */ 15import I18n from '@ohos.i18n' 16import Intl from '@ohos.intl' 17import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium' 18 19export default function PluralRulesInIntlTest() { 20describe('PluralRulesInIntlTest', function () { 21 console.log('*************start PluralRulesInIntlTest*************'); 22 23 let hour = I18n.System.is24HourClock(); 24 console.log('init 24 hour clock value ' + hour); 25 26 /* * 27 * execute this step before all testcases 28 */ 29 beforeAll(function(){ 30 console.log('step before all cases in I18n.' 31 + ' 24hour: ' + I18n.System.is24HourClock() 32 + ' prelang: ' + I18n.System.getPreferredLanguageList() 33 + ' syslocale: ' + I18n.System.getSystemLocale()); 34 }) 35 36 /* * 37 * execute this step before every testcase 38 */ 39 beforeEach(function(){ 40 console.log('step before every case in I18n.'); 41 }) 42 43 /* * 44 * execute this step after every testcase 45 */ 46 afterEach(function(){ 47 console.log('step after every case in I18n.'); 48 }) 49 50 /* * 51 * execute this step after all testcases 52 */ 53 afterAll(function(){ 54 console.log('step after all cases in I18n.' 55 + ' 24hour: ' + I18n.System.is24HourClock() 56 + ' prelang: ' + I18n.System.getPreferredLanguageList() 57 + ' syslocale: ' + I18n.System.getSystemLocale()); 58 }) 59 60 /* * 61 * @tc.number SUB_GLOBAL_INTL_JS_PLURAL_2600 62 * @tc.name get PluralRules 63 * @tc.desc check the select result 64 */ 65 it('pluralrules_test_2600', 0, function () { 66 let pl = new Intl.PluralRules(); 67 let value = pl.select(0); 68 console.log('pluralrules_test_2600 ' + value); 69 expect(value).assertEqual('other'); 70 }) 71 72 /* * 73 * @tc.number SUB_GLOBAL_INTL_JS_PLURAL_2700 74 * @tc.name get PluralRules with zh locale 75 * @tc.desc check the select result 76 */ 77 it('pluralrules_test_2700', 0, function () { 78 let pl = new Intl.PluralRules('zh'); 79 let value = pl.select(0); 80 console.log('pluralrules_test_2700 ' + value); 81 expect(value).assertEqual('other'); 82 }) 83 84 /* * 85 * @tc.number SUB_GLOBAL_INTL_JS_PLURAL_2720 86 * @tc.name get PluralRules with zh locale and undefined options 87 * @tc.desc check the select result 88 */ 89 it('pluralrules_test_2720', 0, function () { 90 let pl = new Intl.PluralRules('zh', undefined); 91 let value = pl.select(0); 92 console.log('pluralrules_test_2720 ' + value); 93 expect(value).assertEqual('other'); 94 }) 95 96 /* * 97 * @tc.number SUB_GLOBAL_INTL_JS_PLURAL_2740 98 * @tc.name get PluralRules with zh locale and null options 99 * @tc.desc check the select result 100 */ 101 it('pluralrules_test_2740', 0, function () { 102 let pl = new Intl.PluralRules('zh', null); 103 let value = pl.select(0); 104 console.log('pluralrules_test_2740 ' + value); 105 expect(value).assertEqual('other'); 106 }) 107 108 /* * 109 * @tc.number SUB_GLOBAL_INTL_JS_PLURAL_2800 110 * @tc.name get PluralRules with zh locale and ordinal type 111 * @tc.desc check the select result 112 */ 113 it('pluralrules_test_2800', 0, function () { 114 let pl = new Intl.PluralRules('zh', {'type': 'ordinal'}); 115 let value = pl.select(0); 116 console.log('pluralrules_test_2800 ' + value); 117 expect(value).assertEqual('other'); 118 }) 119 120 /* * 121 * @tc.number SUB_GLOBAL_INTL_JS_PLURAL_2900 122 * @tc.name get PluralRules with zh locale and loolup localeMatcher 123 * @tc.desc check the select result 124 */ 125 it('pluralrules_test_2900', 0, function () { 126 let pl = new Intl.PluralRules('zh', {'localeMatcher': 'lookup'}); 127 let value = pl.select(0); 128 console.log('pluralrules_test_2900 ' + value); 129 expect(value).assertEqual('other'); 130 }) 131 132 /* * 133 * @tc.number SUB_GLOBAL_INTL_JS_PLURAL_3000 134 * @tc.name get PluralRules with zh locale and minimumIntegerDigits options 135 * @tc.desc check the select result 136 */ 137 it('pluralrules_test_3000', 0, function () { 138 let pl = new Intl.PluralRules('zh', {'minimumIntegerDigits': 10}); 139 let value = pl.select(0); 140 console.log('pluralrules_test_3000 ' + value); 141 expect(value).assertEqual('other'); 142 }) 143 144 /* * 145 * @tc.number SUB_GLOBAL_INTL_JS_PLURAL_3100 146 * @tc.name get PluralRules with zh locale and minimumFractionDigits options 147 * @tc.desc check the select result 148 */ 149 it('pluralrules_test_3100', 0, function () { 150 let pl = new Intl.PluralRules('zh', {'minimumFractionDigits': 11}); 151 let value = pl.select(0); 152 console.log('pluralrules_test_3100 ' + value); 153 expect(value).assertEqual('other'); 154 }) 155 156 /* * 157 * @tc.number SUB_GLOBAL_INTL_JS_PLURAL_3200 158 * @tc.name get PluralRules with zh locale and maximumFractionDigits options 159 * @tc.desc check the select result 160 */ 161 it('pluralrules_test_3200', 0, function () { 162 let pl = new Intl.PluralRules('zh', {'maximumFractionDigits': 'lookup'}); 163 let value = pl.select(0); 164 console.log('pluralrules_test_3200 ' + value); 165 expect(value).assertEqual('other'); 166 }) 167 168 /* * 169 * @tc.number SUB_GLOBAL_INTL_JS_PLURAL_3300 170 * @tc.name get PluralRules with zh locale and minimumSignificantDigits options 171 * @tc.desc check the select result 172 */ 173 it('pluralrules_test_3300', 0, function () { 174 let pl = new Intl.PluralRules('zh', {'minimumSignificantDigits': 10}); 175 let value = pl.select(0); 176 console.log('pluralrules_test_3300 ' + value); 177 expect(value).assertEqual('other'); 178 }) 179 180 /* * 181 * @tc.number SUB_GLOBAL_INTL_JS_PLURAL_3400 182 * @tc.name get PluralRules with zh locale and maximumSignificantDigits options 183 * @tc.desc check the select result 184 */ 185 it('pluralrules_test_3400', 0, function () { 186 let pl = new Intl.PluralRules('zh', {'maximumSignificantDigits': 11}); 187 let value = pl.select(0); 188 console.log('pluralrules_test_3400 ' + value); 189 expect(value).assertEqual('other'); 190 }) 191 192 console.log('*************end PluralRulesInIntlTest*************'); 193})} 194