Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
Hello UTS
提交
babeb0ba
H
Hello UTS
项目概览
DCloud
/
Hello UTS
通知
1595
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看板
提交
babeb0ba
编写于
7月 18, 2024
作者:
M
mahaifeng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[array-buffer]添加测试用例
上级
4dda08b4
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
126 addition
and
2 deletion
+126
-2
uni_modules/uts-tests/utssdk/ArrayBuffer.uts
uni_modules/uts-tests/utssdk/ArrayBuffer.uts
+69
-0
uni_modules/uts-tests/utssdk/TFloat32Array.uts
uni_modules/uts-tests/utssdk/TFloat32Array.uts
+10
-0
uni_modules/uts-tests/utssdk/TFloat64Array.uts
uni_modules/uts-tests/utssdk/TFloat64Array.uts
+47
-2
未找到文件。
uni_modules/uts-tests/utssdk/ArrayBuffer.uts
浏览文件 @
babeb0ba
...
@@ -69,7 +69,76 @@ export function testArrayBuffer() : Result {
...
@@ -69,7 +69,76 @@ export function testArrayBuffer() : Result {
tDataView.doTestDataViewFloats()
tDataView.doTestDataViewFloats()
})
})
//dataview end
//dataview end
//typedarray start
test('typedarray_testConstructor', () => {
var arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16];
var int32 = new Int32Array(arr);
expect(int32.toString()).toEqual("1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16");
var buffer = new ArrayBuffer(64);
int32 = new Int32Array(buffer);
expect(int32.byteLength).toEqual(64);
var length = 1024;
var arrUnit8 = new Uint8Array(length);
for (var i = 0; i < length; i++) {
arrUnit8[i] = i;
}
var uint8 = new Uint8Array(arrUnit8);
expect(uint8.byteLength).toEqual(1024);
length = 1024;
uint8 = new Uint8Array(length);
for (var i = 0; i < length; i++) {
uint8[i] = i;
}
var float64 = new Float64Array(uint8);
expect(float64.length).toEqual(1024);
int32 = new Int32Array(16);
expect(int32.length).toEqual(16);
})
test('typedarray_from_different_type', () => {
const length = 16;
const dest_arrays = [
new Uint8Array(length),
new Int8Array(length),
new Uint16Array(length),
new Int16Array(length),
new Uint32Array(length),
new Int32Array(length),
new Float32Array(length),
new Float64Array(length),
new Uint8ClampedArray(length)
];
let uint8_array = new Uint8Array(length);
let int32_array = new Int32Array(length);
let float32_array = new Float32Array(length);
let float64_array = new Float64Array(length);
for (let i = 0; i < length; i++) {
uint8_array[i] = i;
int32_array[i] = i;
float32_array[i] = i;
float64_array[i] = i;
}
for (let i = 0; i < dest_arrays.length; i++) {
var typed_dest = dest_arrays[i]
typed_dest.set(uint8_array)
expect(typed_dest.length).toEqual(16)
typed_dest.set(int32_array)
expect(typed_dest.length).toEqual(16)
typed_dest.set(float32_array)
expect(typed_dest.length).toEqual(16)
typed_dest.set(float64_array)
expect(typed_dest.length).toEqual(16)
}
})
//typedarray end
//float32array start
//float32array start
test('float32_testConstructor', () => {
test('float32_testConstructor', () => {
float32.testConstructor()
float32.testConstructor()
...
...
uni_modules/uts-tests/utssdk/TFloat32Array.uts
浏览文件 @
babeb0ba
...
@@ -76,6 +76,16 @@ export class TFloat32Array {
...
@@ -76,6 +76,16 @@ export class TFloat32Array {
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");
let src = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4];
let typed_dest = new Float32Array(16);
typed_dest.set(src);
expect(typed_dest.toString()).toEqual("1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4");
let typed_src = new Float32Array(src);
typed_dest = new Float32Array(16);
typed_dest.set(typed_src);
expect(typed_dest.toString()).toEqual("1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4");
// #END
// #END
}
}
...
...
uni_modules/uts-tests/utssdk/TFloat64Array.uts
浏览文件 @
babeb0ba
...
@@ -76,6 +76,19 @@ export class TFloat64Array {
...
@@ -76,6 +76,19 @@ export class TFloat64Array {
float64.set([1, 2, 3], 1);
float64.set([1, 2, 3], 1);
float64.copyWithin(3, 0, 3);
float64.copyWithin(3, 0, 3);
expect(float64.toString()).toEqual("0,1,2,0,1,2,0,0");
expect(float64.toString()).toEqual("0,1,2,0,1,2,0,0");
let initialLargeArray : Array<number> = new Array(10000, 0);
for (let i = 0; i < 5000; ++i) {
initialLargeArray[i] = i;
}
let initialLargeFloat64Array = new Float64Array(initialLargeArray);
let largeFloat64Array : Float64Array = new Float64Array(initialLargeFloat64Array);
largeFloat64Array.copyWithin(5000, 0);
for (let i = 0; i < 5000; ++i) {
if (largeFloat64Array[i + 5000] !== i) {
expect(true).toEqual(false);
}
}
// #END
// #END
}
}
...
@@ -266,6 +279,25 @@ export class TFloat64Array {
...
@@ -266,6 +279,25 @@ export class TFloat64Array {
res = float64.slice(0, 1);
res = float64.slice(0, 1);
expect(res.toString()).toEqual("1");
expect(res.toString()).toEqual("1");
const size = 1000;
const initialFloat64Array = new Float64Array(size);
for (let i = 0; i < size; ++i) {
initialFloat64Array[i] = Math.random();
}
let arr : Float64Array;
let new_arr : Float64Array;
arr = new Float64Array(initialFloat64Array);
new_arr = arr.slice(1, -1);
for (let i = 1; i < size - 1; ++i) {
if (arr[i] !== new_arr[i - 1]) {
expect(true).toEqual(false);
break
}
}
// #END
// #END
}
}
...
@@ -290,6 +322,19 @@ export class TFloat64Array {
...
@@ -290,6 +322,19 @@ export class TFloat64Array {
let sub = float64.subarray(0, 4);
let sub = float64.subarray(0, 4);
expect(sub.toString()).toEqual("1,2,3,0");
expect(sub.toString()).toEqual("1,2,3,0");
const size = 1000;
const initialFloat64Array = new Float64Array(size);
for (let i = 0; i < size; ++i) {
initialFloat64Array[i] = Math.random();
}
let arr = new Float64Array(initialFloat64Array);
let new_arr = arr.subarray(1, size - 1);
for (let i = 1; i < size - 1; ++i) {
if (arr[i] !== new_arr[i - 1]) {
expect(true).toEqual(false);
}
}
// #END
// #END
}
}
...
@@ -304,7 +349,7 @@ export class TFloat64Array {
...
@@ -304,7 +349,7 @@ export class TFloat64Array {
}
}
arrayBufferSlice() {
arrayBufferSlice() {
// #TEST ArrayBuffer.slice
// #TEST ArrayBuffer.slice
let buffer = new ArrayBuffer(16);
let buffer = new ArrayBuffer(16);
let float64 = new Float64Array(buffer);
let float64 = new Float64Array(buffer);
...
@@ -315,7 +360,7 @@ export class TFloat64Array {
...
@@ -315,7 +360,7 @@ export class TFloat64Array {
let sliced = new Float64Array(res);
let sliced = new Float64Array(res);
expect(sliced[0]).toEqual(42);
expect(sliced[0]).toEqual(42);
// #END
// #END
}
}
testSome() {
testSome() {
// #TEST Float64Array.some
// #TEST Float64Array.some
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录