Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
09fe36ef
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看板
提交
09fe36ef
编写于
5月 30, 2022
作者:
Z
zhangxingxia
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update fileio xts
Signed-off-by:
N
zhangxingxia
<
zhangxingxia1@huawei.com
>
上级
863f64dc
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
207 addition
and
0 deletion
+207
-0
storage/storagefileiojstest/src/main/js/default/test/module_fileio/class_stream/read.test.js
...n/js/default/test/module_fileio/class_stream/read.test.js
+101
-0
storage/storagefileiojstest/src/main/js/default/test/module_fileio/class_stream/write.test.js
.../js/default/test/module_fileio/class_stream/write.test.js
+106
-0
未找到文件。
storage/storagefileiojstest/src/main/js/default/test/module_fileio/class_stream/read.test.js
浏览文件 @
09fe36ef
...
...
@@ -239,4 +239,105 @@ describe('fileio_stream_read', function () {
}
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_READASYNC_0800
* @tc.name fileio_test_stream_read_async_008
* @tc.desc Test read() interface, When the length is greater than the buffer length.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileio_test_stream_read_async_008
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileio_test_stream_read_async_008
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
let
ss
=
fileio
.
createStreamSync
(
fpath
,
'
r+
'
);
expect
(
ss
!==
null
).
assertTrue
();
try
{
await
ss
.
read
(
new
ArrayBuffer
(
4096
),
{
length
:
4097
});
}
catch
(
err
)
{
console
.
info
(
'
fileio_test_stream_read_async_008 has failed for
'
+
err
);
expect
(
err
.
message
==
"
Failed GetReadArg
"
).
assertTrue
();
ss
.
closeSync
();
fileio
.
unlinkSync
(
fpath
);
done
();
}
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_READASYNC_0900
* @tc.name fileio_test_stream_read_async_009
* @tc.desc Test read() interface, When the length is negative.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileio_test_stream_read_async_009
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileio_test_stream_read_async_009
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
let
ss
=
fileio
.
createStreamSync
(
fpath
,
'
r+
'
);
expect
(
ss
!==
null
).
assertTrue
();
try
{
let
readout
=
await
ss
.
read
(
new
ArrayBuffer
(
4096
),
{
length
:
-
1
});
console
.
info
(
"
====>
"
+
readout
.
bytesRead
);
done
();
}
catch
(
err
)
{
console
.
info
(
'
fileio_test_stream_read_async_009 has failed for
'
+
err
);
expect
(
err
.
message
==
"
Failed GetReadArg
"
).
assertTrue
();
ss
.
closeSync
();
fileio
.
unlinkSync
(
fpath
);
done
();
}
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_READASYNC_1000
* @tc.name fileio_test_stream_read_async_010
* @tc.desc Test read() interface, When there are no parameters.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileio_test_stream_read_async_010
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileio_test_stream_read_async_010
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
let
ss
=
fileio
.
createStreamSync
(
fpath
,
'
r+
'
);
expect
(
ss
!==
null
).
assertTrue
();
try
{
await
ss
.
read
();
}
catch
(
err
)
{
console
.
info
(
'
fileio_test_stream_read_async_010 has failed for
'
+
err
);
expect
(
err
.
message
==
"
Number of arguments unmatched
"
).
assertTrue
();
ss
.
closeSync
();
fileio
.
unlinkSync
(
fpath
);
done
();
}
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_READASYNC_1100
* @tc.name fileio_test_stream_read_async_011
* @tc.desc Test read() interface, When length>FILE_CONTENT.length.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileio_test_stream_read_async_011
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileio_test_stream_read_async_011
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
let
ss
=
fileio
.
createStreamSync
(
fpath
,
'
r+
'
);
expect
(
ss
!==
null
).
assertTrue
();
try
{
let
readout
=
await
ss
.
read
(
new
ArrayBuffer
(
4096
),
{
length
:
FILE_CONTENT
.
length
+
1
});
expect
(
readout
.
bytesRead
==
FILE_CONTENT
.
length
).
assertTrue
();
ss
.
closeSync
();
fileio
.
unlinkSync
(
fpath
);
done
();
}
catch
(
err
)
{
console
.
info
(
'
fileio_test_stream_read_async_011 has failed for
'
+
err
);
}
});
});
storage/storagefileiojstest/src/main/js/default/test/module_fileio/class_stream/write.test.js
浏览文件 @
09fe36ef
...
...
@@ -326,4 +326,110 @@ describe('fileio_stream_write', function () {
done
();
}
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_WRITEASYNC_1100
* @tc.name fileio_test_stream_write_async_011
* @tc.desc Test write() interface,When the length is negative.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileio_test_stream_write_async_011
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileio_test_stream_write_async_011
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
let
ss
=
fileio
.
createStreamSync
(
fpath
,
'
r+
'
);
expect
(
ss
!==
null
).
assertTrue
();
try
{
let
content
=
"
hello, world
"
;
let
number
=
await
ss
.
write
(
content
,
{
length
:
-
1
});
console
.
info
(
"
====>
"
+
number
);
done
();
}
catch
(
err
)
{
console
.
info
(
'
fileio_test_stream_write_async_011 has failed for
'
+
err
);
expect
(
err
.
message
==
"
Invalid option.length, positive integer is desired
"
).
assertTrue
();
fileio
.
unlinkSync
(
fpath
);
ss
.
closeSync
();
done
();
}
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_WRITEASYNC_1200
* @tc.name fileio_test_stream_write_async_012
* @tc.desc Test write() interface,When the buffer parameter type is wrong.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileio_test_stream_write_async_012
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileio_test_stream_write_async_012
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
let
ss
=
fileio
.
createStreamSync
(
fpath
,
'
r+
'
);
expect
(
ss
!==
null
).
assertTrue
();
try
{
await
ss
.
write
(
12
,
{
length
:
-
1
});
}
catch
(
err
)
{
console
.
info
(
'
fileio_test_stream_write_async_012 has failed for
'
+
err
);
expect
(
err
.
message
==
"
Illegal write buffer or encoding
"
).
assertTrue
();
fileio
.
unlinkSync
(
fpath
);
ss
.
closeSync
();
done
();
}
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_WRITEASYNC_1300
* @tc.name fileio_test_stream_write_async_013
* @tc.desc Test write() interface,When the length is greater than the buffer length.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileio_test_stream_write_async_013
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileio_test_stream_write_async_013
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
let
ss
=
fileio
.
createStreamSync
(
fpath
,
'
r+
'
);
expect
(
ss
!==
null
).
assertTrue
();
try
{
await
ss
.
write
(
new
ArrayBuffer
(
4096
),
{
length
:
4097
});
}
catch
(
err
)
{
console
.
info
(
'
fileio_test_stream_write_async_013 has failed for
'
+
err
);
expect
(
err
.
message
==
"
Invalid option.length, buffer limit exceeded
"
).
assertTrue
();
fileio
.
unlinkSync
(
fpath
);
ss
.
closeSync
();
done
();
}
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_WRITEASYNC_1400
* @tc.name fileio_test_stream_write_async_014
* @tc.desc Test write() interface,When the length>content.length .
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileio_test_stream_write_async_014
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileio_test_stream_write_async_014
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
let
ss
=
fileio
.
createStreamSync
(
fpath
,
'
r+
'
);
expect
(
ss
!==
null
).
assertTrue
();
try
{
let
content
=
"
hello,world
"
;
await
ss
.
write
(
content
,{
length
:
content
.
length
+
1
});
}
catch
(
err
)
{
console
.
info
(
'
fileio_test_stream_write_async_014 has failed for
'
+
err
);
expect
(
err
.
message
==
"
Invalid option.length, buffer limit exceeded
"
).
assertTrue
();
fileio
.
unlinkSync
(
fpath
);
ss
.
closeSync
();
done
();
}
});
});
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录