1/* 2 * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; 16 17export default function LocaleTest() { 18 describe('LocaleTest', () => { 19 // Defines a test suite. Two parameters are supported: test suite name and test suite function. 20 beforeAll(() => { 21 // Presets an action, which is performed only once before all test cases of the test suite start. 22 // This API supports only one parameter: preset action function. 23 }) 24 beforeEach(() => { 25 // Presets an action, which is performed before each unit test case starts. 26 // The number of execution times is the same as the number of test cases defined by **it**. 27 // This API supports only one parameter: preset action function. 28 }) 29 afterEach(() => { 30 // Presets a clear action, which is performed after each unit test case ends. 31 // The number of execution times is the same as the number of test cases defined by **it**. 32 // This API supports only one parameter: clear action function. 33 }) 34 afterAll(() => { 35 // Presets a clear action, which is performed after all test cases of the test suite end. 36 // This API supports only one parameter: clear action function. 37 }) 38 /** 39 * @tc.number : SUB_COMMONLIBRARY_UTIL_BASE_LOCALE_0100 40 * @tc.name : testLocaleConstructor0001 41 * @tc.desc : Test the function of the interface constructor. 42 * @tc.size : MediumTest 43 * @tc.type : Function 44 * @tc.level : Level 1 45 */ 46 it('testLocaleConstructor0001', 0, async () => { 47 const TAG = "testLocaleConstructor0001"; 48 try { 49 const us = new Intl.Locale("en-US"); 50 let value = us.language; 51 console.log("result:" + value); 52 expect(value).assertEqual('en'); 53 } catch (err) { 54 console.error(`${TAG} failed, error: ${err.message}`); 55 expect().assertFail(); 56 } 57 }) 58 59 /** 60 * @tc.number : SUB_COMMONLIBRARY_UTIL_BASE_LOCALE_0200 61 * @tc.name : testLocaleConstructor0002 62 * @tc.desc : Test the function of the interface constructor. 63 * @tc.size : MediumTest 64 * @tc.type : Function 65 * @tc.level : Level 1 66 */ 67 it('testLocaleConstructor0002', 0, async () => { 68 const TAG = "testLocaleConstructor0002"; 69 try { 70 const locale = new Intl.Locale("en-US", { 71 hourCycle: "h11" 72 }) 73 let value = locale.language; 74 console.log("result:" + value); 75 expect(value).assertEqual('en'); 76 } catch (err) { 77 console.error(`${TAG} failed, error: ${err.message}`); 78 expect().assertFail(); 79 } 80 }) 81 82 /** 83 * @tc.number : SUB_COMMONLIBRARY_UTIL_BASE_LOCALE_0300 84 * @tc.name : testLocaleConstructor0003 85 * @tc.desc : Test the function of the interface constructor. 86 * @tc.size : MediumTest 87 * @tc.type : Function 88 * @tc.level : Level 1 89 */ 90 it('testLocaleConstructor0003', 0, async () => { 91 const TAG = "testLocaleConstructor0003"; 92 try { 93 const locale = new Intl.Locale("en-US", { 94 hourCycle: "h12" 95 }) 96 let value = locale.language; 97 console.log("result:" + value); 98 expect(value).assertEqual('en'); 99 } catch (err) { 100 console.error(`${TAG} failed, error: ${err.message}`); 101 expect().assertFail(); 102 } 103 }) 104 105 /** 106 * @tc.number : SUB_COMMONLIBRARY_UTIL_BASE_LOCALE_0400 107 * @tc.name : testLocaleConstructor0004 108 * @tc.desc : Test the function of the interface constructor. 109 * @tc.size : MediumTest 110 * @tc.type : Function 111 * @tc.level : Level 1 112 */ 113 it('testLocaleConstructor0004', 0, async () => { 114 const TAG = "testLocaleConstructor0004"; 115 try { 116 const locale = new Intl.Locale("en-US", { 117 hourCycle: "h23" 118 }) 119 let value = locale.language; 120 console.log("result:" + value); 121 expect(value).assertEqual('en'); 122 } catch (err) { 123 console.error(`${TAG} failed, error: ${err.message}`); 124 expect().assertFail(); 125 } 126 }) 127 128 /** 129 * @tc.number : SUB_COMMONLIBRARY_UTIL_BASE_LOCALE_0500 130 * @tc.name : testLocaleConstructor0005 131 * @tc.desc : Test the function of the interface constructor. 132 * @tc.size : MediumTest 133 * @tc.type : Function 134 * @tc.level : Level 1 135 */ 136 it('testLocaleConstructor0005', 0, async () => { 137 const TAG = "testLocaleConstructor0005"; 138 try { 139 const locale = new Intl.Locale("en-US", { 140 hourCycle: "h24" 141 }) 142 let value = locale.language; 143 console.log("result:" + value); 144 expect(value).assertEqual('en'); 145 } catch (err) { 146 console.error(`${TAG} failed, error: ${err.message}`); 147 expect().assertFail(); 148 } 149 }) 150 151 /** 152 * @tc.number : SUB_COMMONLIBRARY_UTIL_BASE_LOCALE_0600 153 * @tc.name : testLocale.prototype.toString0001 154 * @tc.desc : Test the function of the interface prototype.toString. 155 * @tc.size : MediumTest 156 * @tc.type : Function 157 * @tc.level : Level 1 158 */ 159 it('testLocale.prototype.toString0001', 0, async () => { 160 const TAG = "testLocale.prototype.toString0001"; 161 try { 162 const myLocale = new Intl.Locale("fr-Latn-FR", { 163 hourCycle: "h11", calendar: "gregory" 164 }) 165 let value = myLocale.toString(); 166 console.log("result:" + value); 167 expect(value).assertEqual('fr-Latn-FR-u-ca-gregory-hc-h11'); 168 } catch (err) { 169 console.error(`${TAG} failed, error: ${err.message}`); 170 expect().assertFail(); 171 } 172 }) 173 174 /** 175 * @tc.number : SUB_COMMONLIBRARY_UTIL_BASE_LOCALE_0700 176 * @tc.name : testLocale.prototype.toString0002 177 * @tc.desc : Test the function of the interface prototype.toString. 178 * @tc.size : MediumTest 179 * @tc.type : Function 180 * @tc.level : Level 1 181 */ 182 it('testLocale.prototype.toString0002', 0, () => { 183 const TAG = "testLocale.prototype.toString0002"; 184 try { 185 const myLocale = new Intl.Locale("fr-Latn-FR", { 186 hourCycle: "h12", calendar: "gregory" 187 }) 188 let value = myLocale.toString(); 189 console.log("result:" + value); 190 expect(value).assertEqual('fr-Latn-FR-u-ca-gregory-hc-h12'); 191 } catch (err) { 192 console.error(`${TAG} failed, error: ${err.message}`); 193 expect().assertFail(); 194 } 195 }) 196 197 /** 198 * @tc.number : SUB_COMMONLIBRARY_UTIL_BASE_LOCALE_0800 199 * @tc.name : testLocale.prototype.toString0003 200 * @tc.desc : Test the function of the interface prototype.toString. 201 * @tc.size : MediumTest 202 * @tc.type : Function 203 * @tc.level : Level 1 204 */ 205 it('testLocale.prototype.toString0003', 0, async () => { 206 const TAG = "testLocale.prototype.toString0003"; 207 try { 208 const myLocale = new Intl.Locale("fr-Latn-FR", { 209 hourCycle: "h23", calendar: "gregory" 210 }) 211 let value = myLocale.toString(); 212 console.log("result:" + value); 213 expect(value).assertEqual('fr-Latn-FR-u-ca-gregory-hc-h23'); 214 } catch (err) { 215 console.error(`${TAG} failed, error: ${err.message}`); 216 expect().assertFail(); 217 } 218 }) 219 220 /** 221 * @tc.number : SUB_COMMONLIBRARY_UTIL_BASE_LOCALE_0900 222 * @tc.name : testLocale.prototype.toString0004 223 * @tc.desc : Test the function of the interface prototype.toString. 224 * @tc.size : MediumTest 225 * @tc.type : Function 226 * @tc.level : Level 1 227 */ 228 it('testLocale.prototype.toString0004', 0, async () => { 229 const TAG = "testLocale.prototype.toString0004"; 230 try { 231 const myLocale = new Intl.Locale("fr-Latn-FR", { 232 hourCycle: "h24", calendar: "gregory" 233 }) 234 let value = myLocale.toString(); 235 console.log("result:" + value); 236 expect(value).assertEqual('fr-Latn-FR-u-ca-gregory-hc-h24'); 237 } catch (err) { 238 console.error(`${TAG} failed, error: ${err.message}`); 239 expect().assertFail(); 240 } 241 }) 242 243 /** 244 * @tc.number : SUB_COMMONLIBRARY_UTIL_BASE_LOCALE_1000 245 * @tc.name : testLocale.prototype.baseName0001 246 * @tc.desc : Test the function of the interface prototype.baseName. 247 * @tc.size : MediumTest 248 * @tc.type : Function 249 * @tc.level : Level 1 250 */ 251 it('testLocale.prototype.baseName0001', 0, async () => { 252 const TAG = "testLocale.prototype.baseName0001"; 253 try { 254 const myLocale = new Intl.Locale("fr-Latn-FR", { 255 hourCycle: "h11", calendar: "gregory" 256 }) 257 let value = myLocale.baseName; 258 console.log("result:" + value); 259 expect(value).assertEqual('fr-Latn-FR'); 260 } catch (err) { 261 console.error(`${TAG} failed, error: ${err.message}`); 262 expect().assertFail(); 263 } 264 }) 265 266 /** 267 * @tc.number : SUB_COMMONLIBRARY_UTIL_BASE_LOCALE_1100 268 * @tc.name : testLocale.prototype.baseName0002 269 * @tc.desc : Test the function of the interface prototype.baseName. 270 * @tc.size : MediumTest 271 * @tc.type : Function 272 * @tc.level : Level 1 273 */ 274 it('testLocale.prototype.baseName0002', 0, async () => { 275 const TAG = "testLocale.prototype.baseName0002"; 276 try { 277 const myLocale = new Intl.Locale("fr-Latn-FR", { 278 hourCycle: "h12", calendar: "gregory" 279 }) 280 let value = myLocale.baseName; 281 console.log("result:" + value); 282 expect(value).assertEqual('fr-Latn-FR'); 283 } catch (err) { 284 console.error(`${TAG} failed, error: ${err.message}`); 285 expect().assertFail(); 286 } 287 }) 288 289 /** 290 * @tc.number : SUB_COMMONLIBRARY_UTIL_BASE_LOCALE_1200 291 * @tc.name : testLocale.prototype.baseName0003 292 * @tc.desc : Test the function of the interface prototype.baseName. 293 * @tc.size : MediumTest 294 * @tc.type : Function 295 * @tc.level : Level 1 296 */ 297 it('testLocale.prototype.baseName0003', 0, async () => { 298 const TAG = "testLocale.prototype.baseName0003"; 299 try { 300 const myLocale = new Intl.Locale("fr-Latn-FR", { 301 hourCycle: "h23", calendar: "gregory" 302 }) 303 let value = myLocale.baseName; 304 console.log("result:" + value); 305 expect(value).assertEqual('fr-Latn-FR'); 306 } catch (err) { 307 console.error(`${TAG} failed, error: ${err.message}`); 308 expect().assertFail(); 309 } 310 }) 311 312 /** 313 * @tc.number : SUB_COMMONLIBRARY_UTIL_BASE_LOCALE_1300 314 * @tc.name : testLocale.prototype.baseName0004 315 * @tc.desc : Test the function of the interface prototype.baseName. 316 * @tc.size : MediumTest 317 * @tc.type : Function 318 * @tc.level : Level 1 319 */ 320 it('testLocale.prototype.baseName0004', 0, async () => { 321 const TAG = "testLocale.prototype.baseName0004"; 322 try { 323 const myLocale = new Intl.Locale("fr-Latn-FR", { 324 hourCycle: "h24", calendar: "gregory" 325 }) 326 let value = myLocale.baseName; 327 console.log("result:" + value); 328 expect(value).assertEqual('fr-Latn-FR'); 329 } catch (err) { 330 console.error(`${TAG} failed, error: ${err.message}`); 331 expect().assertFail(); 332 } 333 }) 334 335 /** 336 * @tc.number : SUB_COMMONLIBRARY_UTIL_BASE_LOCALE_1400 337 * @tc.name : testLocale.prototype.calendar0001 338 * @tc.desc : Test the function of the interface prototype.calendar. 339 * @tc.size : MediumTest 340 * @tc.type : Function 341 * @tc.level : Level 1 342 */ 343 it('testLocale.prototype.calendar0001', 0, async () => { 344 const TAG = "testLocale.prototype.calendar0001"; 345 try { 346 const locale = new Intl.Locale("fr-FR-u-ca-buddhist"); 347 let value = locale.calendar; 348 console.log("result:" + value); 349 expect(value).assertEqual('buddhist'); 350 } catch (err) { 351 console.error(`${TAG} failed, error: ${err.message}`); 352 expect().assertFail(); 353 } 354 }) 355 356 /** 357 * @tc.number : SUB_COMMONLIBRARY_UTIL_BASE_LOCALE_1500 358 * @tc.name : testLocale.prototype.calendar0002 359 * @tc.desc : Test the function of the interface prototype.calendar. 360 * @tc.size : MediumTest 361 * @tc.type : Function 362 * @tc.level : Level 1 363 */ 364 it('testLocale.prototype.calendar0002', 0, async () => { 365 const TAG = "testLocale.prototype.calendar0002"; 366 try { 367 const locale = new Intl.Locale("fr-FR", { 368 calendar: "buddhist" 369 }) 370 let value = locale.calendar; 371 console.log("result:" + value); 372 expect(value).assertEqual('buddhist'); 373 } catch (err) { 374 console.error(`${TAG} failed, error: ${err.message}`); 375 expect().assertFail(); 376 } 377 }) 378 379 /** 380 * @tc.number : SUB_COMMONLIBRARY_UTIL_BASE_LOCALE_1600 381 * @tc.name : testLocale.prototype.caseFirst0001 382 * @tc.desc : Test the function of the interface prototype.caseFirst. 383 * @tc.size : MediumTest 384 * @tc.type : Function 385 * @tc.level : Level 1 386 */ 387 it('testLocale.prototype.caseFirst0001', 0, async () => { 388 const TAG = "testLocale.prototype.caseFirst0001"; 389 try { 390 const locale = new Intl.Locale("fr-Latn-FR-u-kf-upper"); 391 let value = locale.caseFirst; 392 console.log("result:" + value); 393 expect(value).assertEqual('upper'); 394 } catch (err) { 395 console.error(`${TAG} failed, error: ${err.message}`); 396 expect().assertFail(); 397 } 398 }) 399 400 /** 401 * @tc.number : SUB_COMMONLIBRARY_UTIL_BASE_LOCALE_1700 402 * @tc.name : testLocale.prototype.caseFirst0002 403 * @tc.desc : Test the function of the interface prototype.caseFirst. 404 * @tc.size : MediumTest 405 * @tc.type : Function 406 * @tc.level : Level 1 407 */ 408 it('testLocale.prototype.caseFirst0002', 0, async () => { 409 const TAG = "testLocale.prototype.caseFirst0002"; 410 try { 411 const locale = new Intl.Locale("en-Latn-US", { 412 caseFirst: "lower" 413 }) 414 let value = locale.caseFirst; 415 console.log("result:" + value); 416 expect(value).assertEqual('lower'); 417 } catch (err) { 418 console.error(`${TAG} failed, error: ${err.message}`); 419 expect().assertFail(); 420 } 421 }) 422 423 /** 424 * @tc.number : SUB_COMMONLIBRARY_UTIL_BASE_LOCALE_1800 425 * @tc.name : testLocalePrototypeCollation0001 426 * @tc.desc : Test the function of the interface prototype.collation. 427 * @tc.size : MediumTest 428 * @tc.type : Function 429 * @tc.level : Level 1 430 */ 431 it('testLocalePrototypeCollation0001', 0, async () => { 432 const TAG = "testLocalePrototypeCollation0001"; 433 try { 434 const locale = new Intl.Locale("zh-Hant-u-co-zhuyin"); 435 let value = locale.collation; 436 console.log("result:" + value); 437 expect(value).assertEqual('zhuyin'); 438 } catch (err) { 439 console.error(`${TAG} failed, error: ${err.message}`); 440 expect().assertFail(); 441 } 442 }) 443 444 /** 445 * @tc.number : SUB_COMMONLIBRARY_UTIL_BASE_LOCALE_1900 446 * @tc.name : testLocalePrototypeCollation0002 447 * @tc.desc : Test the function of the interface prototype.collation. 448 * @tc.size : MediumTest 449 * @tc.type : Function 450 * @tc.level : Level 1 451 */ 452 it('testLocalePrototypeCollation0002', 0, async () => { 453 const TAG = "testLocalePrototypeCollation0002"; 454 try { 455 const locale = new Intl.Locale("zh-Hant", { 456 collation: "zhuyin" 457 }) 458 let value = locale.collation; 459 console.log("result:" + value); 460 expect(value).assertEqual('zhuyin'); 461 } catch (err) { 462 console.error(`${TAG} failed, error: ${err.message}`); 463 expect().assertFail(); 464 } 465 }) 466 467 /** 468 * @tc.number : SUB_COMMONLIBRARY_UTIL_BASE_LOCALE_2000 469 * @tc.name : testLocalePrototypeHourCycle0001 470 * @tc.desc : Test the function of the interface prototype.hourCycle. 471 * @tc.size : MediumTest 472 * @tc.type : Function 473 * @tc.level : Level 1 474 */ 475 it('testLocalePrototypeHourCycle0001', 0, async () => { 476 const TAG = "testLocalePrototypeHourCycle0001"; 477 try { 478 const locale = new Intl.Locale("fr-FR-u-hc-h23"); 479 let value = locale.hourCycle; 480 console.log("result:" + value); 481 expect(value).assertEqual('h23'); 482 } catch (err) { 483 console.error(`${TAG} failed, error: ${err.message}`); 484 expect().assertFail(); 485 } 486 }) 487 488 /** 489 * @tc.number : SUB_COMMONLIBRARY_UTIL_BASE_LOCALE_2100 490 * @tc.name : testLocalePrototypeHourCycle0002 491 * @tc.desc : Test the function of the interface prototype.hourCycle. 492 * @tc.size : MediumTest 493 * @tc.type : Function 494 * @tc.level : Level 1 495 */ 496 it('testLocalePrototypeHourCycle0002', 0, async () => { 497 const TAG = "testLocalePrototypeHourCycle0002"; 498 try { 499 const locale = new Intl.Locale("en-US", { 500 hourCycle: "h12" 501 }) 502 let value = locale.hourCycle; 503 console.log("result:" + value); 504 expect(value).assertEqual('h12'); 505 } catch (err) { 506 console.error(`${TAG} failed, error: ${err.message}`); 507 expect().assertFail(); 508 } 509 }) 510 511 /** 512 * @tc.number : SUB_COMMONLIBRARY_UTIL_BASE_LOCALE_2200 513 * @tc.name : testLocalePrototypeLanguage0001 514 * @tc.desc : Test the function of the interface prototype.language. 515 * @tc.size : MediumTest 516 * @tc.type : Function 517 * @tc.level : Level 1 518 */ 519 it('testLocalePrototypeLanguage0001', 0, async () => { 520 const TAG = "testLocalePrototypeLanguage0001"; 521 try { 522 const locale = new Intl.Locale("en-Latn-US"); 523 let value = locale.language; 524 console.log("result:" + value); 525 expect(value).assertEqual('en'); 526 } catch (err) { 527 console.error(`${TAG} failed, error: ${err.message}`); 528 expect().assertFail(); 529 } 530 }) 531 532 /** 533 * @tc.number : SUB_COMMONLIBRARY_UTIL_BASE_LOCALE_2300 534 * @tc.name : testLocalePrototypeLanguage0002 535 * @tc.desc : Test the function of the interface prototype.language. 536 * @tc.size : MediumTest 537 * @tc.type : Function 538 * @tc.level : Level 1 539 */ 540 it('testLocalePrototypeLanguage0002', 0, async () => { 541 const TAG = "testLocalePrototypeLanguage0002"; 542 try { 543 const locale = new Intl.Locale("en-Latn-US", { 544 language: "es" 545 }) 546 let value = locale.language; 547 console.log("result:" + value); 548 expect(value).assertEqual('es'); 549 } catch (err) { 550 console.error(`${TAG} failed, error: ${err.message}`); 551 expect().assertFail(); 552 } 553 }) 554 555 /** 556 * @tc.number : SUB_COMMONLIBRARY_UTIL_BASE_LOCALE_2400 557 * @tc.name : testLocalePrototypeNumberingSystem0001 558 * @tc.desc : Test the function of the interface prototype.numberingSystem. 559 * @tc.size : MediumTest 560 * @tc.type : Function 561 * @tc.level : Level 1 562 */ 563 it('testLocalePrototypeNumberingSystem0001', 0, async () => { 564 const TAG = "testLocalePrototypeNumberingSystem0001"; 565 try { 566 const locale = new Intl.Locale("fr-Latn-FR-u-nu-mong"); 567 let value = locale.numberingSystem; 568 console.log("result:" + value); 569 expect(value).assertEqual('mong'); 570 } catch (err) { 571 console.error(`${TAG} failed, error: ${err.message}`); 572 expect().assertFail(); 573 } 574 }) 575 576 /** 577 * @tc.number : SUB_COMMONLIBRARY_UTIL_BASE_LOCALE_2500 578 * @tc.name : testLocalePrototypeNumberingSystem0002 579 * @tc.desc : Test the function of the interface prototype.numberingSystem. 580 * @tc.size : MediumTest 581 * @tc.type : Function 582 * @tc.level : Level 1 583 */ 584 it('testLocalePrototypeNumberingSystem0002', 0, async () => { 585 const TAG = "testLocalePrototypeNumberingSystem0002"; 586 try { 587 const locale = new Intl.Locale("en-Latn-US", { 588 numberingSystem: "latn" 589 }) 590 let value = locale.numberingSystem; 591 console.log("result:" + value); 592 expect(value).assertEqual('latn'); 593 } catch (err) { 594 console.error(`${TAG} failed, error: ${err.message}`); 595 expect().assertFail(); 596 } 597 }) 598 599 /** 600 * @tc.number : SUB_COMMONLIBRARY_UTIL_BASE_LOCALE_2600 601 * @tc.name : testLocalePrototypeNumeric0001 602 * @tc.desc : Test the function of the interface prototype.numeric. 603 * @tc.size : MediumTest 604 * @tc.type : Function 605 * @tc.level : Level 1 606 */ 607 it('testLocalePrototypeNumeric0001', 0, async () => { 608 const TAG = "testLocalePrototypeNumeric0001"; 609 try { 610 const locale = new Intl.Locale("fr-Latn-FR-u-kn-false"); 611 let value = locale.numeric; 612 console.log("result:" + value); 613 expect(value).assertEqual(false); 614 } catch (err) { 615 console.error(`${TAG} failed, error: ${err.message}`); 616 expect().assertFail(); 617 } 618 }) 619 620 /** 621 * @tc.number : SUB_COMMONLIBRARY_UTIL_BASE_LOCALE_2700 622 * @tc.name : testLocalePrototypeNumeric0002 623 * @tc.desc : Test the function of the interface prototype.numeric. 624 * @tc.size : MediumTest 625 * @tc.type : Function 626 * @tc.level : Level 1 627 */ 628 it('testLocalePrototypeNumeric0002', 0, async () => { 629 const TAG = "testLocalePrototypeNumeric0002"; 630 try { 631 const locale = new Intl.Locale("en-Latn-US", { 632 numeric: true 633 }) 634 let value = locale.numeric; 635 console.log("result:" + value); 636 expect(value).assertEqual(true); 637 } catch (err) { 638 console.error(`${TAG} failed, error: ${err.message}`); 639 expect().assertFail(); 640 } 641 }) 642 643 /** 644 * @tc.number : SUB_COMMONLIBRARY_UTIL_BASE_LOCALE_2800 645 * @tc.name : testLocalePrototypeRegion0001 646 * @tc.desc : Test the function of the interface prototype.region. 647 * @tc.size : MediumTest 648 * @tc.type : Function 649 * @tc.level : Level 1 650 */ 651 it('testLocalePrototypeRegion0001', 0, async () => { 652 const TAG = "testLocalePrototypeRegion0001"; 653 try { 654 const locale = new Intl.Locale("en-Latn-US"); 655 let value = locale.region; 656 console.log("result:" + value); 657 expect(value).assertEqual('US'); 658 } catch (err) { 659 console.error(`${TAG} failed, error: ${err.message}`); 660 expect().assertFail(); 661 } 662 }) 663 664 /** 665 * @tc.number : SUB_COMMONLIBRARY_UTIL_BASE_LOCALE_2900 666 * @tc.name : testLocalePrototypeRegion0002 667 * @tc.desc : Test the function of the interface prototype.region. 668 * @tc.size : MediumTest 669 * @tc.type : Function 670 * @tc.level : Level 1 671 */ 672 it('testLocalePrototypeRegion0002', 0, async () => { 673 const TAG = "testLocalePrototypeRegion0002"; 674 try { 675 const locale = new Intl.Locale("fr-Latn", { 676 region: "FR" 677 }) 678 let value = locale.region; 679 console.log("result:" + value); 680 expect(value).assertEqual('FR'); 681 } catch (err) { 682 console.error(`${TAG} failed, error: ${err.message}`); 683 expect().assertFail(); 684 } 685 }) 686 687 /** 688 * @tc.number : SUB_COMMONLIBRARY_UTIL_BASE_LOCALE_3000 689 * @tc.name : testLocalePrototypeScript0001 690 * @tc.desc : Test the function of the interface prototype.script. 691 * @tc.size : MediumTest 692 * @tc.type : Function 693 * @tc.level : Level 1 694 */ 695 it('testLocalePrototypeScript0001', 0, async () => { 696 const TAG = "testLocalePrototypeScript0001"; 697 try { 698 const locale = new Intl.Locale("en-Latn-US"); 699 let value = locale.script; 700 console.log("result:" + value); 701 expect(value).assertEqual('Latn'); 702 } catch (err) { 703 console.error(`${TAG} failed, error: ${err.message}`); 704 expect().assertFail(); 705 } 706 }) 707 708 /** 709 * @tc.number : SUB_COMMONLIBRARY_UTIL_BASE_LOCALE_3100 710 * @tc.name : testLocalePrototypeScript0002 711 * @tc.desc : Test the function of the interface prototype.script. 712 * @tc.size : MediumTest 713 * @tc.type : Function 714 * @tc.level : Level 1 715 */ 716 it('testLocalePrototypeScript0002', 0, async () => { 717 const TAG = "testLocalePrototypeScript0002"; 718 try { 719 const locale = new Intl.Locale("fr-FR", { 720 script: "Latn" 721 }) 722 let value = locale.script; 723 console.log("result:" + value); 724 expect(value).assertEqual('Latn'); 725 } catch (err) { 726 console.error(`${TAG} failed, error: ${err.message}`); 727 expect().assertFail(); 728 } 729 }) 730 }) 731}