Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
7d507405
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看板
未验证
提交
7d507405
编写于
9月 26, 2022
作者:
O
openharmony_ci
提交者:
Gitee
9月 26, 2022
浏览文件
操作
浏览文件
下载
差异文件
!5635 cherry-pick !5581 Add xts cases to buffer
Merge pull request !5635 from 冷昌晶/OpenHarmony-3.2-Beta3
上级
7882e85c
4d9e14e4
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
147 addition
and
9 deletion
+147
-9
commonlibrary/ets_utils/buffer_lib_standard/src/main/js/test/Buffer.test.js
...utils/buffer_lib_standard/src/main/js/test/Buffer.test.js
+147
-9
未找到文件。
commonlibrary/ets_utils/buffer_lib_standard/src/main/js/test/Buffer.test.js
浏览文件 @
7d507405
...
...
@@ -108,6 +108,36 @@ describe('BufferTest', function () {
}
});
/**
* @tc.name: testAlloc0017
* @tc.desc: Allocates a new Buffer for a fixed size bytes. If fill is undefined, the Buffer will be zero-filled.
* For example: buffer.alloc(10, string, encode);
* @tc.author: lengchangjing
*/
it
(
"
testAlloc0017
"
,
0
,
function
()
{
let
encodeArr
=
[
'
utf8
'
,
'
utf-8
'
,
'
ucs2
'
,
'
ucs-2
'
,
'
ascii
'
,
'
latin1
'
,
'
binary
'
,
'
utf16le
'
,
'
utf-16le
'
,
'
base64
'
,
'
base64url
'
,
'
hex
'
];
for
(
const
encode
of
encodeArr
)
{
let
buf
=
buffer
.
alloc
(
10
,
"
ab$#
"
,
encode
);
expect
(
buf
.
length
).
assertEqual
(
10
);
}
});
/**
* @tc.name: testAlloc0018
* @tc.desc: Allocates a new Buffer for a fixed size bytes. If fill is undefined, the Buffer will be zero-filled.
* For example: buffer.alloc(0).fill(string, encode);
* @tc.author: lengchangjing
*/
it
(
"
testAlloc0018
"
,
0
,
function
()
{
let
encodeArr
=
[
'
utf8
'
,
'
utf-8
'
,
'
ucs2
'
,
'
ucs-2
'
,
'
ascii
'
,
'
latin1
'
,
'
binary
'
,
'
utf16le
'
,
'
utf-16le
'
,
'
base64
'
,
'
base64url
'
,
'
hex
'
];
for
(
const
encode
of
encodeArr
)
{
let
buf
=
buffer
.
alloc
(
0
,
"
ab$#
"
,
encode
);
expect
(
buf
.
length
).
assertEqual
(
0
);
}
});
/**
* @tc.name: testAlloc0019
* @tc.desc: Allocates a new Buffer for a fixed size bytes. If fill is undefined, the Buffer will be zero-filled.
...
...
@@ -1016,6 +1046,22 @@ describe('BufferTest', function () {
expect
(
index
).
assertEqual
(
-
1
);
});
/**
* @tc.name: testIndexOf0177
* @tc.desc: Returns true if value was found in buf, false otherwise.
* For example: let buf = buffer.from("13236"); buf.indexOf("a", 0, "utf8");
* @tc.author: lengchangjing
*/
it
(
"
testIndexOf0177
"
,
0
,
function
()
{
let
encodeArr
=
[
'
utf8
'
,
'
utf-8
'
,
'
ucs2
'
,
'
ucs-2
'
,
'
ascii
'
,
'
latin1
'
,
'
binary
'
,
'
utf16le
'
,
'
utf-16le
'
,
'
base64
'
,
'
base64url
'
,
'
hex
'
];
let
buf
=
buffer
.
from
(
"
13236
"
);
for
(
const
encode
of
encodeArr
)
{
let
index
=
buf
.
indexOf
(
"
ab
"
,
0
,
encode
);
expect
(
index
).
assertEqual
(
-
1
);
}
});
/**
* @tc.name: testLastIndexOf0180
* @tc.desc: The index of the last occurrence of value in buf.
...
...
@@ -1076,6 +1122,22 @@ describe('BufferTest', function () {
expect
(
index
).
assertEqual
(
-
1
);
});
/**
* @tc.name: testLastIndexOf0187
* @tc.desc: Returns true if value was found in buf, false otherwise.
* For example: let buf = buffer.from("13236"); buf.lastIndexOf("a", 0, "utf8");
* @tc.author: lengchangjing
*/
it
(
"
testLastIndexOf0187
"
,
0
,
function
()
{
let
encodeArr
=
[
'
utf8
'
,
'
utf-8
'
,
'
ucs2
'
,
'
ucs-2
'
,
'
ascii
'
,
'
latin1
'
,
'
binary
'
,
'
utf16le
'
,
'
utf-16le
'
,
'
base64
'
,
'
base64url
'
,
'
hex
'
];
let
buf
=
buffer
.
from
(
"
13236
"
);
for
(
const
encode
of
encodeArr
)
{
let
index
=
buf
.
lastIndexOf
(
"
ab
"
,
0
,
encode
);
expect
(
index
).
assertEqual
(
-
1
);
}
});
/**
* @tc.name: testIncludes0190
* @tc.desc: Returns true if value was found in buf, false otherwise.
...
...
@@ -1150,6 +1212,22 @@ describe('BufferTest', function () {
expect
(
flag
).
assertEqual
(
false
);
});
/**
* @tc.name: testIncludes0197
* @tc.desc: Returns true if value was found in buf, false otherwise.
* For example: let buf1 = buffer.from("13236"); buf1.includes("abc", 0, "utf8");
* @tc.author: lengchangjing
*/
it
(
"
testIncludes0197
"
,
0
,
function
()
{
let
encodeArr
=
[
'
utf8
'
,
'
utf-8
'
,
'
ucs2
'
,
'
ucs-2
'
,
'
ascii
'
,
'
latin1
'
,
'
binary
'
,
'
utf16le
'
,
'
utf-16le
'
,
'
base64
'
,
'
base64url
'
,
'
hex
'
];
for
(
const
encode
of
encodeArr
)
{
let
buf
=
buffer
.
from
(
"
13236
"
);
let
flag
=
buf
.
includes
(
"
abc
"
,
0
,
encode
);
expect
(
flag
).
assertEqual
(
false
);
}
});
/**
* @tc.name: testSwap160200
* @tc.desc: Interprets buf as an array of unsigned 16-bit integers and swaps the byte order in-place.
...
...
@@ -1421,20 +1499,36 @@ describe('BufferTest', function () {
str
=
buf3
.
toString
(
"
base64
"
);
expect
(
str
).
assertEqual
(
"
F1FG
"
);
let
buf4
=
buffer
.
from
(
"
F1FG刘
"
,
"
binary
"
)
str
=
buf4
.
toString
(
"
binary
"
);
let
buf4
=
buffer
.
from
(
"
F1FG刘
"
,
"
base64url
"
)
str
=
buf4
.
toString
(
"
base64url
"
);
expect
(
str
).
assertEqual
(
"
F1FG
"
);
let
buf5
=
buffer
.
from
(
"
F1FG刘
"
,
"
binary
"
)
str
=
buf5
.
toString
(
"
binary
"
);
expect
(
str
).
assertEqual
(
"
F1FGå
"
);
let
buf
5
=
buffer
.
from
(
"
F1FG刘
"
,
"
latin1
"
)
str
=
buf
5
.
toString
(
"
latin1
"
);
let
buf
6
=
buffer
.
from
(
"
F1FG刘
"
,
"
latin1
"
)
str
=
buf
6
.
toString
(
"
latin1
"
);
expect
(
str
).
assertEqual
(
"
F1FGe
"
);
let
buf6
=
buffer
.
from
(
"
F1FG刘
"
,
"
ucs2
"
)
str
=
buf6
.
toString
(
"
ucs2
"
);
let
buf7
=
buffer
.
from
(
"
F1FG刘
"
,
"
ucs2
"
)
str
=
buf7
.
toString
(
"
ucs2
"
);
expect
(
str
).
assertEqual
(
"
F1FG刘
"
);
let
buf8
=
buffer
.
from
(
"
F1FG刘
"
,
"
utf16le
"
)
str
=
buf8
.
toString
(
"
utf16le
"
);
expect
(
str
).
assertEqual
(
"
F1FG刘
"
);
let
buf7
=
buffer
.
from
(
"
F1FG刘
"
,
"
utf-8
"
)
str
=
buf7
.
toString
(
"
utf-8
"
);
let
buf9
=
buffer
.
from
(
"
F1FG刘
"
,
"
ucs2
"
)
str
=
buf9
.
toString
(
"
ucs2
"
);
expect
(
str
).
assertEqual
(
"
F1FG刘
"
);
let
buf10
=
buffer
.
from
(
"
F1FG刘
"
,
"
utf-8
"
)
str
=
buf10
.
toString
(
"
utf-8
"
);
expect
(
str
).
assertEqual
(
"
F1FG刘
"
);
let
buf11
=
buffer
.
from
(
"
F1FG刘
"
,
"
utf8
"
)
str
=
buf11
.
toString
(
"
utf8
"
);
expect
(
str
).
assertEqual
(
"
F1FG刘
"
);
});
...
...
@@ -3223,12 +3317,56 @@ describe('BufferTest', function () {
* @tc.desc: Returns the number of bytes in buf.
* @tc.author: liuganlin
*/
it
(
"
testBufferLength075
1
"
,
0
,
function
()
{
it
(
"
testBufferLength075
2
"
,
0
,
function
()
{
let
buf
=
buffer
.
from
(
"
测试特殊字符$#@!
"
);
let
len
=
buf
.
length
;
expect
(
len
).
assertEqual
(
22
);
});
/**
* @tc.name: testBufferByteOffset0755
* @tc.desc: Returns the offset of bytes in buf.
* @tc.author: lengchangjing
*/
it
(
"
testBufferByteOffset0755
"
,
0
,
function
()
{
let
buf
=
buffer
.
from
(
"
1236
"
);
let
offset
=
buf
.
byteOffset
;
expect
(
offset
>=
0
).
assertTrue
();
});
/**
* @tc.name: testBufferByteOffset0756
* @tc.desc: Returns the offset of bytes in buf.
* @tc.author: lengchangjing
*/
it
(
"
testBufferByteOffset0756
"
,
0
,
function
()
{
let
buf
=
buffer
.
alloc
(
10
);
let
offset
=
buf
.
byteOffset
;
expect
(
offset
>=
0
).
assertTrue
();
});
/**
* @tc.name: testBufferByteOffset0757
* @tc.desc: Returns the offset of bytes in buf.
* @tc.author: lengchangjing
*/
it
(
"
testBufferByteOffset0757
"
,
0
,
function
()
{
let
buf
=
buffer
.
allocUninitializedFromPool
(
10
);
let
offset
=
buf
.
byteOffset
;
expect
(
offset
>=
0
).
assertTrue
();
});
/**
* @tc.name: testBufferByteOffset0758
* @tc.desc: Returns the offset of bytes in buf.
* @tc.author: lengchangjing
*/
it
(
"
testBufferByteOffset0758
"
,
0
,
function
()
{
let
buf
=
buffer
.
allocUninitialized
(
10
);
let
offset
=
buf
.
byteOffset
;
expect
(
offset
>=
0
).
assertTrue
();
});
/**
* @tc.name: testBlobSize0760
* @tc.desc: The total size of the Blob in bytes.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录