提交 6761a358 编写于 作者: R raoxian

新增randomaccessfile测试用例

Signed-off-by: Nraoxian <raoxian@huawei.com>
上级 b510db8c
...@@ -23,6 +23,10 @@ import fileioDirListfile from './module_fileio/class_dir/listfile.test.js' ...@@ -23,6 +23,10 @@ import fileioDirListfile from './module_fileio/class_dir/listfile.test.js'
import fileioDirRead from './module_fileio/class_dir/read.test.js' import fileioDirRead from './module_fileio/class_dir/read.test.js'
import fileioDirent from './module_fileio/class_dirent/all.test.js' import fileioDirent from './module_fileio/class_dirent/all.test.js'
import fileioStream from './module_fileio/class_stream/all.test.js' import fileioStream from './module_fileio/class_stream/all.test.js'
import fileioRandomAccessFileClose from './module_fileio/class_randomAccessFile/close.test.js'
import fileioRandomAccessFileRead from './module_fileio/class_randomAccessFile/read.test.js'
import fileioRandomAccessFileSetFilePointer from './module_fileio/class_randomAccessFile/setFilePointer.test.js'
import fileioRandomAccessFileWrite from './module_fileio/class_randomAccessFile/write.test.js'
import fileioStreamClose from './module_fileio/class_stream/close.test.js' import fileioStreamClose from './module_fileio/class_stream/close.test.js'
import fileioStreamFlush from './module_fileio/class_stream/flush.test.js' import fileioStreamFlush from './module_fileio/class_stream/flush.test.js'
import fileioStreamRead from './module_fileio/class_stream/read.test.js' import fileioStreamRead from './module_fileio/class_stream/read.test.js'
...@@ -33,6 +37,7 @@ import fileioChmod from './module_fileio/members/chmod.test.js' ...@@ -33,6 +37,7 @@ import fileioChmod from './module_fileio/members/chmod.test.js'
import fileioChown from './module_fileio/members/chown.test.js' import fileioChown from './module_fileio/members/chown.test.js'
import fileioClose from './module_fileio/members/close.test.js' import fileioClose from './module_fileio/members/close.test.js'
import fileioCopyfile from './module_fileio/members/copyFile.test.js' import fileioCopyfile from './module_fileio/members/copyFile.test.js'
import fileioCreateRandomAccessFile from './module_fileio/members/createRandomAccessFile.test.js'
import fileioCreateStream from './module_fileio/members/createStream.test.js' import fileioCreateStream from './module_fileio/members/createStream.test.js'
import fileioFchmod from './module_fileio/members/fchmod.test.js' import fileioFchmod from './module_fileio/members/fchmod.test.js'
import fileioFchown from './module_fileio/members/fchown.test.js' import fileioFchown from './module_fileio/members/fchown.test.js'
...@@ -71,6 +76,10 @@ export default function testsuite() { ...@@ -71,6 +76,10 @@ export default function testsuite() {
fileioDirRead() fileioDirRead()
fileioDirent() fileioDirent()
fileioStream() fileioStream()
fileioRandomAccessFileClose()
fileioRandomAccessFileRead()
fileioRandomAccessFileSetFilePointer()
fileioRandomAccessFileWrite()
fileioStreamClose() fileioStreamClose()
fileioStreamFlush() fileioStreamFlush()
fileioStreamRead() fileioStreamRead()
...@@ -81,6 +90,7 @@ export default function testsuite() { ...@@ -81,6 +90,7 @@ export default function testsuite() {
fileioChown() fileioChown()
fileioClose() fileioClose()
fileioCopyfile() fileioCopyfile()
fileioCreateRandomAccessFile()
fileioCreateStream() fileioCreateStream()
fileioFchmod() fileioFchmod()
fileioFchown() fileioFchown()
......
/*
* Copyright (C) 2021 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {
fileio, nextFileName,
describe, it, expect
} from '../../Common';
export default function fileioRandomAccessFileClose() {
describe('fileio_randomAccessFile_close', function () {
/**
* @tc.number SUB_STORAGE_FILEIO_RANDOMACCESSFILE_CLOSE_SYNC_0000
* @tc.name fileio_randomaccessfile_close_sync_000
* @tc.desc Test closeSync() interface. Close the RandomAccessFile object.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_randomaccessfile_close_sync_000', 0, async function () {
let fpath = await nextFileName('fileio_randomaccessfile_close_sync_000');
try {
let randomaccessfile = fileio.createRandomAccessFileSync(fpath, 0, 0o102);
randomaccessfile.closeSync();
fileio.unlinkSync(fpath);
} catch(err) {
console.info('fileio_randomaccessfile_close_sync_000 has failed for ' + err);
expect(null).assertFail();
}
});
/**
* @tc.number SUB_STORAGE_FILEIO_RANDOMACCESSFILE_CLOSE_SYNC_0100
* @tc.name fileio_randomaccessfile_close_sync_001
* @tc.desc Test closeSync() interface. Parameter mismatch.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_randomaccessfile_close_sync_001', 0, async function () {
let fpath = await nextFileName('fileio_randomaccessfile_close_sync_001');
let randomaccessfile = fileio.createRandomAccessFileSync(fpath, 0, 0o102);
try {
randomaccessfile.closeSync(1);
} catch(err) {
console.info('fileio_randomaccessfile_close_sync_001 has failed for ' + err);
expect(err.message == "Number of arguments unmatched").assertTrue();
randomaccessfile.closeSync();
fileio.unlinkSync(fpath);
}
});
})
}
\ No newline at end of file
/*
* Copyright (C) 2021 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {
fileio, nextFileName, describe, it, expect
} from '../../Common';
export default function fileioRandomAccessFileSetFilePointer() {
describe('fileio_randomAccessFile_setFilePointer', function () {
/**
* @tc.number SUB_STORAGE_FILEIO_RANDOMACCESSFILE_SET_FILE_POINTER_SYNC_0000
* @tc.name fileio_randomaccessfile_set_file_pointer_sync_000
* @tc.desc Test setFilePointerSync() interface. Set file offset pointer position.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_randomaccessfile_set_file_pointer_sync_000', 0, async function () {
let fpath = await nextFileName('fileio_randomaccessfile_set_file_pointer_sync_000');
try {
let randomaccessfile = fileio.createRandomAccessFileSync(fpath, 0, 0o102);
expect(randomaccessfile.fpointer == 0).assertTrue();
randomaccessfile.setFilePointerSync(5);
expect(randomaccessfile.fpointer == 5).assertTrue();
randomaccessfile.closeSync();
fileio.unlinkSync(fpath);
} catch(err) {
console.info('fileio_randomaccessfile_set_file_pointer_sync_000 has failed for ' + err);
expect(null).assertFail();
}
});
/**
* @tc.number SUB_STORAGE_FILEIO_RANDOMACCESSFILE_SET_FILE_POINTER_SYNC_0100
* @tc.name fileio_randomaccessfile_set_file_pointer_sync_001
* @tc.desc Test setFilePointerSync() interface. Invalid fpointer.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_randomaccessfile_set_file_pointer_sync_001', 0, async function () {
let fpath = await nextFileName('fileio_randomaccessfile_set_file_pointer_sync_001');
let randomaccessfile = fileio.createRandomAccessFileSync(fpath, 0, 0o102);
try {
randomaccessfile.setFilePointerSync('5');
} catch(err) {
console.info('fileio_randomaccessfile_set_file_pointer_sync_001 has failed for ' + err);
expect(err.message == "Invalid fpointer").assertTrue();
randomaccessfile.closeSync();
fileio.unlinkSync(fpath);
}
});
/**
* @tc.number SUB_STORAGE_FILEIO_RANDOMACCESSFILE_SET_FILE_POINTER_SYNC_0200
* @tc.name fileio_randomaccessfile_set_file_pointer_sync_002
* @tc.desc Test setFilePointerSync() interface. Missing Parameter.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_randomaccessfile_set_file_pointer_sync_002', 0, async function () {
let fpath = await nextFileName('fileio_randomaccessfile_set_file_pointer_sync_002');
let randomaccessfile = fileio.createRandomAccessFileSync(fpath, 0, 0o102);
try {
randomaccessfile.setFilePointerSync();
} catch(err) {
console.info('fileio_randomaccessfile_set_file_pointer_sync_002 has failed for ' + err);
expect(err.message == "Number of arguments unmatched").assertTrue();
randomaccessfile.closeSync();
fileio.unlinkSync(fpath);
}
});
})
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册