Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
fadcc00e
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
1 年多 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
fadcc00e
编写于
5月 27, 2023
作者:
O
openharmony_ci
提交者:
Gitee
5月 27, 2023
浏览文件
操作
浏览文件
下载
差异文件
!8781 modify intl module cases to 4.0beta1
Merge pull request !8781 from 杨清/cherry-pick-1685100652
上级
ee1cab27
99d0ab82
变更
8
展开全部
显示空白变更内容
内联
并排
Showing
8 changed file
with
1561 addition
and
516 deletion
+1561
-516
global/i18n_standard/intljs/src/main/js/test/CollatorInIntl.test.js
...n_standard/intljs/src/main/js/test/CollatorInIntl.test.js
+224
-0
global/i18n_standard/intljs/src/main/js/test/DateTimeFormatInIntl.test.js
...dard/intljs/src/main/js/test/DateTimeFormatInIntl.test.js
+454
-0
global/i18n_standard/intljs/src/main/js/test/I18n.test.js
global/i18n_standard/intljs/src/main/js/test/I18n.test.js
+0
-459
global/i18n_standard/intljs/src/main/js/test/Lang.test.js
global/i18n_standard/intljs/src/main/js/test/Lang.test.js
+0
-55
global/i18n_standard/intljs/src/main/js/test/List.test.js
global/i18n_standard/intljs/src/main/js/test/List.test.js
+10
-2
global/i18n_standard/intljs/src/main/js/test/NumberFormatInIntl.test.js
...andard/intljs/src/main/js/test/NumberFormatInIntl.test.js
+475
-0
global/i18n_standard/intljs/src/main/js/test/PluralRulesInIntl.test.js
...tandard/intljs/src/main/js/test/PluralRulesInIntl.test.js
+193
-0
global/i18n_standard/intljs/src/main/js/test/RelativeTimeFormatInIntl.test.js
.../intljs/src/main/js/test/RelativeTimeFormatInIntl.test.js
+205
-0
未找到文件。
global/i18n_standard/intljs/src/main/js/test/CollatorInIntl.test.js
0 → 100644
浏览文件 @
fadcc00e
/*
* Copyright (C) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
I18n
from
'
@ohos.i18n
'
import
Intl
from
'
@ohos.intl
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
export
default
function
CollatorInIntlTest
()
{
describe
(
'
CollatorInIntlTest
'
,
function
()
{
console
.
log
(
'
*************start CollatorInIntlTest*************
'
);
let
hour
=
I18n
.
System
.
is24HourClock
();
console
.
log
(
'
init 24 hour clock value
'
+
hour
);
/* *
* execute this step before all testcases
*/
beforeAll
(
function
(){
console
.
log
(
'
step before all cases in I18n.
'
+
'
24hour:
'
+
I18n
.
System
.
is24HourClock
()
+
'
prelang:
'
+
I18n
.
System
.
getPreferredLanguageList
()
+
'
syslocale:
'
+
I18n
.
System
.
getSystemLocale
());
})
/* *
* execute this step before every testcase
*/
beforeEach
(
function
(){
console
.
log
(
'
step before every case in I18n.
'
);
})
/* *
* execute this step after every testcase
*/
afterEach
(
function
(){
console
.
log
(
'
step after every case in I18n.
'
);
})
/* *
* execute this step after all testcases
*/
afterAll
(
function
(){
console
.
log
(
'
step after all cases in I18n.
'
+
'
24hour:
'
+
I18n
.
System
.
is24HourClock
()
+
'
prelang:
'
+
I18n
.
System
.
getPreferredLanguageList
()
+
'
syslocale:
'
+
I18n
.
System
.
getSystemLocale
());
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_COLLATOR_3500
* @tc.name compare two different strings
* @tc.desc check the compare result
*/
it
(
'
collator_test_3500
'
,
0
,
function
()
{
let
coll
=
new
Intl
.
Collator
();
let
value
=
coll
.
compare
(
'
a
'
,
'
b
'
);
console
.
log
(
'
collator_test_3500
'
+
value
);
expect
(
value
).
assertEqual
(
-
1
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_COLLATOR_3510
* @tc.name compare the same strings
* @tc.desc check the compare result
*/
it
(
'
collator_test_3510
'
,
0
,
function
()
{
let
coll
=
new
Intl
.
Collator
();
let
value
=
coll
.
compare
(
'
a
'
,
'
a
'
);
console
.
log
(
'
collator_test_3100
'
+
value
);
expect
(
value
).
assertEqual
(
0
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_COLLATOR_3520
* @tc.name compare two different strings and return positive value
* @tc.desc check the compare result
*/
it
(
'
collator_test_3520
'
,
0
,
function
()
{
let
coll
=
new
Intl
.
Collator
();
let
value
=
coll
.
compare
(
'
b
'
,
'
a
'
);
console
.
log
(
'
collator_test_3200
'
+
value
);
expect
(
value
).
assertEqual
(
1
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_COLLATOR_3600
* @tc.name compare two different strings with zh locale
* @tc.desc check the compare result
*/
it
(
'
collator_test_3600
'
,
0
,
function
()
{
let
coll
=
new
Intl
.
Collator
(
'
zh
'
);
let
value
=
coll
.
compare
(
'
a
'
,
'
b
'
);
console
.
log
(
'
collator_test_3600
'
+
value
);
expect
(
value
).
assertEqual
(
-
1
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_COLLATOR_3620
* @tc.name compare two different strings with zh locale and undefined options
* @tc.desc check the compare result
*/
it
(
'
collator_test_3620
'
,
0
,
function
()
{
let
coll
=
new
Intl
.
Collator
(
'
zh
'
,
undefined
);
let
value
=
coll
.
compare
(
'
a
'
,
'
b
'
);
console
.
log
(
'
collator_test_3620
'
+
value
);
expect
(
value
).
assertEqual
(
-
1
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_COLLATOR_3640
* @tc.name compare two different strings with zh locale and null options
* @tc.desc check the compare result
*/
it
(
'
collator_test_3640
'
,
0
,
function
()
{
let
coll
=
new
Intl
.
Collator
(
'
zh
'
,
null
);
let
value
=
coll
.
compare
(
'
a
'
,
'
b
'
);
console
.
log
(
'
collator_test_3640
'
+
value
);
expect
(
value
).
assertEqual
(
-
1
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_COLLATOR_3700
* @tc.name compare two different strings with zh locale and eor collation
* @tc.desc check the compare result
*/
it
(
'
collator_test_3700
'
,
0
,
function
()
{
let
coll
=
new
Intl
.
Collator
(
'
zh
'
,
{
'
collation
'
:
'
eor
'
});
let
value
=
coll
.
compare
(
'
a
'
,
'
b
'
);
console
.
log
(
'
collator_test_3700
'
+
value
);
expect
(
value
).
assertEqual
(
-
1
);
expect
(
coll
.
resolvedOptions
().
collation
).
assertEqual
(
'
eor
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_COLLATOR_3800
* @tc.name compare two different strings with zh locale and base sensitivity
* @tc.desc check the compare result
*/
it
(
'
collator_test_3800
'
,
0
,
function
()
{
let
coll
=
new
Intl
.
Collator
(
'
zh
'
,
{
'
sensitivity
'
:
'
base
'
});
let
value
=
coll
.
compare
(
'
a
'
,
'
b
'
);
console
.
log
(
'
collator_test_3800
'
+
value
);
expect
(
value
).
assertEqual
(
-
1
);
expect
(
coll
.
resolvedOptions
().
sensitivity
).
assertEqual
(
'
base
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_COLLATOR_3900
* @tc.name compare two different strings with zh locale and upper caseFirst
* @tc.desc check the compare result
*/
it
(
'
collator_test_3900
'
,
0
,
function
()
{
let
coll
=
new
Intl
.
Collator
(
'
zh
'
,
{
'
caseFirst
'
:
'
upper
'
});
let
value
=
coll
.
compare
(
'
a
'
,
'
b
'
);
console
.
log
(
'
collator_test_3900
'
+
value
);
expect
(
value
).
assertEqual
(
-
1
);
expect
(
coll
.
resolvedOptions
().
caseFirst
).
assertEqual
(
'
upper
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_COLLATOR_4000
* @tc.name compare two different strings with zh locale and true numeric
* @tc.desc check the compare result
*/
it
(
'
collator_test_4000
'
,
0
,
function
()
{
let
coll
=
new
Intl
.
Collator
(
'
zh
'
,
{
'
numeric
'
:
true
});
let
value
=
coll
.
compare
(
'
a
'
,
'
b
'
);
console
.
log
(
'
collator_test_4000
'
+
value
);
expect
(
value
).
assertEqual
(
-
1
);
expect
(
coll
.
resolvedOptions
().
numeric
).
assertTrue
();
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_COLLATOR_4100
* @tc.name compare two different strings with zh locale and true ignorePunctuation
* @tc.desc check the compare result
*/
it
(
'
collator_test_4100
'
,
0
,
function
()
{
let
coll
=
new
Intl
.
Collator
(
'
zh
'
,
{
'
ignorePunctuation
'
:
true
});
let
value
=
coll
.
compare
(
'
a
'
,
'
b
'
);
console
.
log
(
'
collator_test_4100
'
+
value
);
expect
(
value
).
assertEqual
(
-
1
);
expect
(
coll
.
resolvedOptions
().
ignorePunctuation
).
assertTrue
();
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_COLLATOR_4200
* @tc.name compare two different strings with zh locale and sort usage
* @tc.desc check the compare result
*/
it
(
'
collator_test_4200
'
,
0
,
function
()
{
let
coll
=
new
Intl
.
Collator
(
'
zh
'
,
{
'
usage
'
:
'
sort
'
});
let
value
=
coll
.
compare
(
'
a
'
,
'
b
'
);
console
.
log
(
'
collator_test_4200
'
+
value
);
expect
(
value
).
assertEqual
(
-
1
);
expect
(
coll
.
resolvedOptions
().
usage
).
assertEqual
(
'
sort
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_COLLATOR_4300
* @tc.name compare the string with localeMatcher options
* @tc.desc check the compare result
*/
it
(
'
collator_test_4300
'
,
0
,
function
()
{
let
coll
=
new
Intl
.
Collator
(
'
zh
'
,
{
'
localeMatcher
'
:
'
lookup
'
});
let
value
=
coll
.
compare
(
'
a
'
,
'
b
'
);
console
.
log
(
'
collator_test_4300
'
+
value
);
expect
(
value
).
assertEqual
(
-
1
);
expect
(
coll
.
resolvedOptions
().
localeMatcher
).
assertEqual
(
'
lookup
'
);
})
console
.
log
(
'
*************end CollatorInIntlTest*************
'
);
})}
global/i18n_standard/intljs/src/main/js/test/DateTimeFormatInIntl.test.js
0 → 100644
浏览文件 @
fadcc00e
此差异已折叠。
点击以展开。
global/i18n_standard/intljs/src/main/js/test/I18n.test.js
浏览文件 @
fadcc00e
...
...
@@ -68,17 +68,6 @@ describe('I18nTest', function () {
expect
(
lang
).
assertInstanceOf
(
'
String
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_0120
* @tc.name getSystemLanguage
* @tc.desc check the getSystemLanguage
*/
it
(
'
i18n_test_0120
'
,
0
,
function
()
{
let
lang
=
I18n
.
System
.
getSystemLanguage
();
console
.
log
(
'
i18n_test_0120
'
+
lang
);
expect
(
lang
).
assertInstanceOf
(
'
String
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_0200
* @tc.name getSystemRegion
...
...
@@ -90,17 +79,6 @@ describe('I18nTest', function () {
expect
(
region
).
assertInstanceOf
(
'
String
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_0220
* @tc.name getSystemRegion
* @tc.desc check the getSystemRegion
*/
it
(
'
i18n_test_0220
'
,
0
,
function
()
{
let
region
=
I18n
.
System
.
getSystemRegion
();
console
.
log
(
'
i18n_test_0220
'
+
region
);
expect
(
region
).
assertInstanceOf
(
'
String
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_0300
* @tc.name getSystemLocale
...
...
@@ -112,90 +90,6 @@ describe('I18nTest', function () {
expect
(
locale
).
assertInstanceOf
(
'
String
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_0320
* @tc.name getSystemLocale
* @tc.desc check the getSystemLocale
*/
it
(
'
i18n_test_0320
'
,
0
,
function
()
{
let
locale
=
I18n
.
System
.
getSystemLocale
();
console
.
log
(
'
i18n_test_0320
'
+
locale
);
expect
(
locale
).
assertInstanceOf
(
'
String
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_0340
* @tc.name is24HourClock
* @tc.desc check the is24HourClock
*/
it
(
'
i18n_test_0340
'
,
0
,
function
()
{
let
value
=
I18n
.
System
.
is24HourClock
();
console
.
log
(
'
i18n_test_0340
'
+
value
);
expect
(
value
).
assertFalse
();
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_2110
* @tc.name getSystemLanguages test
* @tc.desc check the getSystemLanguages
*/
it
(
'
i18n_test_2110
'
,
0
,
function
()
{
let
value
=
I18n
.
System
.
getSystemLanguages
();
let
len
=
value
.
length
;
console
.
log
(
'
i18n_test_2110
'
+
len
);
expect
(
len
).
assertLarger
(
0
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_2120
* @tc.name getSystemCountries with en param
* @tc.desc check the getSystemCountries
*/
it
(
'
i18n_test_2120
'
,
0
,
function
()
{
let
value
=
I18n
.
System
.
getSystemCountries
(
'
en
'
);
let
len
=
value
.
length
;
console
.
log
(
'
i18n_test_2120
'
+
len
);
expect
(
len
).
assertLarger
(
0
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_2140
* @tc.name getSystemCountries with en param
* @tc.desc check the getSystemCountries
*/
it
(
'
i18n_test_2140
'
,
0
,
function
()
{
try
{
let
value
=
I18n
.
System
.
getSystemCountries
();
let
len
=
value
.
length
;
console
.
log
(
'
i18n_test_2140
'
+
len
);
expect
(
len
).
assertLarger
(
0
);
}
catch
(
e
){
console
.
log
(
'
i18n_test_2140
'
+
e
.
code
);
console
.
log
(
'
i18n_test_2140
'
+
e
.
message
);
expect
(
e
.
code
).
assertEqual
(
'
401
'
);
expect
(
e
.
message
).
assertEqual
(
'
Check param failed
'
);
}
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_2160
* @tc.name getSystemCountries with en param
* @tc.desc check the getSystemCountries
*/
it
(
'
i18n_test_2160
'
,
0
,
function
()
{
try
{
let
value
=
I18n
.
System
.
getSystemCountries
(
12345
);
let
len
=
value
.
length
;
console
.
log
(
'
i18n_test_2160
'
+
len
);
expect
(
len
).
assertLarger
(
0
);
}
catch
(
e
){
console
.
log
(
'
i18n_test_2160
'
+
e
.
code
);
console
.
log
(
'
i18n_test_2160
'
+
e
.
message
);
expect
(
e
.
code
).
assertEqual
(
'
890001
'
);
expect
(
e
.
message
).
assertEqual
(
'
Param value not valid
'
);
}
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_2310
* @tc.name isSuggested with zh param
...
...
@@ -240,86 +134,6 @@ describe('I18nTest', function () {
expect
(
value
).
assertTrue
();
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_2350
* @tc.name isSuggested with zh param
* @tc.desc check the isSuggested
*/
it
(
'
i18n_test_2350
'
,
0
,
function
()
{
let
value
=
I18n
.
System
.
isSuggested
(
'
zh
'
);
console
.
log
(
'
i18n_test_2350
'
+
value
);
expect
(
value
).
assertTrue
();
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_2360
* @tc.name isSuggested with en param
* @tc.desc check the isSuggested
*/
it
(
'
i18n_test_2360
'
,
0
,
function
()
{
let
value
=
I18n
.
System
.
isSuggested
(
'
en
'
);
console
.
log
(
'
i18n_test_2360
'
+
value
);
expect
(
value
).
assertFalse
();
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_2370
* @tc.name isSuggested with zh-CN param
* @tc.desc check the isSuggested
*/
it
(
'
i18n_test_2370
'
,
0
,
function
()
{
let
value
=
I18n
.
System
.
isSuggested
(
'
zh
'
,
'
CN
'
);
console
.
log
(
'
i18n_test_2370
'
+
value
);
expect
(
value
).
assertTrue
();
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_2380
* @tc.name isSuggested with en-US param
* @tc.desc check the isSuggested
*/
it
(
'
i18n_test_2380
'
,
0
,
function
()
{
let
value
=
I18n
.
System
.
isSuggested
(
'
en
'
,
'
US
'
);
console
.
log
(
'
i18n_test_2380
'
+
value
);
expect
(
value
).
assertTrue
();
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_2390
* @tc.name isSuggested with en-US param
* @tc.desc check the isSuggested
*/
it
(
'
i18n_test_2390
'
,
0
,
function
()
{
try
{
let
value
=
I18n
.
System
.
isSuggested
();
console
.
log
(
'
i18n_test_2390
'
+
value
);
expect
(
value
).
assertTrue
();
}
catch
(
e
){
console
.
log
(
'
i18n_test_2390
'
+
e
.
code
);
console
.
log
(
'
i18n_test_2390
'
+
e
.
message
);
expect
(
e
.
code
).
assertEqual
(
'
401
'
);
expect
(
e
.
message
).
assertEqual
(
'
Check param failed
'
);
}
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_2391
* @tc.name isSuggested with en-US param
* @tc.desc check the isSuggested
*/
it
(
'
i18n_test_2391
'
,
0
,
function
()
{
try
{
let
value
=
I18n
.
System
.
isSuggested
(
12345
);
console
.
log
(
'
i18n_test_2391
'
+
value
);
expect
(
value
).
assertTrue
();
}
catch
(
e
){
console
.
log
(
'
i18n_test_2391
'
+
e
.
code
);
console
.
log
(
'
i18n_test_2391
'
+
e
.
message
);
expect
(
e
.
code
).
assertEqual
(
'
890001
'
);
expect
(
e
.
message
).
assertEqual
(
'
Param value not valid
'
);
}
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_3800
* @tc.name getDisplayCountry with zh-Hans-CN and en-US and true param
...
...
@@ -408,144 +222,6 @@ describe('I18nTest', function () {
expect
(
value
).
assertEqual
(
'
China
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_4310
* @tc.name getDisplayCountry with zh-Hans-CN and en-US and true param
* @tc.desc check the display country
*/
it
(
'
i18n_test_4310
'
,
0
,
function
()
{
let
value
=
I18n
.
System
.
getDisplayCountry
(
'
zh-Hans-CN
'
,
'
en-US
'
,
true
);
console
.
log
(
'
i18n_test_4310
'
+
value
);
expect
(
value
).
assertEqual
(
'
China
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_4320
* @tc.name getDisplayCountry with zh-Hans-CN and en-US and undefined param
* @tc.desc check the display country
*/
it
(
'
i18n_test_4320
'
,
0
,
function
()
{
let
value
=
I18n
.
System
.
getDisplayCountry
(
'
zh-Hans-CN
'
,
'
en-US
'
,
undefined
);
console
.
log
(
'
i18n_test_4320
'
+
value
);
expect
(
value
).
assertEqual
(
'
China
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_4321
* @tc.name getDisplayCountry with zh-Hans-CN and en-US and null param
* @tc.desc check the display country
*/
it
(
'
i18n_test_4321
'
,
0
,
function
()
{
let
value
=
I18n
.
System
.
getDisplayCountry
(
'
zh-Hans-CN
'
,
'
en-US
'
,
null
);
console
.
log
(
'
i18n_test_4321
'
+
value
);
expect
(
value
).
assertEqual
(
'
China
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_4330
* @tc.name getDisplayCountry with zh and en-US and true param
* @tc.desc check the display country
*/
it
(
'
i18n_test_4330
'
,
0
,
function
()
{
try
{
let
value
=
I18n
.
System
.
getDisplayCountry
(
'
zh
'
,
'
en-US
'
,
true
);
console
.
log
(
'
i18n_test_4330
'
+
value
);
expect
(
value
).
assertEqual
(
''
);
}
catch
(
e
){
console
.
log
(
'
i18n_test_4330
'
+
e
.
code
);
console
.
log
(
'
i18n_test_4330
'
+
e
.
message
);
expect
(
e
.
code
).
assertEqual
(
'
890001
'
);
expect
(
e
.
message
).
assertEqual
(
'
Param value not valid
'
);
}
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_4340
* @tc.name getDisplayCountry with zh-CN and en-US and true param
* @tc.desc check the display country
*/
it
(
'
i18n_test_4340
'
,
0
,
function
()
{
let
value
=
I18n
.
System
.
getDisplayCountry
(
'
zh-CN
'
,
'
en-US
'
,
true
);
console
.
log
(
'
i18n_test_4340
'
+
value
);
expect
(
value
).
assertEqual
(
'
China
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_4350
* @tc.name getDisplayCountry with zh-Hans and en-US and true param
* @tc.desc check the display country
*/
it
(
'
i18n_test_4350
'
,
0
,
function
()
{
try
{
let
value
=
I18n
.
System
.
getDisplayCountry
(
'
zh-Hans
'
,
'
en-US
'
,
true
);
console
.
log
(
'
i18n_test_4350
'
+
value
);
expect
(
value
).
assertEqual
(
''
);
}
catch
(
e
){
console
.
log
(
'
i18n_test_4350
'
+
e
.
code
);
console
.
log
(
'
i18n_test_4350
'
+
e
.
message
);
expect
(
e
.
code
).
assertEqual
(
'
890001
'
);
expect
(
e
.
message
).
assertEqual
(
'
Param value not valid
'
);
}
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_4360
* @tc.name getDisplayCountry with zh-Hans-CN and en-US and false param
* @tc.desc check the language
*/
it
(
'
i18n_test_4360
'
,
0
,
function
()
{
let
value
=
I18n
.
System
.
getDisplayCountry
(
'
zh-Hans-CN
'
,
'
en-US
'
,
false
);
console
.
log
(
'
i18n_test_4360
'
+
value
);
expect
(
value
).
assertEqual
(
'
China
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_4370
* @tc.name getDisplayCountry with zh-Hans-CN and en-US param
* @tc.desc check the language
*/
it
(
'
i18n_test_4370
'
,
0
,
function
()
{
let
value
=
I18n
.
System
.
getDisplayCountry
(
'
zh-Hans-CN
'
,
'
en-US
'
);
console
.
log
(
'
i18n_test_4370
'
+
value
);
expect
(
value
).
assertEqual
(
'
China
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_4380
* @tc.name getDisplayCountry with zh-Hans-CN and en-US param
* @tc.desc check the language
*/
it
(
'
i18n_test_4380
'
,
0
,
function
()
{
try
{
let
value
=
I18n
.
System
.
getDisplayCountry
(
'
zh-Hans-CN
'
);
console
.
log
(
'
i18n_test_4380
'
+
value
);
expect
(
value
).
assertEqual
(
'
China
'
);
}
catch
(
e
){
console
.
log
(
'
i18n_test_4380
'
+
e
.
code
);
console
.
log
(
'
i18n_test_4380
'
+
e
.
message
);
expect
(
e
.
code
).
assertEqual
(
'
401
'
);
expect
(
e
.
message
).
assertEqual
(
'
Check param failed
'
);
}
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_4390
* @tc.name getDisplayCountry with zh-Hans-CN and en-US param
* @tc.desc check the language
*/
it
(
'
i18n_test_4390
'
,
0
,
function
()
{
try
{
let
value
=
I18n
.
System
.
getDisplayCountry
(
'
zh-Hans-CN
'
,
12345
);
console
.
log
(
'
i18n_test_4390
'
+
value
);
expect
(
value
).
assertEqual
(
'
China
'
);
}
catch
(
e
){
console
.
log
(
'
i18n_test_4390
'
+
e
.
code
);
console
.
log
(
'
i18n_test_4390
'
+
e
.
message
);
expect
(
e
.
code
).
assertEqual
(
'
890001
'
);
expect
(
e
.
message
).
assertEqual
(
'
Param value not valid
'
);
}
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_4400
* @tc.name getDisplayLanguage with zh-Hans-CN and en-US and true param
...
...
@@ -645,141 +321,6 @@ describe('I18nTest', function () {
expect
(
value
).
assertEqual
(
'
Simplified Chinese
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_5010
* @tc.name getDisplayLanguage with zh-Hans-CN and en-US and true param
* @tc.desc check the language
*/
it
(
'
i18n_test_5010
'
,
0
,
function
()
{
let
value
=
I18n
.
System
.
getDisplayLanguage
(
'
zh-Hans-CN
'
,
'
en-US
'
,
true
);
console
.
log
(
'
i18n_test_5010
'
+
value
);
expect
(
value
).
assertEqual
(
'
Simplified Chinese
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_5020
* @tc.name getDisplayLanguage with zh-Hans-CN and en-US and undefined param
* @tc.desc check the language
*/
it
(
'
i18n_test_5020
'
,
0
,
function
()
{
let
value
=
I18n
.
System
.
getDisplayLanguage
(
'
zh-Hans-CN
'
,
'
en-US
'
,
undefined
);
console
.
log
(
'
i18n_test_5020
'
+
value
);
expect
(
value
).
assertEqual
(
'
Simplified Chinese
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_5021
* @tc.name getDisplayLanguage with zh-Hans-CN and en-US and null param
* @tc.desc check the language
*/
it
(
'
i18n_test_5021
'
,
0
,
function
()
{
let
value
=
I18n
.
System
.
getDisplayLanguage
(
'
zh-Hans-CN
'
,
'
en-US
'
,
null
);
console
.
log
(
'
i18n_test_5021
'
+
value
);
expect
(
value
).
assertEqual
(
'
Simplified Chinese
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_5030
* @tc.name getDisplayLanguage with zh-Hans-CN and en-GB and true param
* @tc.desc check the language
*/
it
(
'
i18n_test_5030
'
,
0
,
function
()
{
let
value
=
I18n
.
System
.
getDisplayLanguage
(
'
zh-Hans-CN
'
,
'
en-GB
'
,
true
);
console
.
log
(
'
i18n_test_5030
'
+
value
);
expect
(
value
).
assertEqual
(
'
Simplified Chinese
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_5040
* @tc.name getDisplayLanguage with zh and en-US and true param
* @tc.desc check the language
*/
it
(
'
i18n_test_5040
'
,
0
,
function
()
{
let
value
=
I18n
.
System
.
getDisplayLanguage
(
'
zh
'
,
'
en-US
'
,
true
);
console
.
log
(
'
i18n_test_5040
'
+
value
);
expect
(
value
).
assertEqual
(
'
Chinese
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_5050
* @tc.name getDisplayLanguage with zh-CN and en-US and true param
* @tc.desc check the language
*/
it
(
'
i18n_test_5050
'
,
0
,
function
()
{
let
value
=
I18n
.
System
.
getDisplayLanguage
(
'
zh-CN
'
,
'
en-US
'
,
true
);
console
.
log
(
'
i18n_test_5050
'
+
value
);
expect
(
value
).
assertEqual
(
'
Chinese
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_5060
* @tc.name getDisplayLanguage with zh-Hans and en-US and true param
* @tc.desc check the language
*/
it
(
'
i18n_test_5060
'
,
0
,
function
()
{
let
value
=
I18n
.
System
.
getDisplayLanguage
(
'
zh-Hans
'
,
'
en-US
'
,
true
);
console
.
log
(
'
i18n_test_5060
'
+
value
);
expect
(
value
).
assertEqual
(
'
Simplified Chinese
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_5070
* @tc.name getDisplayLanguage with zh-Hans-CN and en-US and false param
* @tc.desc check the language
*/
it
(
'
i18n_test_5070
'
,
0
,
function
()
{
let
value
=
I18n
.
System
.
getDisplayLanguage
(
'
zh-Hans-CN
'
,
'
en-US
'
,
false
);
console
.
log
(
'
i18n_test_5070
'
+
value
);
expect
(
value
).
assertEqual
(
'
Simplified Chinese
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_5080
* @tc.name getDisplayLanguage with zh-Hans-CN and en-US param
* @tc.desc check the language
*/
it
(
'
i18n_test_5080
'
,
0
,
function
()
{
let
value
=
I18n
.
System
.
getDisplayLanguage
(
'
zh-Hans-CN
'
,
'
en-US
'
);
console
.
log
(
'
i18n_test_5080
'
+
value
);
expect
(
value
).
assertEqual
(
'
Simplified Chinese
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_5090
* @tc.name getDisplayLanguage with zh-Hans-CN and en-US param
* @tc.desc check the language
*/
it
(
'
i18n_test_5090
'
,
0
,
function
()
{
try
{
let
value
=
I18n
.
System
.
getDisplayLanguage
(
'
zh-Hans-CN
'
);
console
.
log
(
'
i18n_test_5090
'
+
value
);
expect
(
value
).
assertEqual
(
'
Simplified Chinese
'
);
}
catch
(
e
){
console
.
log
(
'
i18n_test_5090
'
+
e
.
code
);
console
.
log
(
'
i18n_test_5090
'
+
e
.
message
);
expect
(
e
.
code
).
assertEqual
(
'
401
'
);
expect
(
e
.
message
).
assertEqual
(
'
Check param failed
'
);
}
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_5091
* @tc.name getDisplayLanguage with zh-Hans-CN and en-US param
* @tc.desc check the language
*/
it
(
'
i18n_test_5091
'
,
0
,
function
()
{
try
{
let
value
=
I18n
.
System
.
getDisplayLanguage
(
'
zh-Hans-CN
'
,
12345
);
console
.
log
(
'
i18n_test_5091
'
+
value
);
expect
(
value
).
assertEqual
(
'
Simplified Chinese
'
);
}
catch
(
e
){
console
.
log
(
'
i18n_test_5091
'
+
e
.
code
);
console
.
log
(
'
i18n_test_5091
'
+
e
.
message
);
expect
(
e
.
code
).
assertEqual
(
'
890001
'
);
expect
(
e
.
message
).
assertEqual
(
'
Param value not valid
'
);
}
})
/**
* @tc.number SUB_GLOBAL_I18N_JS_8800
* @tc.name test isRTL interface with zh-CN param
...
...
global/i18n_standard/intljs/src/main/js/test/Lang.test.js
浏览文件 @
fadcc00e
...
...
@@ -138,18 +138,6 @@ describe('LangTest', function () {
expect
(
value
.
length
).
assertLarger
(
0
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_PREFERREDLANGUAGE_0110
* @tc.name test the getPreferredLanguageList interface with default value
* @tc.desc check the value of getPreferredLanguageList method
*/
it
(
'
i18n_test_preferredlanguage_0110
'
,
0
,
function
()
{
console
.
log
(
'
i18n_test_preferredlanguage_0110
'
+
'
start
'
);
let
value
=
I18n
.
System
.
getPreferredLanguageList
();
console
.
log
(
'
i18n_test_preferredlanguage_0110
'
+
value
);
expect
(
value
.
length
).
assertLarger
(
0
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_PREFERREDLANGUAGE_0120
* @tc.name test the addPreferredLanguage interface
...
...
@@ -211,26 +199,6 @@ describe('LangTest', function () {
}
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_PREFERREDLANGUAGE_1020
* @tc.name test the getFirstPreferredLanguage interface
* @tc.desc check the value of getFirstPreferredLanguage method
*/
it
(
'
i18n_test_preferredlanguage_1020
'
,
0
,
function
()
{
console
.
log
(
'
i18n_test_preferredlanguage_1020
'
+
'
start
'
);
let
value
=
I18n
.
System
.
getFirstPreferredLanguage
();
console
.
log
(
'
i18n_test_preferredlanguage_1020
'
+
value
);
let
list
=
I18n
.
System
.
getPreferredLanguageList
();
console
.
log
(
'
i18n_test_preferredlanguage_1020
'
+
list
);
expect
(
list
.
length
).
assertLarger
(
0
);
if
(
list
[
0
]
==
'
zh-Hans
'
){
expect
(
value
).
assertEqual
(
'
zh-Hans
'
);
}
else
if
(
list
[
0
]
==
'
en
'
){
expect
(
value
).
assertEqual
(
'
en
'
);
}
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_PREFERREDLANGUAGE_1100
* @tc.name test the getAppPreferredLanguage interface
...
...
@@ -243,18 +211,6 @@ describe('LangTest', function () {
expect
(
value
).
assertContain
(
'
zh
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_PREFERREDLANGUAGE_1120
* @tc.name test the getAppPreferredLanguage interface
* @tc.desc check the value of getAppPreferredLanguage method
*/
it
(
'
i18n_test_preferredlanguage_1120
'
,
0
,
function
()
{
console
.
log
(
'
i18n_test_preferredlanguage_1120
'
+
'
start
'
);
let
value
=
I18n
.
System
.
getAppPreferredLanguage
();
console
.
log
(
'
i18n_test_preferredlanguage_1120
'
+
value
);
expect
(
value
).
assertContain
(
'
zh
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_TRANSFER_0100
* @tc.name transfer from lower to upper
...
...
@@ -303,16 +259,5 @@ describe('LangTest', function () {
expect
(
value
).
assertEqual
(
'
the sky is in blue-style!
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_LOCALDIGIT_0100
* @tc.name test getUsingLocalDigit method
* @tc.desc get the getUsingLocalDigit value
*/
it
(
'
localdigit_test_0100
'
,
0
,
function
()
{
let
value
=
I18n
.
System
.
getUsingLocalDigit
();
console
.
log
(
'
localdigit_test_0100
'
+
value
);
expect
(
value
).
assertFalse
();
})
console
.
log
(
'
*************end LangTest*************
'
);
})}
global/i18n_standard/intljs/src/main/js/test/List.test.js
浏览文件 @
fadcc00e
...
...
@@ -19,7 +19,6 @@ import CharacterInI18nTest from './CharacterInI18n.test.js'
import
I18nTest
from
'
./I18n.test.js
'
import
I18nUtilInI18nTest
from
'
./I18nUtilInI18n.test.js
'
import
IndexUtilInI18nTest
from
'
./IndexUtilInI18n.test.js
'
import
intlTest
from
'
./Intl.test.js
'
import
NormalizerInI18nTest
from
'
./NormalizerInI18n.test.js
'
import
PhoneNumberFormatInI18nTest
from
'
./PhoneNumberFormatInI18n.test.js
'
import
LangTest
from
'
./Lang.test.js
'
...
...
@@ -28,7 +27,12 @@ import TimezoneInI18nTest from './TimezoneInI18n.test.js'
import
TransliteratorInI18nTest
from
'
./TransliteratorInI18n.test.js
'
import
UnicodeInI18nTest
from
'
./UnicodeInI18n.test.js
'
import
UtilInI18nTest
from
'
./UtilInI18n.test.js
'
import
CollatorInIntlTest
from
'
./CollatorInIntl.test.js
'
import
DateTimeFormatInIntlTest
from
'
./DateTimeFormatInIntl.test.js
'
import
LocaleInIntlTest
from
'
./LocaleInIntl.test.js
'
import
NumberFormatInIntlTest
from
'
./NumberFormatInIntl.test.js
'
import
PluralRulesInIntlTest
from
'
./PluralRulesInIntl.test.js
'
import
RelativeTimeFormatInIntlTest
from
'
./RelativeTimeFormatInIntl.test.js
'
export
default
function
testsuite
()
{
BreakIteratorInI18nTest
()
CalendarInI18nTest
()
...
...
@@ -36,7 +40,6 @@ CharacterInI18nTest()
I18nTest
()
I18nUtilInI18nTest
()
IndexUtilInI18nTest
()
intlTest
()
NormalizerInI18nTest
()
PhoneNumberFormatInI18nTest
()
LangTest
()
...
...
@@ -45,5 +48,10 @@ TimezoneInI18nTest()
TransliteratorInI18nTest
()
UnicodeInI18nTest
()
UtilInI18nTest
()
CollatorInIntlTest
()
DateTimeFormatInIntlTest
()
LocaleInIntlTest
()
NumberFormatInIntlTest
()
PluralRulesInIntlTest
()
RelativeTimeFormatInIntlTest
()
}
global/i18n_standard/intljs/src/main/js/test/Intl.test.js
→
global/i18n_standard/intljs/src/main/js/test/
NumberFormatIn
Intl.test.js
浏览文件 @
fadcc00e
此差异已折叠。
点击以展开。
global/i18n_standard/intljs/src/main/js/test/PluralRulesInIntl.test.js
0 → 100644
浏览文件 @
fadcc00e
/*
* Copyright (C) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
I18n
from
'
@ohos.i18n
'
import
Intl
from
'
@ohos.intl
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
export
default
function
PluralRulesInIntlTest
()
{
describe
(
'
PluralRulesInIntlTest
'
,
function
()
{
console
.
log
(
'
*************start PluralRulesInIntlTest*************
'
);
let
hour
=
I18n
.
System
.
is24HourClock
();
console
.
log
(
'
init 24 hour clock value
'
+
hour
);
/* *
* execute this step before all testcases
*/
beforeAll
(
function
(){
console
.
log
(
'
step before all cases in I18n.
'
+
'
24hour:
'
+
I18n
.
System
.
is24HourClock
()
+
'
prelang:
'
+
I18n
.
System
.
getPreferredLanguageList
()
+
'
syslocale:
'
+
I18n
.
System
.
getSystemLocale
());
})
/* *
* execute this step before every testcase
*/
beforeEach
(
function
(){
console
.
log
(
'
step before every case in I18n.
'
);
})
/* *
* execute this step after every testcase
*/
afterEach
(
function
(){
console
.
log
(
'
step after every case in I18n.
'
);
})
/* *
* execute this step after all testcases
*/
afterAll
(
function
(){
console
.
log
(
'
step after all cases in I18n.
'
+
'
24hour:
'
+
I18n
.
System
.
is24HourClock
()
+
'
prelang:
'
+
I18n
.
System
.
getPreferredLanguageList
()
+
'
syslocale:
'
+
I18n
.
System
.
getSystemLocale
());
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_PLURAL_2600
* @tc.name get PluralRules
* @tc.desc check the select result
*/
it
(
'
pluralrules_test_2600
'
,
0
,
function
()
{
let
pl
=
new
Intl
.
PluralRules
();
let
value
=
pl
.
select
(
0
);
console
.
log
(
'
pluralrules_test_2600
'
+
value
);
expect
(
value
).
assertEqual
(
'
other
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_PLURAL_2700
* @tc.name get PluralRules with zh locale
* @tc.desc check the select result
*/
it
(
'
pluralrules_test_2700
'
,
0
,
function
()
{
let
pl
=
new
Intl
.
PluralRules
(
'
zh
'
);
let
value
=
pl
.
select
(
0
);
console
.
log
(
'
pluralrules_test_2700
'
+
value
);
expect
(
value
).
assertEqual
(
'
other
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_PLURAL_2720
* @tc.name get PluralRules with zh locale and undefined options
* @tc.desc check the select result
*/
it
(
'
pluralrules_test_2720
'
,
0
,
function
()
{
let
pl
=
new
Intl
.
PluralRules
(
'
zh
'
,
undefined
);
let
value
=
pl
.
select
(
0
);
console
.
log
(
'
pluralrules_test_2720
'
+
value
);
expect
(
value
).
assertEqual
(
'
other
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_PLURAL_2740
* @tc.name get PluralRules with zh locale and null options
* @tc.desc check the select result
*/
it
(
'
pluralrules_test_2740
'
,
0
,
function
()
{
let
pl
=
new
Intl
.
PluralRules
(
'
zh
'
,
null
);
let
value
=
pl
.
select
(
0
);
console
.
log
(
'
pluralrules_test_2740
'
+
value
);
expect
(
value
).
assertEqual
(
'
other
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_PLURAL_2800
* @tc.name get PluralRules with zh locale and ordinal type
* @tc.desc check the select result
*/
it
(
'
pluralrules_test_2800
'
,
0
,
function
()
{
let
pl
=
new
Intl
.
PluralRules
(
'
zh
'
,
{
'
type
'
:
'
ordinal
'
});
let
value
=
pl
.
select
(
0
);
console
.
log
(
'
pluralrules_test_2800
'
+
value
);
expect
(
value
).
assertEqual
(
'
other
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_PLURAL_2900
* @tc.name get PluralRules with zh locale and loolup localeMatcher
* @tc.desc check the select result
*/
it
(
'
pluralrules_test_2900
'
,
0
,
function
()
{
let
pl
=
new
Intl
.
PluralRules
(
'
zh
'
,
{
'
localeMatcher
'
:
'
lookup
'
});
let
value
=
pl
.
select
(
0
);
console
.
log
(
'
pluralrules_test_2900
'
+
value
);
expect
(
value
).
assertEqual
(
'
other
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_PLURAL_3000
* @tc.name get PluralRules with zh locale and minimumIntegerDigits options
* @tc.desc check the select result
*/
it
(
'
pluralrules_test_3000
'
,
0
,
function
()
{
let
pl
=
new
Intl
.
PluralRules
(
'
zh
'
,
{
'
minimumIntegerDigits
'
:
10
});
let
value
=
pl
.
select
(
0
);
console
.
log
(
'
pluralrules_test_3000
'
+
value
);
expect
(
value
).
assertEqual
(
'
other
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_PLURAL_3100
* @tc.name get PluralRules with zh locale and minimumFractionDigits options
* @tc.desc check the select result
*/
it
(
'
pluralrules_test_3100
'
,
0
,
function
()
{
let
pl
=
new
Intl
.
PluralRules
(
'
zh
'
,
{
'
minimumFractionDigits
'
:
11
});
let
value
=
pl
.
select
(
0
);
console
.
log
(
'
pluralrules_test_3100
'
+
value
);
expect
(
value
).
assertEqual
(
'
other
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_PLURAL_3200
* @tc.name get PluralRules with zh locale and maximumFractionDigits options
* @tc.desc check the select result
*/
it
(
'
pluralrules_test_3200
'
,
0
,
function
()
{
let
pl
=
new
Intl
.
PluralRules
(
'
zh
'
,
{
'
maximumFractionDigits
'
:
'
lookup
'
});
let
value
=
pl
.
select
(
0
);
console
.
log
(
'
pluralrules_test_3200
'
+
value
);
expect
(
value
).
assertEqual
(
'
other
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_PLURAL_3300
* @tc.name get PluralRules with zh locale and minimumSignificantDigits options
* @tc.desc check the select result
*/
it
(
'
pluralrules_test_3300
'
,
0
,
function
()
{
let
pl
=
new
Intl
.
PluralRules
(
'
zh
'
,
{
'
minimumSignificantDigits
'
:
10
});
let
value
=
pl
.
select
(
0
);
console
.
log
(
'
pluralrules_test_3300
'
+
value
);
expect
(
value
).
assertEqual
(
'
other
'
);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_PLURAL_3400
* @tc.name get PluralRules with zh locale and maximumSignificantDigits options
* @tc.desc check the select result
*/
it
(
'
pluralrules_test_3400
'
,
0
,
function
()
{
let
pl
=
new
Intl
.
PluralRules
(
'
zh
'
,
{
'
maximumSignificantDigits
'
:
11
});
let
value
=
pl
.
select
(
0
);
console
.
log
(
'
pluralrules_test_3400
'
+
value
);
expect
(
value
).
assertEqual
(
'
other
'
);
})
console
.
log
(
'
*************end PluralRulesInIntlTest*************
'
);
})}
global/i18n_standard/intljs/src/main/js/test/RelativeTimeFormatInIntl.test.js
0 → 100644
浏览文件 @
fadcc00e
/*
* Copyright (C) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
I18n
from
'
@ohos.i18n
'
import
Intl
from
'
@ohos.intl
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
export
default
function
RelativeTimeFormatInIntlTest
()
{
describe
(
'
RelativeTimeFormatInIntlTest
'
,
function
()
{
console
.
log
(
'
*************start RelativeTimeFormatInIntlTest*************
'
);
let
hour
=
I18n
.
System
.
is24HourClock
();
console
.
log
(
'
init 24 hour clock value
'
+
hour
);
/* *
* execute this step before all testcases
*/
beforeAll
(
function
(){
console
.
log
(
'
step before all cases in I18n.
'
+
'
24hour:
'
+
I18n
.
System
.
is24HourClock
()
+
'
prelang:
'
+
I18n
.
System
.
getPreferredLanguageList
()
+
'
syslocale:
'
+
I18n
.
System
.
getSystemLocale
());
})
/* *
* execute this step before every testcase
*/
beforeEach
(
function
(){
console
.
log
(
'
step before every case in I18n.
'
);
})
/* *
* execute this step after every testcase
*/
afterEach
(
function
(){
console
.
log
(
'
step after every case in I18n.
'
);
})
/* *
* execute this step after all testcases
*/
afterAll
(
function
(){
console
.
log
(
'
step after all cases in I18n.
'
+
'
24hour:
'
+
I18n
.
System
.
is24HourClock
()
+
'
prelang:
'
+
I18n
.
System
.
getPreferredLanguageList
()
+
'
syslocale:
'
+
I18n
.
System
.
getSystemLocale
());
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_RELATIVETIMEFORMAT_0100
* @tc.name format the relativetime with 100 second
* @tc.desc check the relativetime
*/
it
(
'
i18n_test_relativetimeformat_0100
'
,
0
,
function
()
{
console
.
log
(
'
i18n_test_relativetimeformat_0100
'
+
'
start
'
);
let
relativetimefmt
=
new
Intl
.
RelativeTimeFormat
();
let
value
=
relativetimefmt
.
format
(
100
,
'
second
'
);
console
.
log
(
'
i18n_test_relativetimeformat_0100
'
+
value
);
expect
(
value
).
assertContain
(
'
100
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_RELATIVETIMEFORMAT_0200
* @tc.name format the relativetime with 100 second in en
* @tc.desc check the relativetime
*/
it
(
'
i18n_test_relativetimeformat_0200
'
,
0
,
function
()
{
console
.
log
(
'
i18n_test_relativetimeformat_0200
'
+
'
start
'
);
let
relativetimefmt
=
new
Intl
.
RelativeTimeFormat
(
'
en
'
);
let
value
=
relativetimefmt
.
format
(
100
,
'
second
'
);
console
.
log
(
'
i18n_test_relativetimeformat_0200
'
+
value
);
expect
(
value
).
assertEqual
(
'
in 100 seconds
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_RELATIVETIMEFORMAT_0220
* @tc.name format the relativetime with 100 second in en and undefined options
* @tc.desc check the relativetime
*/
it
(
'
i18n_test_relativetimeformat_0220
'
,
0
,
function
()
{
console
.
log
(
'
i18n_test_relativetimeformat_0220
'
+
'
start
'
);
let
relativetimefmt
=
new
Intl
.
RelativeTimeFormat
(
'
en
'
,
undefined
);
let
value
=
relativetimefmt
.
format
(
100
,
'
second
'
);
console
.
log
(
'
i18n_test_relativetimeformat_0220
'
+
value
);
expect
(
value
).
assertEqual
(
'
in 100 seconds
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_RELATIVETIMEFORMAT_0240
* @tc.name format the relativetime with 100 second in en and null options
* @tc.desc check the relativetime
*/
it
(
'
i18n_test_relativetimeformat_0240
'
,
0
,
function
()
{
console
.
log
(
'
i18n_test_relativetimeformat_0240
'
+
'
start
'
);
let
relativetimefmt
=
new
Intl
.
RelativeTimeFormat
(
'
en
'
,
null
);
let
value
=
relativetimefmt
.
format
(
100
,
'
second
'
);
console
.
log
(
'
i18n_test_relativetimeformat_0240
'
+
value
);
expect
(
value
).
assertEqual
(
'
in 100 seconds
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_RELATIVETIMEFORMAT_0300
* @tc.name format the relativetime with 100 second in narrow style
* @tc.desc check the relativetime
*/
it
(
'
i18n_test_relativetimeformat_0300
'
,
0
,
function
()
{
console
.
log
(
'
i18n_test_relativetimeformat_0300
'
+
'
start
'
);
let
relativetimefmt
=
new
Intl
.
RelativeTimeFormat
(
'
en
'
,
{
style
:
'
narrow
'
});
let
value
=
relativetimefmt
.
format
(
100
,
'
second
'
);
console
.
log
(
'
i18n_test_relativetimeformat_0300
'
+
value
);
expect
(
value
).
assertEqual
(
'
in 100 sec.
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_RELATIVETIMEFORMAT_0400
* @tc.name format the relativetime with 100 second, get the formatToParts value
* @tc.desc check the formatToParts value
*/
it
(
'
i18n_test_relativetimeformat_0400
'
,
0
,
function
()
{
console
.
log
(
'
i18n_test_relativetimeformat_0400
'
+
'
start
'
);
let
relativetimefmt
=
new
Intl
.
RelativeTimeFormat
(
'
en
'
);
let
value
=
relativetimefmt
.
formatToParts
(
100
,
'
second
'
);
console
.
log
(
'
i18n_test_relativetimeformat_0400
'
+
value
[
0
].
value
+
'
value
'
);
expect
(
value
[
0
].
value
).
assertEqual
(
'
in
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_RELATIVETIMEFORMAT_0500
* @tc.name format the relativetime, get the locale options
* @tc.desc check the relativetime
*/
it
(
'
i18n_test_relativetimeformat_0500
'
,
0
,
function
()
{
console
.
log
(
'
i18n_test_relativetimeformat_0500
'
+
'
start
'
);
let
relativetimefmt
=
new
Intl
.
RelativeTimeFormat
(
'
en
'
);
let
value
=
relativetimefmt
.
resolvedOptions
();
console
.
log
(
'
i18n_test_relativetimeformat_0500
'
+
value
);
expect
(
value
.
locale
).
assertEqual
(
'
en
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_RELATIVETIMEFORMAT_0600
* @tc.name format the relativetime, get the style options
* @tc.desc check the relativetime
*/
it
(
'
i18n_test_relativetimeformat_0600
'
,
0
,
function
()
{
console
.
log
(
'
i18n_test_relativetimeformat_0600
'
+
'
start
'
);
let
relativetimefmt
=
new
Intl
.
RelativeTimeFormat
(
'
en
'
);
let
value
=
relativetimefmt
.
resolvedOptions
();
console
.
log
(
'
i18n_test_relativetimeformat_0600
'
+
value
);
expect
(
value
.
style
).
assertEqual
(
'
long
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_RELATIVETIMEFORMAT_0700
* @tc.name format the relativetime, get the numeric options
* @tc.desc check the relativetime
*/
it
(
'
i18n_test_relativetimeformat_0700
'
,
0
,
function
()
{
console
.
log
(
'
i18n_test_relativetimeformat_0700
'
+
'
start
'
);
let
relativetimefmt
=
new
Intl
.
RelativeTimeFormat
(
'
en
'
);
let
value
=
relativetimefmt
.
resolvedOptions
();
console
.
log
(
'
i18n_test_relativetimeformat_0700
'
+
value
);
expect
(
value
.
numeric
).
assertEqual
(
'
always
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_RELATIVETIMEFORMAT_0800
* @tc.name format the relativetime, get the numberingSystem options
* @tc.desc check the relativetime
*/
it
(
'
i18n_test_relativetimeformat_0800
'
,
0
,
function
()
{
console
.
log
(
'
i18n_test_relativetimeformat_0800
'
+
'
start
'
);
let
relativetimefmt
=
new
Intl
.
RelativeTimeFormat
(
'
en
'
);
let
value
=
relativetimefmt
.
resolvedOptions
();
console
.
log
(
'
i18n_test_relativetimeformat_0800
'
+
value
.
numberingSystem
);
expect
(
value
.
numberingSystem
).
assertEqual
(
'
latn
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_RELATIVETIMEFORMAT_0900
* @tc.name format the relativetime with localeMatcher options
* @tc.desc check the relativetime
*/
it
(
'
i18n_test_relativetimeformat_0900
'
,
0
,
function
()
{
console
.
log
(
'
i18n_test_relativetimeformat_0900
'
+
'
start
'
);
let
relativetimefmt
=
new
Intl
.
RelativeTimeFormat
(
'
en
'
,
{
localeMatcher
:
'
best fit
'
,
numeric
:
'
auto
'
,
style
:
'
narrow
'
});
let
value
=
relativetimefmt
.
resolvedOptions
();
console
.
log
(
'
i18n_test_relativetimeformat_0900
'
+
value
);
expect
(
value
.
numeric
).
assertEqual
(
'
auto
'
);
expect
(
value
.
style
).
assertEqual
(
'
narrow
'
);
})
console
.
log
(
'
*************end RelativeTimeFormatInIntlTest*************
'
);
})}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录