Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
df49bb27
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
df49bb27
编写于
2月 16, 2023
作者:
O
openharmony_ci
提交者:
Gitee
2月 16, 2023
浏览文件
操作
浏览文件
下载
差异文件
!7616 Modified the static functions of rationalnumber【monthly_20221018】
Merge pull request !7616 from jwx1068251/monthly_20221018
上级
400bed38
381d4c11
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
55 addition
and
99 deletion
+55
-99
commonlibrary/ets_utils/util2_lib_standard/src/main/js/test/util.test.js
...ts_utils/util2_lib_standard/src/main/js/test/util.test.js
+49
-88
commonlibrary/ets_utils/util_lib_standard/src/main/js/test/util.test.js
...ets_utils/util_lib_standard/src/main/js/test/util.test.js
+6
-11
未找到文件。
commonlibrary/ets_utils/util2_lib_standard/src/main/js/test/util.test.js
浏览文件 @
df49bb27
...
...
@@ -3407,7 +3407,7 @@ describe('FunctionTest', function () {
})
/**
* @tc.name: testUtilformat001
* @tc.name: testUtilformat
ThrowError
001
* @tc.desc: Returns the formatted string.
*/
it
(
'
testUtilformatThrowError001
'
,
0
,
function
()
{
...
...
@@ -3551,11 +3551,9 @@ describe('RationalNumberTest', function () {
* @tc.desc: Creates a RationalNumber object based on a given string.
*/
it
(
'
test_parseRationalNumber_001
'
,
0
,
function
()
{
var
pro
=
new
util
.
RationalNumber
()
pro
.
parseRationalNumber
(
1
,
2
)
var
res
=
pro
.
createRationalFromString
(
'
+2:-4
'
)
var
result1
=
res
.
valueOf
()
expect
(
result1
).
assertEqual
(
-
0.5
)
var
res
=
util
.
RationalNumber
.
parseRationalNumber
(
2
,
1
)
var
result
=
res
.
valueOf
()
expect
(
result
).
assertEqual
(
2
)
})
/**
...
...
@@ -3564,11 +3562,9 @@ describe('RationalNumberTest', function () {
*/
it
(
'
test_parseRationalNumberThrowError_001
'
,
0
,
function
()
{
try
{
var
pro
=
new
util
.
RationalNumber
()
pro
.
parseRationalNumber
(
'
str
'
,
2
)
var
res
=
pro
.
createRationalFromString
(
'
+2:-4
'
)
var
result1
=
res
.
valueOf
()
expect
(
result1
).
assertEqual
(
-
0.5
)
var
pro
=
util
.
RationalNumber
.
parseRationalNumber
(
'
str
'
,
2
)
var
result
=
res
.
valueOf
()
expect
(
result
).
assertEqual
(
2
)
}
catch
(
e
)
{
expect
(
e
.
toString
()).
assertEqual
(
"
BusinessError: Parameter error.The type of str must be number
"
);
}
...
...
@@ -3579,11 +3575,9 @@ describe('RationalNumberTest', function () {
* @tc.desc: Creates a RationalNumber object based on a given string.
*/
it
(
'
test_createRationalFromString_001
'
,
0
,
function
()
{
var
pro
=
new
util
.
RationalNumber
()
pro
.
parseRationalNumber
(
1
,
2
)
var
res
=
pro
.
createRationalFromString
(
'
-1:2
'
)
var
result1
=
res
.
valueOf
()
expect
(
result1
).
assertEqual
(
-
0.5
)
var
res
=
util
.
RationalNumber
.
createRationalFromString
(
'
-1:2
'
)
var
result
=
res
.
valueOf
()
expect
(
result
).
assertEqual
(
-
0.5
)
})
/**
...
...
@@ -3591,11 +3585,9 @@ describe('RationalNumberTest', function () {
* @tc.desc: Creates a RationalNumber object based on a given string.
*/
it
(
'
test_createRationalFromString_002
'
,
0
,
function
()
{
var
pro
=
new
util
.
RationalNumber
()
pro
.
parseRationalNumber
(
1
,
2
)
var
res
=
pro
.
createRationalFromString
(
'
+3/4
'
)
var
result1
=
res
.
valueOf
()
expect
(
result1
).
assertEqual
(
0.75
)
var
res
=
util
.
RationalNumber
.
createRationalFromString
(
'
+3/4
'
)
var
result
=
res
.
valueOf
()
expect
(
result
).
assertEqual
(
0.75
)
})
/**
...
...
@@ -3603,11 +3595,9 @@ describe('RationalNumberTest', function () {
* @tc.desc: Creates a RationalNumber object based on a given string.
*/
it
(
'
test_createRationalFromString_003
'
,
0
,
function
()
{
var
pro
=
new
util
.
RationalNumber
()
pro
.
parseRationalNumber
(
1
,
2
)
var
res
=
pro
.
createRationalFromString
(
'
+3:-4
'
)
var
result1
=
res
.
valueOf
()
expect
(
result1
).
assertEqual
(
-
0.75
)
var
res
=
util
.
RationalNumber
.
createRationalFromString
(
'
+3:-4
'
)
var
result
=
res
.
valueOf
()
expect
(
result
).
assertEqual
(
-
0.75
)
})
/**
...
...
@@ -3615,11 +3605,9 @@ describe('RationalNumberTest', function () {
* @tc.desc: Creates a RationalNumber object based on a given string.
*/
it
(
'
test_createRationalFromString_004
'
,
0
,
function
()
{
var
pro
=
new
util
.
RationalNumber
()
pro
.
parseRationalNumber
(
1
,
2
)
var
res
=
pro
.
createRationalFromString
(
'
+2:4
'
)
var
result1
=
res
.
valueOf
()
expect
(
result1
).
assertEqual
(
0.5
)
var
res
=
util
.
RationalNumber
.
createRationalFromString
(
'
+2:4
'
)
var
result
=
res
.
valueOf
()
expect
(
result
).
assertEqual
(
0.5
)
})
/**
...
...
@@ -3627,11 +3615,9 @@ describe('RationalNumberTest', function () {
* @tc.desc: Creates a RationalNumber object based on a given string.
*/
it
(
'
test_createRationalFromString_005
'
,
0
,
function
()
{
var
pro
=
new
util
.
RationalNumber
()
pro
.
parseRationalNumber
(
1
,
2
)
var
res
=
pro
.
createRationalFromString
(
'
+2:-4
'
)
var
result1
=
res
.
valueOf
()
expect
(
result1
).
assertEqual
(
-
0.5
)
var
res
=
util
.
RationalNumber
.
createRationalFromString
(
'
+2:-4
'
)
var
result
=
res
.
valueOf
()
expect
(
result
).
assertEqual
(
-
0.5
)
})
/**
...
...
@@ -3640,11 +3626,9 @@ describe('RationalNumberTest', function () {
*/
it
(
'
test_createRationalFromStringThrowError_001
'
,
0
,
function
()
{
try
{
var
pro
=
new
util
.
RationalNumber
()
pro
.
parseRationalNumber
(
1
,
2
)
var
res
=
pro
.
createRationalFromString
(
123
)
var
result1
=
res
.
valueOf
()
expect
(
result1
).
assertEqual
(
-
0.5
)
var
res
=
util
.
RationalNumber
.
createRationalFromString
(
123
)
var
result
=
res
.
valueOf
()
expect
(
result
).
assertEqual
(
-
0.5
)
}
catch
(
e
)
{
expect
(
e
.
toString
()).
assertEqual
(
"
BusinessError: Parameter error.The type of 123 must be string
"
);
}
...
...
@@ -3655,10 +3639,8 @@ describe('RationalNumberTest', function () {
* @tc.desc: Compares the current RationalNumber object with a given object.
*/
it
(
'
test_compare_001
'
,
0
,
function
()
{
var
pro
=
new
util
.
RationalNumber
()
pro
.
parseRationalNumber
(
2
,
1
)
var
proc
=
new
util
.
RationalNumber
()
proc
.
parseRationalNumber
(
3
,
4
)
var
pro
=
util
.
RationalNumber
.
parseRationalNumber
(
2
,
1
)
var
proc
=
util
.
RationalNumber
.
parseRationalNumber
(
3
,
4
)
var
res
=
pro
.
compare
(
proc
)
expect
(
res
).
assertEqual
(
1
)
})
...
...
@@ -3668,10 +3650,8 @@ describe('RationalNumberTest', function () {
* @tc.desc: Compares the current RationalNumber object with a given object.
*/
it
(
'
test_compare_002
'
,
0
,
function
()
{
var
pro
=
new
util
.
RationalNumber
()
pro
.
parseRationalNumber
(
2
,
1
)
var
proc
=
new
util
.
RationalNumber
()
proc
.
parseRationalNumber
(
0
,
0
)
var
pro
=
util
.
RationalNumber
.
parseRationalNumber
(
2
,
1
)
var
proc
=
util
.
RationalNumber
.
parseRationalNumber
(
0
,
0
)
var
res
=
pro
.
compare
(
proc
)
expect
(
res
).
assertEqual
(
-
1
)
})
...
...
@@ -3681,10 +3661,8 @@ describe('RationalNumberTest', function () {
* @tc.desc: Compares the current RationalNumber object with a given object.
*/
it
(
'
test_compare_003
'
,
0
,
function
()
{
var
pro
=
new
util
.
RationalNumber
()
pro
.
parseRationalNumber
(
2
,
1
)
var
proc
=
new
util
.
RationalNumber
()
proc
.
parseRationalNumber
(
8
,
3
)
var
pro
=
util
.
RationalNumber
.
parseRationalNumber
(
2
,
1
)
var
proc
=
util
.
RationalNumber
.
parseRationalNumber
(
8
,
3
)
var
res
=
pro
.
compare
(
proc
)
expect
(
res
).
assertEqual
(
-
1
)
})
...
...
@@ -3694,10 +3672,8 @@ describe('RationalNumberTest', function () {
* @tc.desc: Compares the current RationalNumber object with a given object.
*/
it
(
'
test_compare_004
'
,
0
,
function
()
{
var
pro
=
new
util
.
RationalNumber
()
pro
.
parseRationalNumber
(
2
,
1
)
var
proc
=
new
util
.
RationalNumber
()
proc
.
parseRationalNumber
(
2
,
1
)
var
pro
=
util
.
RationalNumber
.
parseRationalNumber
(
2
,
1
)
var
proc
=
util
.
RationalNumber
.
parseRationalNumber
(
2
,
1
)
var
res
=
pro
.
compare
(
proc
)
expect
(
res
).
assertEqual
(
0
)
})
...
...
@@ -3707,10 +3683,8 @@ describe('RationalNumberTest', function () {
* @tc.desc: Compares the current RationalNumber object with a given object.
*/
it
(
'
test_compare_005
'
,
0
,
function
()
{
var
pro
=
new
util
.
RationalNumber
()
pro
.
parseRationalNumber
(
0
,
0
)
var
proc
=
new
util
.
RationalNumber
()
proc
.
parseRationalNumber
(
2
,
1
)
var
pro
=
util
.
RationalNumber
.
parseRationalNumber
(
0
,
0
)
var
proc
=
util
.
RationalNumber
.
parseRationalNumber
(
2
,
1
)
var
res
=
pro
.
compare
(
proc
)
expect
(
res
).
assertEqual
(
1
)
})
...
...
@@ -3721,8 +3695,7 @@ describe('RationalNumberTest', function () {
*/
it
(
'
test_compareThrowError_001
'
,
0
,
function
()
{
try
{
var
pro
=
new
util
.
RationalNumber
()
pro
.
parseRationalNumber
(
2
,
1
)
var
pro
=
util
.
RationalNumber
.
parseRationalNumber
(
2
,
1
)
var
proc
=
'
str
'
var
res
=
pro
.
compare
(
proc
)
expect
(
res
).
assertEqual
(
1
)
...
...
@@ -3736,9 +3709,7 @@ describe('RationalNumberTest', function () {
* @tc.desc: Obtains the greatest common divisor of two specified numbers.
*/
it
(
'
testgetCommonFactor001
'
,
0
,
function
()
{
var
pro
=
new
util
.
RationalNumber
()
pro
.
parseRationalNumber
(
0
,
0
)
var
res
=
pro
.
getCommonFactor
(
4
,
8
)
var
res
=
util
.
RationalNumber
.
getCommonFactor
(
4
,
8
)
expect
(
res
).
assertEqual
(
4
)
})
...
...
@@ -3747,9 +3718,7 @@ describe('RationalNumberTest', function () {
* @tc.desc: Obtains the greatest common divisor of two specified numbers.
*/
it
(
'
testgetCommonFactor002
'
,
0
,
function
()
{
var
pro
=
new
util
.
RationalNumber
()
pro
.
parseRationalNumber
(
0
,
0
)
var
res
=
pro
.
getCommonFactor
(
10
,
15
)
var
res
=
util
.
RationalNumber
.
getCommonFactor
(
10
,
15
)
expect
(
res
).
assertEqual
(
5
)
})
...
...
@@ -3758,9 +3727,7 @@ describe('RationalNumberTest', function () {
* @tc.desc: Obtains the greatest common divisor of two specified numbers.
*/
it
(
'
testgetCommonFactor003
'
,
0
,
function
()
{
var
pro
=
new
util
.
RationalNumber
()
pro
.
parseRationalNumber
(
0
,
0
)
var
res
=
pro
.
getCommonFactor
(
8
,
4
)
var
res
=
util
.
RationalNumber
.
getCommonFactor
(
8
,
4
)
expect
(
res
).
assertEqual
(
4
)
})
...
...
@@ -3769,9 +3736,7 @@ describe('RationalNumberTest', function () {
* @tc.desc: Obtains the greatest common divisor of two specified numbers.
*/
it
(
'
testgetCommonFactor004
'
,
0
,
function
()
{
var
pro
=
new
util
.
RationalNumber
()
pro
.
parseRationalNumber
(
0
,
0
)
var
res
=
pro
.
getCommonFactor
(
8
,
16
)
var
res
=
util
.
RationalNumber
.
getCommonFactor
(
8
,
16
)
expect
(
res
).
assertEqual
(
8
)
})
...
...
@@ -3780,9 +3745,7 @@ describe('RationalNumberTest', function () {
* @tc.desc: Obtains the greatest common divisor of two specified numbers.
*/
it
(
'
testgetCommonFactor005
'
,
0
,
function
()
{
var
pro
=
new
util
.
RationalNumber
()
pro
.
parseRationalNumber
(
0
,
0
)
var
res
=
pro
.
getCommonFactor
(
2
,
16
)
var
res
=
util
.
RationalNumber
.
getCommonFactor
(
2
,
16
)
expect
(
res
).
assertEqual
(
2
)
})
...
...
@@ -3792,9 +3755,7 @@ describe('RationalNumberTest', function () {
*/
it
(
'
testgetCommonFactorThrowError001
'
,
0
,
function
()
{
try
{
var
pro
=
new
util
.
RationalNumber
()
pro
.
parseRationalNumber
(
0
,
0
)
var
res
=
pro
.
getCommonFactor
(
'
str
'
,
8
)
var
res
=
util
.
RationalNumber
.
getCommonFactor
(
'
str
'
,
8
)
expect
(
res
).
assertEqual
(
4
)
}
catch
(
e
)
{
expect
(
e
.
toString
()).
assertEqual
(
"
BusinessError: Parameter error.The type of str must be number
"
);
...
...
@@ -4202,11 +4163,11 @@ describe('Base64HelperTest', function () {
})
/**
* @tc.name: test_encodeSync_base64_
005
* @tc.name: test_encodeSync_base64_
throwError_001
* @tc.desc: Asynchronously encodes all bytes in the specified u8 array into the newly allocated u8
array using the Base64 encoding scheme.
*/
it
(
'
test_encodeSync_base64_
005
'
,
0
,
async
function
()
{
it
(
'
test_encodeSync_base64_
throwError_001
'
,
0
,
async
function
()
{
try
{
var
that
=
new
util
.
Base64Helper
()
var
array
=
new
Uint32Array
([
66
,
97
,
115
,
101
,
54
,
52
]);
...
...
@@ -4455,11 +4416,11 @@ describe('Base64HelperTest', function () {
})
/**
* @tc.name: test_decode_base64_
01
1
* @tc.name: test_decode_base64_
throwError_00
1
* @tc.desc: Use the Base64 encoding scheme to asynchronously decode a Base64-encoded string or input u8
array into a newly allocated u8 array.
*/
it
(
'
test_decode_base64_
006
'
,
0
,
async
function
()
{
it
(
'
test_decode_base64_
throwError_001
'
,
0
,
async
function
()
{
try
{
var
that
=
new
util
.
Base64Helper
()
var
array
=
new
Uint16Array
([
99
,
122
,
69
,
122
]);
...
...
@@ -4550,10 +4511,10 @@ describe('DecodeEncodeTest', function () {
})
/**
* @tc.name: testencoding_textdecoder_ThrowError_00
2
* @tc.name: testencoding_textdecoder_ThrowError_00
3
* @tc.desc: The source encoding's name, lowercased.
*/
it
(
'
testencoding_textdecoder_ThrowError_00
2
'
,
0
,
function
()
{
it
(
'
testencoding_textdecoder_ThrowError_00
3
'
,
0
,
function
()
{
try
{
var
that
=
util
.
TextDecoder
.
create
(
'
utf-16be
'
,
123
)
var
encodingStr
=
that
.
encoding
...
...
@@ -4680,7 +4641,7 @@ describe('DecodeEncodeTest', function () {
* @tc.name: testEncodeInto010
* @tc.desc: Returns the result of encoder for GB18030.
*/
it
(
'
testEncodeInto0
0
10
'
,
0
,
function
()
{
it
(
'
testEncodeInto010
'
,
0
,
function
()
{
let
that
=
new
util
.
TextEncoder
(
'
GB18030
'
)
let
buffer
=
new
ArrayBuffer
(
20
)
let
result
=
new
Uint8Array
(
buffer
)
...
...
commonlibrary/ets_utils/util_lib_standard/src/main/js/test/util.test.js
浏览文件 @
df49bb27
...
...
@@ -2403,8 +2403,7 @@ describe('RationalNumberFunTest', function () {
* @tc.desc: Creates a RationalNumber object based on a given string.
*/
it
(
'
test_createRationalFromString_001
'
,
0
,
function
()
{
var
pro
=
new
util
.
RationalNumber
(
1
,
2
)
var
res
=
pro
.
createRationalFromString
(
'
-1:2
'
)
var
res
=
util
.
RationalNumber
.
createRationalFromString
(
'
-1:2
'
)
var
result1
=
res
.
valueOf
()
expect
(
result1
).
assertEqual
(
-
0.5
)
})
...
...
@@ -2414,8 +2413,7 @@ describe('RationalNumberFunTest', function () {
* @tc.desc: Creates a RationalNumber object based on a given string.
*/
it
(
'
test_createRationalFromString_002
'
,
0
,
function
()
{
var
pro
=
new
util
.
RationalNumber
(
1
,
2
)
var
res
=
pro
.
createRationalFromString
(
'
+3/4
'
)
var
res
=
util
.
RationalNumber
.
createRationalFromString
(
'
+3/4
'
)
var
result1
=
res
.
valueOf
()
expect
(
result1
).
assertEqual
(
0.75
)
})
...
...
@@ -2425,8 +2423,7 @@ describe('RationalNumberFunTest', function () {
* @tc.desc: Creates a RationalNumber object based on a given string.
*/
it
(
'
test_createRationalFromString_003
'
,
0
,
function
()
{
var
pro
=
new
util
.
RationalNumber
(
1
,
2
)
var
res
=
pro
.
createRationalFromString
(
'
+3:-4
'
)
var
res
=
util
.
RationalNumber
.
createRationalFromString
(
'
+3:-4
'
)
var
result1
=
res
.
valueOf
()
expect
(
result1
).
assertEqual
(
-
0.75
)
})
...
...
@@ -2436,8 +2433,7 @@ describe('RationalNumberFunTest', function () {
* @tc.desc: Creates a RationalNumber object based on a given string.
*/
it
(
'
test_createRationalFromString_004
'
,
0
,
function
()
{
var
pro
=
new
util
.
RationalNumber
(
1
,
2
)
var
res
=
pro
.
createRationalFromString
(
'
+2:4
'
)
var
res
=
util
.
RationalNumber
.
createRationalFromString
(
'
+2:4
'
)
var
result1
=
res
.
valueOf
()
expect
(
result1
).
assertEqual
(
0.5
)
})
...
...
@@ -2447,10 +2443,9 @@ describe('RationalNumberFunTest', function () {
* @tc.desc: Creates a RationalNumber object based on a given string.
*/
it
(
'
test_createRationalFromString_005
'
,
0
,
function
()
{
var
pro
=
new
util
.
RationalNumber
(
1
,
2
)
var
res
=
pro
.
createRationalFromString
(
'
+2:-4
'
)
var
res
=
util
.
RationalNumber
.
createRationalFromString
(
'
-2:-4
'
)
var
result1
=
res
.
valueOf
()
expect
(
result1
).
assertEqual
(
-
0.5
)
expect
(
result1
).
assertEqual
(
0.5
)
})
/**
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录