Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
5c702c02
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,发现更多精彩内容 >>
未验证
提交
5c702c02
编写于
6月 17, 2022
作者:
O
openharmony_ci
提交者:
Gitee
6月 17, 2022
浏览文件
操作
浏览文件
下载
差异文件
!3511 encode adds gb18030 gbk gb2312 format
Merge pull request !3511 from 王犇/master
上级
7d46b39c
5d2b2182
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
161 addition
and
0 deletion
+161
-0
compileruntime/util_lib_standard/src/main/js/test/util.test.js
...leruntime/util_lib_standard/src/main/js/test/util.test.js
+161
-0
未找到文件。
compileruntime/util_lib_standard/src/main/js/test/util.test.js
浏览文件 @
5c702c02
...
...
@@ -812,6 +812,48 @@ describe('TextEncoderTest', function () {
expect
(
result
[
0
]).
assertEqual
(
0x61
)
})
/**
* @tc.name: testEncoding002
* @tc.desc: Encoding format test gb18030.
* @tc.author: wangben
*/
it
(
'
testEncoding002
'
,
0
,
function
()
{
let
that
=
new
util
.
TextEncoder
(
'
gb18030
'
)
let
str
=
that
.
encoding
expect
(
str
).
assertEqual
(
'
gb18030
'
)
that
=
new
util
.
TextEncoder
(
'
GB18030
'
)
str
=
that
.
encoding
;
expect
(
str
).
assertEqual
(
'
GB18030
'
)
})
/**
* @tc.name: testEncoding003
* @tc.desc: Encoding format test gbk.
* @tc.author: wangben
*/
it
(
'
testEncoding003
'
,
0
,
function
()
{
let
that
=
new
util
.
TextEncoder
(
'
gbk
'
)
let
str
=
that
.
encoding
expect
(
str
).
assertEqual
(
'
gbk
'
)
that
=
new
util
.
TextEncoder
(
'
GBK
'
)
str
=
that
.
encoding
;
expect
(
str
).
assertEqual
(
'
GBK
'
)
})
/**
* @tc.name: testEncoding004
* @tc.desc: Encoding format test gb2313.
* @tc.author: wangben
*/
it
(
'
testEncoding004
'
,
0
,
function
()
{
let
that
=
new
util
.
TextEncoder
(
'
gb2312
'
)
let
str
=
that
.
encoding
expect
(
str
).
assertEqual
(
'
gb2312
'
)
that
=
new
util
.
TextEncoder
(
'
GB2312
'
)
str
=
that
.
encoding
;
expect
(
str
).
assertEqual
(
'
GB2312
'
)
})
/**
* @tc.name: testEncode002
* @tc.desc: Returns the result of encoder.
...
...
@@ -904,6 +946,125 @@ describe('TextEncoderTest', function () {
expect
(
result
[
0
]).
assertEqual
(
0x24
)
})
/**
* @tc.name: testEncode009
* @tc.desc: Returns the result of encoder for gb18030.
* @tc.author: wangben
*/
it
(
'
testEncode009
'
,
0
,
function
()
{
let
that
=
new
util
.
TextEncoder
(
'
gb18030
'
)
let
buffer
=
new
ArrayBuffer
(
20
)
let
result
=
new
Uint8Array
(
buffer
)
result
=
that
.
encode
(
'
abc哈哈熠熠
'
)
expect
(
result
[
0
]).
assertEqual
(
97
)
expect
(
result
[
3
]).
assertEqual
(
185
)
expect
(
result
[
4
]).
assertEqual
(
254
)
expect
(
result
[
7
]).
assertEqual
(
236
)
expect
(
result
[
8
]).
assertEqual
(
218
)
})
/**
* @tc.name: testEncode010
* @tc.desc: Returns the result of encoder for GB18030.
* @tc.author: wangben
*/
it
(
'
testEncode0010
'
,
0
,
function
()
{
let
that
=
new
util
.
TextEncoder
(
'
GB18030
'
)
let
buffer
=
new
ArrayBuffer
(
20
)
let
result
=
new
Uint8Array
(
buffer
)
result
=
that
.
encode
(
'
abc哈哈熠熠
'
)
expect
(
result
[
0
]).
assertEqual
(
97
)
expect
(
result
[
3
]).
assertEqual
(
185
)
expect
(
result
[
4
]).
assertEqual
(
254
)
expect
(
result
[
7
]).
assertEqual
(
236
)
expect
(
result
[
8
]).
assertEqual
(
218
)
})
/**
* @tc.name: testEncode011
* @tc.desc: Returns the result of encoder for GB18030.
* @tc.author: wangben
*/
it
(
'
testEncode0011
'
,
0
,
function
()
{
let
that
=
new
util
.
TextEncoder
(
'
GBK
'
)
let
buffer
=
new
ArrayBuffer
(
20
)
let
result
=
new
Uint8Array
(
buffer
)
result
=
that
.
encode
(
'
abc哈哈熠熠
'
)
expect
(
result
[
0
]).
assertEqual
(
97
)
expect
(
result
[
3
]).
assertEqual
(
185
)
expect
(
result
[
4
]).
assertEqual
(
254
)
expect
(
result
[
7
]).
assertEqual
(
236
)
expect
(
result
[
8
]).
assertEqual
(
218
)
})
/**
* @tc.name: testEncode012
* @tc.desc: Returns the result of encoder for gbk.
* @tc.author: wangben
*/
it
(
'
testEncode012
'
,
0
,
function
()
{
let
that
=
new
util
.
TextEncoder
(
'
gbk
'
)
let
buffer
=
new
ArrayBuffer
(
20
)
let
result
=
new
Uint8Array
(
buffer
)
result
=
that
.
encode
(
'
abc哈哈熠熠
'
)
expect
(
result
[
0
]).
assertEqual
(
97
)
expect
(
result
[
3
]).
assertEqual
(
185
)
expect
(
result
[
4
]).
assertEqual
(
254
)
expect
(
result
[
7
]).
assertEqual
(
236
)
expect
(
result
[
8
]).
assertEqual
(
218
)
})
/**
* @tc.name: testEncode013
* @tc.desc: Returns the result of encoder for gb2312.
* @tc.author: wangben
*/
it
(
'
testEncode013
'
,
0
,
function
()
{
let
that
=
new
util
.
TextEncoder
(
'
gb2312
'
)
let
buffer
=
new
ArrayBuffer
(
20
)
let
result
=
new
Uint8Array
(
buffer
)
result
=
that
.
encode
(
'
abc哈哈熠熠
'
)
expect
(
result
[
0
]).
assertEqual
(
97
)
expect
(
result
[
3
]).
assertEqual
(
185
)
expect
(
result
[
4
]).
assertEqual
(
254
)
expect
(
result
[
7
]).
assertEqual
(
236
)
expect
(
result
[
8
]).
assertEqual
(
218
)
})
/**
* @tc.name: testEncode014
* @tc.desc: Returns the result of encoder for gb2312.
* @tc.author: wangben
*/
it
(
'
testEncode014
'
,
0
,
function
()
{
let
that
=
new
util
.
TextEncoder
(
'
GB2312
'
)
let
buffer
=
new
ArrayBuffer
(
20
)
let
result
=
new
Uint8Array
(
buffer
)
result
=
that
.
encode
(
'
abc哈哈熠熠
'
)
expect
(
result
[
0
]).
assertEqual
(
97
)
expect
(
result
[
3
]).
assertEqual
(
185
)
expect
(
result
[
4
]).
assertEqual
(
254
)
expect
(
result
[
7
]).
assertEqual
(
236
)
expect
(
result
[
8
]).
assertEqual
(
218
)
})
/**
* @tc.name: testEncode015
* @tc.desc: Returns the result of encoder for gb2312, input long string.
* @tc.author: wangben
*/
it
(
'
testEncode015
'
,
0
,
function
()
{
let
that
=
new
util
.
TextEncoder
(
'
GB18030
'
)
let
buffer
=
new
ArrayBuffer
(
900
)
let
result
=
new
Uint8Array
(
buffer
)
result
=
that
.
encode
(
'
abcd哈哈哈哈哈哈哈哈哈哈哈哈哈abcd哈哈哈哈哈哈哈哈哈哈哈哈哈abcd哈哈哈哈哈哈哈哈哈哈哈哈哈abcd哈哈哈哈哈哈哈哈哈哈哈哈哈
'
)
expect
(
result
[
6
]).
assertEqual
(
185
)
expect
(
result
[
30
]).
assertEqual
(
97
)
expect
(
result
[
57
]).
assertEqual
(
254
)
expect
(
result
[
98
]).
assertEqual
(
185
)
expect
(
result
[
119
]).
assertEqual
(
254
)
})
/**
* @tc.name: testEncodeInto001
* @tc.desc: encode string, write the result to dest array.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录