Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
Hello UTS
提交
175d3a51
H
Hello UTS
项目概览
DCloud
/
Hello UTS
通知
1598
Star
27
Fork
9
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
2
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
Hello UTS
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
2
Issue
2
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
175d3a51
编写于
7月 02, 2024
作者:
M
mahaifeng
1
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[array-buffer]添加测试用例
上级
bcb5b721
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
40 addition
and
19 deletion
+40
-19
uni_modules/uts-tests/utssdk/ArrayBuffer.uts
uni_modules/uts-tests/utssdk/ArrayBuffer.uts
+6
-0
uni_modules/uts-tests/utssdk/TFloat32Array.js
uni_modules/uts-tests/utssdk/TFloat32Array.js
+4
-0
uni_modules/uts-tests/utssdk/TUInt8Array.js
uni_modules/uts-tests/utssdk/TUInt8Array.js
+30
-19
未找到文件。
uni_modules/uts-tests/utssdk/ArrayBuffer.uts
浏览文件 @
175d3a51
...
@@ -75,6 +75,9 @@ export function testArrayBuffer() : Result {
...
@@ -75,6 +75,9 @@ export function testArrayBuffer() : Result {
test('float32_testSet', () => {
test('float32_testSet', () => {
float32.testSet()
float32.testSet()
})
})
test('float32_testFrom', () => {
float32.from()
})
test('float32_testCopyWith', () => {
test('float32_testCopyWith', () => {
float32.testCopyWith()
float32.testCopyWith()
})
})
...
@@ -434,6 +437,9 @@ export function testArrayBuffer() : Result {
...
@@ -434,6 +437,9 @@ export function testArrayBuffer() : Result {
test('uint8_testConstructor', () => {
test('uint8_testConstructor', () => {
uint8.testConstructor()
uint8.testConstructor()
})
})
test('uint8_from', () => {
uint8.from()
})
test('uint8_testSet', () => {
test('uint8_testSet', () => {
uint8.testSet()
uint8.testSet()
})
})
...
...
uni_modules/uts-tests/utssdk/TFloat32Array.js
浏览文件 @
175d3a51
...
@@ -32,6 +32,10 @@ export class TFloat32Array {
...
@@ -32,6 +32,10 @@ export class TFloat32Array {
this
.
values
();
this
.
values
();
this
.
arrayBufferSlice
();
this
.
arrayBufferSlice
();
}
}
from
(){
var
float32Array
=
Float32Array
.
from
([
1
,
2
,
3
],
(
v
:
number
,
_
:
number
):
number
=>
v
+
v
);
expect
(
float32Array
.
toString
()).
toEqual
(
'
2,4,6
'
);
}
testfloat32
()
{
testfloat32
()
{
let
float32
=
new
Float32Array
(
2
);
let
float32
=
new
Float32Array
(
2
);
...
...
uni_modules/uts-tests/utssdk/TUInt8Array.js
浏览文件 @
175d3a51
...
@@ -32,7 +32,12 @@ export class TUint8Array {
...
@@ -32,7 +32,12 @@ export class TUint8Array {
this
.
values
();
this
.
values
();
this
.
arrayBufferSlice
();
this
.
arrayBufferSlice
();
}
}
from
()
{
var
s
=
new
Set
([
1
,
2
,
3
]);
var
unit8
=
Uint8Array
.
from
(
s
);
expect
(
unit8
.
toString
()).
toEqual
(
'
1,2,3
'
);
console
.
log
(
unit8
.
toString
())
}
testMAX
()
{
testMAX
()
{
let
float32
=
new
Uint8Array
(
16
);
let
float32
=
new
Uint8Array
(
16
);
float32
[
0
]
=
255
;
float32
[
0
]
=
255
;
...
@@ -48,7 +53,7 @@ export class TUint8Array {
...
@@ -48,7 +53,7 @@ export class TUint8Array {
testSet
()
{
testSet
()
{
let
float32
=
new
Uint8Array
(
8
);
let
float32
=
new
Uint8Array
(
8
);
var
array
=
[
1
,
2
,
3
]
var
array
=
[
1
,
2
,
3
]
float32
.
set
(
array
,
1
);
float32
.
set
(
array
,
1
);
expect
(
float32
.
toString
()).
toEqual
(
"
0,1,2,3,0,0,0,0
"
);
expect
(
float32
.
toString
()).
toEqual
(
"
0,1,2,3,0,0,0,0
"
);
}
}
...
@@ -58,13 +63,14 @@ export class TUint8Array {
...
@@ -58,13 +63,14 @@ export class TUint8Array {
let
float32
=
new
Uint8Array
(
8
);
let
float32
=
new
Uint8Array
(
8
);
float32
.
set
([
1
,
2
,
3
],
1
);
float32
.
set
([
1
,
2
,
3
],
1
);
float32
.
copyWithin
(
3
,
0
,
3
);
float32
.
copyWithin
(
3
,
0
,
3
);
expect
(
float32
.
toString
()).
toEqual
(
"
0,1,2,0,1,2,0,0
"
);
expect
(
float32
.
toString
()).
toEqual
(
"
0,1,2,0,1,2,0,0
"
);
}
}
testEvery
()
{
testEvery
()
{
// const isBelowThreshold = (currentValue: number, index: number, array:Uint8Array): boolean => currentValue < 40;
// const isBelowThreshold = (currentValue: number, index: number, array:Uint8Array): boolean => currentValue < 40;
let
result
=
new
Uint8Array
([
12
,
5
,
8
,
130
,
44
]).
every
((
value
:
number
,
_
:
number
,
_
:
Uint8Array
):
boolean
=>
value
<
40
);
//
let
result
=
new
Uint8Array
([
12
,
5
,
8
,
130
,
44
]).
every
((
value
:
number
,
_
:
number
,
_
:
Uint8Array
):
boolean
=>
value
<
40
);
//
expect
(
result
).
toEqual
(
false
);
expect
(
result
).
toEqual
(
false
);
}
}
...
@@ -87,29 +93,30 @@ export class TUint8Array {
...
@@ -87,29 +93,30 @@ export class TUint8Array {
testFilter
()
{
testFilter
()
{
// const isBelowThreshold = (currentValue: number, index: number, _): boolean => currentValue >= 10;
// const isBelowThreshold = (currentValue: number, index: number, _): boolean => currentValue >= 10;
let
float32
=
new
Uint8Array
([
12
,
5
,
8
,
44
]).
filter
((
value
:
number
,
_
:
number
,
_
:
Uint8Array
):
boolean
=>
value
>=
10
);
let
float32
=
new
Uint8Array
([
12
,
5
,
8
,
44
]).
filter
((
value
:
number
,
_
:
number
,
_
:
Uint8Array
):
boolean
=>
value
>=
10
);
expect
(
float32
.
toString
()).
toEqual
(
"
12,44
"
);
expect
(
float32
.
toString
()).
toEqual
(
"
12,44
"
);
}
}
find
()
{
find
()
{
let
float32
=
new
Uint8Array
([
4
,
5
,
8
,
12
]);
let
float32
=
new
Uint8Array
([
4
,
5
,
8
,
12
]);
let
res
=
float32
.
find
((
value
:
number
,
_
:
number
,
_
:
Uint8Array
):
boolean
=>
value
>
5
);
let
res
=
float32
.
find
((
value
:
number
,
_
:
number
,
_
:
Uint8Array
):
boolean
=>
value
>
5
);
expect
(
res
).
toEqual
(
8
);
expect
(
res
).
toEqual
(
8
);
}
}
findIndex
()
{
findIndex
()
{
let
float32
=
new
Uint8Array
([
4
,
6
,
8
,
12
]);
let
float32
=
new
Uint8Array
([
4
,
6
,
8
,
12
]);
let
res
=
float32
.
findIndex
((
value
:
number
,
_
:
number
,
_
:
Uint8Array
):
boolean
=>
value
>
100
);
let
res
=
float32
.
findIndex
((
value
:
number
,
_
:
number
,
_
:
Uint8Array
):
boolean
=>
value
>
100
);
expect
(
res
).
toEqual
(
-
1
);
expect
(
res
).
toEqual
(
-
1
);
let
ufloat32
=
new
Uint8Array
([
4
,
6
,
7
,
120
]);
let
ufloat32
=
new
Uint8Array
([
4
,
6
,
7
,
120
]);
res
=
ufloat32
.
findIndex
((
value
:
number
,
_
:
number
,
_
:
Uint8Array
):
boolean
=>
value
>
100
);
res
=
ufloat32
.
findIndex
((
value
:
number
,
_
:
number
,
_
:
Uint8Array
):
boolean
=>
value
>
100
);
expect
(
res
).
toEqual
(
3
);
expect
(
res
).
toEqual
(
3
);
}
}
foreach
()
{
foreach
()
{
new
Uint8Array
([
0
,
1
,
2
,
3
]).
forEach
((
value
:
number
,
index
:
number
,
_
:
Uint8Array
)
=>
{
new
Uint8Array
([
0
,
1
,
2
,
3
]).
forEach
((
value
:
number
,
index
:
number
,
_
:
Uint8Array
)
=>
{
console
.
log
(
`a[
${
index
}
] =
${
value
}
`
);
console
.
log
(
`a[
${
index
}
] =
${
value
}
`
);
});
});
}
}
...
@@ -118,7 +125,7 @@ export class TUint8Array {
...
@@ -118,7 +125,7 @@ export class TUint8Array {
let
arr
=
new
Uint8Array
([
10
,
20
,
30
,
40
,
50
]);
let
arr
=
new
Uint8Array
([
10
,
20
,
30
,
40
,
50
]);
let
entries
=
arr
.
entries
();
let
entries
=
arr
.
entries
();
expect
(
entries
.
next
().
value
[
1
]).
toEqual
(
10
);
expect
(
entries
.
next
().
value
[
1
]).
toEqual
(
10
);
}
}
includes
()
{
includes
()
{
...
@@ -171,28 +178,32 @@ export class TUint8Array {
...
@@ -171,28 +178,32 @@ export class TUint8Array {
map
()
{
map
()
{
let
numbers
=
new
Uint8Array
([
1
,
4
,
9
]);
let
numbers
=
new
Uint8Array
([
1
,
4
,
9
]);
let
doubles
=
numbers
.
map
((
value
:
number
,
_
:
number
,
_
:
Uint8Array
):
number
=>
value
*
2
);
let
doubles
=
numbers
.
map
((
value
:
number
,
_
:
number
,
_
:
Uint8Array
):
number
=>
value
*
2
);
expect
(
numbers
.
toString
()).
toEqual
(
"
1,4,9
"
);
expect
(
numbers
.
toString
()).
toEqual
(
"
1,4,9
"
);
expect
(
doubles
.
toString
()).
toEqual
(
"
2,8,18
"
);
expect
(
doubles
.
toString
()).
toEqual
(
"
2,8,18
"
);
}
}
reduce
()
{
reduce
()
{
let
total
=
new
Uint8Array
([
0
,
1
,
2
,
3
]);
let
total
=
new
Uint8Array
([
0
,
1
,
2
,
3
]);
let
res
=
total
.
reduce
((
accumulator
:
number
,
currentValue
:
number
,
_
:
number
,
_
:
Uint8Array
):
number
=>
accumulator
+
currentValue
);
let
res
=
total
.
reduce
((
accumulator
:
number
,
currentValue
:
number
,
_
:
number
,
_
:
Uint8Array
):
number
=>
accumulator
+
currentValue
);
expect
(
res
).
toEqual
(
6
);
expect
(
res
).
toEqual
(
6
);
total
=
new
Uint8Array
([
0
,
1
,
2
,
3
]);
total
=
new
Uint8Array
([
0
,
1
,
2
,
3
]);
res
=
total
.
reduce
((
accumulator
:
number
,
currentValue
:
number
,
_
:
number
,
_
:
Uint8Array
):
number
=>
accumulator
+
currentValue
,
8
);
res
=
total
.
reduce
((
accumulator
:
number
,
currentValue
:
number
,
_
:
number
,
_
:
Uint8Array
):
number
=>
accumulator
+
currentValue
,
8
);
expect
(
res
).
toEqual
(
14
);
expect
(
res
).
toEqual
(
14
);
}
}
reduceRight
()
{
reduceRight
()
{
let
total
=
new
Uint8Array
([
0
,
1
,
2
,
3
]);
let
total
=
new
Uint8Array
([
0
,
1
,
2
,
3
]);
let
res
=
total
.
reduceRight
((
accumulator
:
number
,
currentValue
:
number
,
_
:
number
,
_
:
Uint8Array
):
number
=>
accumulator
+
currentValue
);
let
res
=
total
.
reduceRight
((
accumulator
:
number
,
currentValue
:
number
,
_
:
number
,
_
:
Uint8Array
):
number
=>
accumulator
+
currentValue
);
expect
(
res
).
toEqual
(
6
);
expect
(
res
).
toEqual
(
6
);
total
=
new
Uint8Array
([
0
,
1
,
2
,
3
]);
total
=
new
Uint8Array
([
0
,
1
,
2
,
3
]);
res
=
total
.
reduceRight
((
accumulator
:
number
,
currentValue
:
number
,
_
:
number
,
_
:
Uint8Array
):
number
=>
accumulator
+
currentValue
,
8
);
res
=
total
.
reduceRight
((
accumulator
:
number
,
currentValue
:
number
,
_
:
number
,
_
:
Uint8Array
):
number
=>
accumulator
+
currentValue
,
8
);
expect
(
res
).
toEqual
(
14
);
expect
(
res
).
toEqual
(
14
);
}
}
...
@@ -222,7 +233,7 @@ export class TUint8Array {
...
@@ -222,7 +233,7 @@ export class TUint8Array {
numbers
.
sort
();
numbers
.
sort
();
expect
(
numbers
.
toString
()).
toEqual
(
"
1,5,40
"
);
expect
(
numbers
.
toString
()).
toEqual
(
"
1,5,40
"
);
numbers
.
sort
((
a
,
b
):
Number
=>
a
-
b
);
numbers
.
sort
((
a
,
b
):
Number
=>
a
-
b
);
expect
(
numbers
.
toString
()).
toEqual
(
"
1,5,40
"
);
expect
(
numbers
.
toString
()).
toEqual
(
"
1,5,40
"
);
}
}
...
@@ -240,7 +251,7 @@ export class TUint8Array {
...
@@ -240,7 +251,7 @@ export class TUint8Array {
let
arr
=
new
Uint8Array
([
1
,
2
,
3
]);
let
arr
=
new
Uint8Array
([
1
,
2
,
3
]);
let
values
=
arr
.
values
();
let
values
=
arr
.
values
();
expect
(
values
.
next
().
value
).
toEqual
(
1
);
expect
(
values
.
next
().
value
).
toEqual
(
1
);
}
}
arrayBufferSlice
()
{
arrayBufferSlice
()
{
...
@@ -253,4 +264,4 @@ export class TUint8Array {
...
@@ -253,4 +264,4 @@ export class TUint8Array {
let
sliced
=
new
Uint8Array
(
res
);
let
sliced
=
new
Uint8Array
(
res
);
expect
(
sliced
[
0
]).
toEqual
(
42
);
expect
(
sliced
[
0
]).
toEqual
(
42
);
}
}
}
}
\ No newline at end of file
WOSHIMAHAIFENG
@WOSHIMAHAIFENG
mentioned in commit
b2f31d5f
·
7月 15, 2024
mentioned in commit
b2f31d5f
mentioned in commit b2f31d5f38c3c20b3158345865abe202efefef8b
开关提交列表
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录