Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
6090e20d
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看板
提交
6090e20d
编写于
9月 01, 2022
作者:
R
raoxian
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
新增randomaccessfile测试用例
Signed-off-by:
N
raoxian
<
raoxian@huawei.com
>
上级
a97bffad
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
44 addition
and
21 deletion
+44
-21
storage/storagefileiojstest/src/main/js/test/module_fileio/class_randomAccessFile/close.test.js
...s/test/module_fileio/class_randomAccessFile/close.test.js
+2
-1
storage/storagefileiojstest/src/main/js/test/module_fileio/class_randomAccessFile/read.test.js
...js/test/module_fileio/class_randomAccessFile/read.test.js
+18
-11
storage/storagefileiojstest/src/main/js/test/module_fileio/class_randomAccessFile/setFilePointer.test.js
...dule_fileio/class_randomAccessFile/setFilePointer.test.js
+3
-1
storage/storagefileiojstest/src/main/js/test/module_fileio/class_randomAccessFile/write.test.js
...s/test/module_fileio/class_randomAccessFile/write.test.js
+14
-7
storage/storagefileiojstest/src/main/js/test/module_fileio/members/createRandomAccessFile.test.js
...test/module_fileio/members/createRandomAccessFile.test.js
+7
-1
未找到文件。
storage/storagefileiojstest/src/main/js/test/module_fileio/class_randomAccessFile/close.test.js
浏览文件 @
6090e20d
/*
* Copyright (C) 202
1
Huawei Device Co., Ltd.
* Copyright (C) 202
2
Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
...
...
@@ -58,6 +58,7 @@ describe('fileio_randomAccessFile_close', function () {
try
{
randomaccessfile
.
closeSync
(
1
);
expect
(
false
).
assertTrue
();
}
catch
(
err
)
{
console
.
info
(
'
fileio_randomaccessfile_close_sync_001 has failed for
'
+
err
);
expect
(
err
.
message
==
"
Number of arguments unmatched
"
).
assertTrue
();
...
...
storage/storagefileiojstest/src/main/js/test/module_fileio/class_randomAccessFile/read.test.js
浏览文件 @
6090e20d
/*
* Copyright (C) 202
1
Huawei Device Co., Ltd.
* Copyright (C) 202
2
Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
...
...
@@ -64,7 +64,7 @@ describe('fileio_randomAccessFile_read', function () {
try
{
let
randomaccessfile
=
fileio
.
createRandomAccessFileSync
(
fpath
,
0
,
0o102
);
let
length
=
4096
;
let
length
=
20
;
let
num
=
randomaccessfile
.
writeSync
(
new
ArrayBuffer
(
length
));
expect
(
num
==
length
).
assertTrue
();
randomaccessfile
.
setFilePointerSync
(
0
);
...
...
@@ -92,7 +92,7 @@ describe('fileio_randomAccessFile_read', function () {
try
{
let
randomaccessfile
=
fileio
.
createRandomAccessFileSync
(
fpath
,
0
,
0o102
);
let
length
=
4096
;
let
length
=
20
;
let
num
=
randomaccessfile
.
writeSync
(
new
ArrayBuffer
(
length
));
expect
(
num
==
length
).
assertTrue
();
randomaccessfile
.
setFilePointerSync
(
0
);
...
...
@@ -120,7 +120,7 @@ describe('fileio_randomAccessFile_read', function () {
try
{
let
randomaccessfile
=
fileio
.
createRandomAccessFileSync
(
fpath
,
0
,
0o102
);
let
length
=
4096
;
let
length
=
20
;
let
num
=
randomaccessfile
.
writeSync
(
new
ArrayBuffer
(
length
));
expect
(
num
==
length
).
assertTrue
();
randomaccessfile
.
setFilePointerSync
(
0
);
...
...
@@ -177,7 +177,7 @@ describe('fileio_randomAccessFile_read', function () {
try
{
let
randomaccessfile
=
fileio
.
createRandomAccessFileSync
(
fpath
,
0
,
0o102
);
let
length
=
4096
;
let
length
=
20
;
let
number
=
randomaccessfile
.
readSync
(
new
ArrayBuffer
(
length
),
{
offset
:
1
,
position
:
6
});
expect
(
number
==
FILE_CONTENT
.
length
-
6
).
assertTrue
();
randomaccessfile
.
closeSync
();
...
...
@@ -204,6 +204,7 @@ describe('fileio_randomAccessFile_read', function () {
try
{
randomaccessfile
.
readSync
(
new
ArrayBuffer
(
4096
),
{
offset
:
-
1
});
expect
(
false
).
assertTrue
();
}
catch
(
err
)
{
console
.
info
(
'
fileio_randomaccessfile_read_sync_006 has failed for
'
+
err
);
expect
(
err
.
message
==
"
Invalid buffer/options
"
).
assertTrue
();
...
...
@@ -227,6 +228,7 @@ describe('fileio_randomAccessFile_read', function () {
try
{
randomaccessfile
.
readSync
(
new
ArrayBuffer
(
4096
),
{
offset
:
1
,
length
:
4096
});
expect
(
false
).
assertTrue
();
}
catch
(
err
)
{
console
.
info
(
'
fileio_randomaccessfile_read_sync_007 has failed for
'
+
err
);
expect
(
err
.
message
==
"
Invalid buffer/options
"
).
assertTrue
();
...
...
@@ -251,6 +253,7 @@ describe('fileio_randomAccessFile_read', function () {
try
{
let
length
=
4096
;
randomaccessfile
.
readSync
(
new
ArrayBuffer
(
length
),
{
offset
:
length
+
1
});
expect
(
false
).
assertTrue
();
}
catch
(
err
)
{
console
.
info
(
'
fileio_randomaccessfile_read_sync_008 has failed for
'
+
err
);
expect
(
err
.
message
==
"
Invalid buffer/options
"
).
assertTrue
();
...
...
@@ -275,6 +278,7 @@ describe('fileio_randomAccessFile_read', function () {
try
{
let
length
=
4096
;
randomaccessfile
.
readSync
(
new
ArrayBuffer
(
length
),
{
length
:
length
+
1
});
expect
(
false
).
assertTrue
();
}
catch
(
err
)
{
console
.
info
(
'
fileio_randomaccessfile_read_sync_009 has failed for
'
+
err
);
expect
(
err
.
message
==
"
Invalid buffer/options
"
).
assertTrue
();
...
...
@@ -326,6 +330,7 @@ describe('fileio_randomAccessFile_read', function () {
try
{
randomaccessfile
.
readSync
();
expect
(
false
).
assertTrue
();
}
catch
(
err
)
{
console
.
info
(
'
fileio_randomaccessfile_read_sync_011 has failed for
'
+
err
);
expect
(
err
.
message
==
"
Number of arguments unmatched
"
).
assertTrue
();
...
...
@@ -349,6 +354,7 @@ describe('fileio_randomAccessFile_read', function () {
try
{
randomaccessfile
.
readSync
(
new
ArrayBuffer
(
4096
),
{
position
:
-
1
});
expect
(
false
).
assertTrue
();
}
catch
(
err
)
{
console
.
info
(
'
fileio_randomaccessfile_read_sync_012 has failed for
'
+
err
);
expect
(
err
.
message
==
"
Invalid buffer/options
"
).
assertTrue
();
...
...
@@ -358,8 +364,8 @@ describe('fileio_randomAccessFile_read', function () {
});
/**
* @tc.number SUB_STORAGE_FILEIO_RANDOMACCESSFILE_READ_SYNC_1
2
00
* @tc.name fileio_randomaccessfile_read_sync_01
2
* @tc.number SUB_STORAGE_FILEIO_RANDOMACCESSFILE_READ_SYNC_1
3
00
* @tc.name fileio_randomaccessfile_read_sync_01
3
* @tc.desc Test readSync() interface. When the parameter type is wrong.
* @tc.size MEDIUM
* @tc.type Function
...
...
@@ -372,6 +378,7 @@ describe('fileio_randomAccessFile_read', function () {
try
{
randomaccessfile
.
readSync
(
''
);
expect
(
false
).
assertTrue
();
}
catch
(
err
)
{
console
.
info
(
'
fileio_randomaccessfile_read_sync_013 has failed for
'
+
err
);
expect
(
err
.
message
==
"
Invalid buffer/options
"
).
assertTrue
();
...
...
@@ -424,7 +431,7 @@ describe('fileio_randomAccessFile_read', function () {
try
{
fileio
.
createRandomAccessFile
(
fpath
,
0
,
0o102
,
async
function
(
err
,
randomaccessfile
)
{
let
length
=
4096
;
let
length
=
20
;
let
num
=
await
randomaccessfile
.
write
(
new
ArrayBuffer
(
length
));
expect
(
num
==
length
).
assertTrue
();
randomaccessfile
.
setFilePointerSync
(
0
);
...
...
@@ -455,7 +462,7 @@ describe('fileio_randomAccessFile_read', function () {
try
{
let
fd
=
fileio
.
openSync
(
fpath
,
0o102
,
0o666
);
let
randomaccessfile
=
await
fileio
.
createRandomAccessFile
(
fd
,
0
);
let
length
=
4096
;
let
length
=
20
;
let
num
=
await
randomaccessfile
.
write
(
new
ArrayBuffer
(
length
));
expect
(
num
==
length
).
assertTrue
();
randomaccessfile
.
setFilePointerSync
(
0
);
...
...
@@ -485,7 +492,7 @@ describe('fileio_randomAccessFile_read', function () {
try
{
let
randomaccessfile
=
await
fileio
.
createRandomAccessFile
(
fpath
,
0
,
0o102
);
let
length
=
4096
;
let
length
=
20
;
let
num
=
await
randomaccessfile
.
write
(
new
ArrayBuffer
(
length
));
expect
(
num
==
length
).
assertTrue
();
randomaccessfile
.
setFilePointerSync
(
0
);
...
...
@@ -547,7 +554,7 @@ describe('fileio_randomAccessFile_read', function () {
try
{
let
randomaccessfile
=
await
fileio
.
createRandomAccessFile
(
fpath
,
0
,
0o102
);
let
length
=
4096
;
let
length
=
20
;
let
readOut
=
await
randomaccessfile
.
read
(
new
ArrayBuffer
(
length
),
{
offset
:
1
,
position
:
6
});
expect
(
readOut
.
bytesRead
==
FILE_CONTENT
.
length
-
6
).
assertTrue
();
expect
(
readOut
.
offset
==
1
).
assertTrue
();
...
...
storage/storagefileiojstest/src/main/js/test/module_fileio/class_randomAccessFile/setFilePointer.test.js
浏览文件 @
6090e20d
/*
* Copyright (C) 202
1
Huawei Device Co., Ltd.
* Copyright (C) 202
2
Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
...
...
@@ -60,6 +60,7 @@ describe('fileio_randomAccessFile_setFilePointer', function () {
try
{
randomaccessfile
.
setFilePointerSync
(
'
5
'
);
expect
(
false
).
assertTrue
();
}
catch
(
err
)
{
console
.
info
(
'
fileio_randomaccessfile_set_file_pointer_sync_001 has failed for
'
+
err
);
expect
(
err
.
message
==
"
Invalid fpointer
"
).
assertTrue
();
...
...
@@ -83,6 +84,7 @@ describe('fileio_randomAccessFile_setFilePointer', function () {
try
{
randomaccessfile
.
setFilePointerSync
();
expect
(
false
).
assertTrue
();
}
catch
(
err
)
{
console
.
info
(
'
fileio_randomaccessfile_set_file_pointer_sync_002 has failed for
'
+
err
);
expect
(
err
.
message
==
"
Number of arguments unmatched
"
).
assertTrue
();
...
...
storage/storagefileiojstest/src/main/js/test/module_fileio/class_randomAccessFile/write.test.js
浏览文件 @
6090e20d
/*
* Copyright (C) 202
1
Huawei Device Co., Ltd.
* Copyright (C) 202
2
Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
...
...
@@ -60,7 +60,7 @@ describe('fileio_randomAccessFile_write', function () {
try
{
let
randomaccessfile
=
fileio
.
createRandomAccessFileSync
(
fpath
,
0
,
0o102
);
let
length
=
4096
;
let
length
=
20
;
let
num
=
randomaccessfile
.
writeSync
(
new
ArrayBuffer
(
length
),
{
offset
:
1
});
expect
(
num
==
length
-
1
).
assertTrue
();
randomaccessfile
.
closeSync
();
...
...
@@ -86,7 +86,7 @@ describe('fileio_randomAccessFile_write', function () {
try
{
let
fd
=
fileio
.
openSync
(
fpath
,
0o102
,
0o666
);
let
randomaccessfile
=
fileio
.
createRandomAccessFileSync
(
fd
,
0
);
let
length
=
4096
;
let
length
=
20
;
let
num
=
randomaccessfile
.
writeSync
(
new
ArrayBuffer
(
length
),
{
position
:
1
});
expect
(
num
==
length
).
assertTrue
();
randomaccessfile
.
closeSync
();
...
...
@@ -111,7 +111,7 @@ describe('fileio_randomAccessFile_write', function () {
try
{
let
randomaccessfile
=
fileio
.
createRandomAccessFileSync
(
fpath
,
0
,
0o102
);
let
length
=
4096
;
let
length
=
20
;
let
num
=
randomaccessfile
.
writeSync
(
new
ArrayBuffer
(
length
),
{
offset
:
1
,
length
:
10
});
expect
(
num
==
10
).
assertTrue
();
randomaccessfile
.
closeSync
();
...
...
@@ -196,6 +196,7 @@ describe('fileio_randomAccessFile_write', function () {
try
{
randomaccessfile
.
writeSync
(
new
ArrayBuffer
(
4096
),
{
offset
:
5
,
length
:
4095
});
expect
(
false
).
assertTrue
();
}
catch
(
err
)
{
console
.
info
(
'
fileio_randomaccessfile_write_sync_006 has failed for
'
+
err
);
expect
(
err
.
message
==
"
Invalid buffer/options
"
).
assertTrue
();
...
...
@@ -220,6 +221,7 @@ describe('fileio_randomAccessFile_write', function () {
try
{
let
length
=
4096
;
randomaccessfile
.
writeSync
(
new
ArrayBuffer
(
length
),
{
offset
:
length
+
1
});
expect
(
false
).
assertTrue
();
}
catch
(
err
)
{
console
.
info
(
'
fileio_randomaccessfile_write_sync_007 has failed for
'
+
err
);
expect
(
err
.
message
==
"
Invalid buffer/options
"
).
assertTrue
();
...
...
@@ -243,6 +245,7 @@ describe('fileio_randomAccessFile_write', function () {
try
{
randomaccessfile
.
writeSync
();
expect
(
false
).
assertTrue
();
}
catch
(
err
)
{
console
.
info
(
'
fileio_randomaccessfile_write_sync_008 has failed for
'
+
err
);
expect
(
err
.
message
==
"
Number of arguments unmatched
"
).
assertTrue
();
...
...
@@ -267,6 +270,7 @@ describe('fileio_randomAccessFile_write', function () {
try
{
randomaccessfile
.
writeSync
(
new
ArrayBuffer
(
4096
),
{
offset
:
-
1
});
expect
(
false
).
assertTrue
();
}
catch
(
err
)
{
console
.
info
(
'
fileio_randomaccessfile_write_sync_009 has failed for
'
+
err
);
expect
(
err
.
message
==
"
Invalid buffer/options
"
).
assertTrue
();
...
...
@@ -315,6 +319,7 @@ describe('fileio_randomAccessFile_write', function () {
try
{
randomaccessfile
.
writeSync
(
10
,
{
length
:
-
1
});
expect
(
false
).
assertTrue
();
}
catch
(
err
)
{
console
.
info
(
'
fileio_randomaccessfile_write_sync_011 has failed for
'
+
err
);
expect
(
err
.
message
==
"
Invalid buffer/options
"
).
assertTrue
();
...
...
@@ -339,6 +344,7 @@ describe('fileio_randomAccessFile_write', function () {
try
{
let
length
=
4096
;
randomaccessfile
.
writeSync
(
new
ArrayBuffer
(
length
),
{
length
:
length
+
1
});
expect
(
false
).
assertTrue
();
}
catch
(
err
)
{
console
.
info
(
'
fileio_randomaccessfile_write_sync_012 has failed for
'
+
err
);
expect
(
err
.
message
==
"
Invalid buffer/options
"
).
assertTrue
();
...
...
@@ -362,6 +368,7 @@ describe('fileio_randomAccessFile_write', function () {
try
{
randomaccessfile
.
writeSync
(
new
ArrayBuffer
(
4096
),
{
position
:
-
1
});
expect
(
false
).
assertTrue
();
}
catch
(
err
)
{
console
.
info
(
'
fileio_randomaccessfile_write_sync_013 has failed for
'
+
err
);
expect
(
err
.
message
==
"
Invalid buffer/options
"
).
assertTrue
();
...
...
@@ -412,7 +419,7 @@ describe('fileio_randomAccessFile_write', function () {
try
{
let
fd
=
fileio
.
openSync
(
fpath
,
0o102
,
0o666
);
let
randomaccessfile
=
await
fileio
.
createRandomAccessFile
(
fd
,
0
);
let
length
=
4096
;
let
length
=
20
;
randomaccessfile
.
write
(
new
ArrayBuffer
(
length
),
{
offset
:
1
},
function
(
err
,
bytesWritten
)
{
expect
(
bytesWritten
==
length
-
1
).
assertTrue
();
randomaccessfile
.
closeSync
();
...
...
@@ -439,7 +446,7 @@ describe('fileio_randomAccessFile_write', function () {
try
{
let
randomaccessfile
=
await
fileio
.
createRandomAccessFile
(
fpath
,
0
,
0o102
);
let
length
=
4096
;
let
length
=
20
;
let
num
=
await
randomaccessfile
.
write
(
new
ArrayBuffer
(
length
),
{
position
:
1
});
expect
(
num
==
length
).
assertTrue
();
randomaccessfile
.
closeSync
();
...
...
@@ -465,7 +472,7 @@ describe('fileio_randomAccessFile_write', function () {
try
{
let
randomaccessfile
=
await
fileio
.
createRandomAccessFile
(
fpath
,
0
,
0o102
);
let
length
=
4096
;
let
length
=
20
;
let
num
=
await
randomaccessfile
.
write
(
new
ArrayBuffer
(
length
),
{
offset
:
1
,
length
:
10
});
expect
(
num
==
10
).
assertTrue
();
randomaccessfile
.
closeSync
();
...
...
storage/storagefileiojstest/src/main/js/test/module_fileio/members/createRandomAccessFile.test.js
浏览文件 @
6090e20d
/*
* Copyright (C) 202
1
Huawei Device Co., Ltd.
* Copyright (C) 202
2
Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
...
...
@@ -136,6 +136,7 @@ describe('fileio_create_randomAccessFile', function () {
try
{
fileio
.
createRandomAccessFileSync
(
fpath
,
0
,
0o2
);
expect
(
false
).
assertTrue
();
}
catch
(
err
)
{
console
.
info
(
'
fileio_create_randomaccessfile_sync_004 has failed for
'
+
err
);
expect
(
err
.
message
==
"
No such file or directory
"
).
assertTrue
();
...
...
@@ -154,6 +155,7 @@ describe('fileio_create_randomAccessFile', function () {
it
(
'
fileio_create_randomaccessfile_sync_005
'
,
0
,
async
function
()
{
try
{
fileio
.
createRandomAccessFileSync
(
-
1
,
0
);
expect
(
false
).
assertTrue
();
}
catch
(
err
)
{
console
.
info
(
'
fileio_create_randomaccessfile_sync_005 has failed for
'
+
err
);
expect
(
err
.
message
==
"
Invalid fd
"
).
assertTrue
();
...
...
@@ -175,6 +177,7 @@ describe('fileio_create_randomAccessFile', function () {
try
{
fileio
.
createRandomAccessFileSync
(
fd
,
'
1
'
);
expect
(
false
).
assertTrue
();
}
catch
(
err
)
{
console
.
info
(
'
fileio_create_randomaccessfile_sync_006 has failed for
'
+
err
);
expect
(
err
.
message
==
"
Invalid fp
"
).
assertTrue
();
...
...
@@ -198,6 +201,7 @@ describe('fileio_create_randomAccessFile', function () {
try
{
fileio
.
createRandomAccessFileSync
(
fd
);
expect
(
false
).
assertTrue
();
}
catch
(
err
)
{
console
.
info
(
'
fileio_create_randomaccessfile_sync_007 has failed for
'
+
err
);
expect
(
err
.
message
==
"
Number of arguments unmatched
"
).
assertTrue
();
...
...
@@ -246,6 +250,7 @@ describe('fileio_create_randomAccessFile', function () {
try
{
fileio
.
createRandomAccessFileSync
(
fpath
,
0
,
0o302
);
expect
(
false
).
assertTrue
();
}
catch
(
err
)
{
console
.
info
(
'
fileio_create_randomaccessfile_sync_009 has failed for
'
+
err
);
expect
(
err
.
message
==
"
File exists
"
).
assertTrue
();
...
...
@@ -324,6 +329,7 @@ describe('fileio_create_randomAccessFile', function () {
try
{
fileio
.
createRandomAccessFileSync
(
fpath
,
0
,
0o200002
);
expect
(
false
).
assertTrue
();
}
catch
(
err
)
{
console
.
info
(
'
fileio_create_randomaccessfile_sync_012 has failed for
'
+
err
);
expect
(
err
.
message
==
"
Not a directory
"
).
assertTrue
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录