未验证 提交 9ffb8c36 编写于 作者: O openharmony_ci 提交者: Gitee

!3335 update fileio xts

Merge pull request !3335 from zhangxingxia/master
......@@ -2289,7 +2289,7 @@ describe('fileIOTest', function () {
fileio.copyFileSync(-1, -1);
} catch (err) {
console.info('fileio_test_copy_file_sync_007 has failed for ' + err);
expect(err.message == "Invalid argument").assertTrue();
expect(err.message == "Invalid argument" || err.message == "Bad file descriptor").assertTrue();
}
});
......
......@@ -23,8 +23,8 @@ describe('fileio_stream', function () {
/**
* @tc.number SUB_DF_FILEIO_STREAM_CREATESTREAMSYNC_0000
* @tc.name fileio_test_stream_create_stream_sync_000
* @tc.desc Test createStreamSync() interface.
* @tc.size MEDIUM(中型)
* @tc.desc Test createStreamSync() interface, Open read-write file.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
......@@ -36,19 +36,19 @@ describe('fileio_stream', function () {
try {
let ss = fileio.createStreamSync(fpath, 'r+');
expect(ss !== null).assertTrue();
expect(ss.closeSync() == null).assertTrue();
expect(fileio.unlinkSync(fpath) == null).assertTrue();
} catch (e) {
console.log('fileio_test_stream_create_stream_sync_000 has failed for ' + e);
ss.closeSync();
fileio.unlinkSync(fpath);
} catch (err) {
console.info('fileio_test_stream_create_stream_sync_000 has failed for ' + err);
expect(null).assertFail();
}
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_CREATESTREAMSYNC_0010
* @tc.number SUB_DF_FILEIO_STREAM_CREATESTREAMSYNC_0100
* @tc.name fileio_test_stream_create_stream_sync_001
* @tc.desc Test createStreamSync() interface.
* @tc.size MEDIUM(中型)
* @tc.desc Test createStreamSync() interface, When file does not exist.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
......@@ -58,17 +58,17 @@ describe('fileio_stream', function () {
try {
fileio.createStreamSync(fpath, 'r+');
expect(null).assertFail();
} catch (e) {
console.log('fileio_test_stream_create_stream_sync_001 has failed for ' + e);
} catch (err) {
console.info('fileio_test_stream_create_stream_sync_001 has failed for ' + err);
expect(err.message == "No such file or directory").assertTrue();
}
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_CREATESTREAMSYNC_0020
* @tc.number SUB_DF_FILEIO_STREAM_CREATESTREAMSYNC_0200
* @tc.name fileio_test_stream_create_stream_sync_002
* @tc.desc Test createStreamSync() interface.
* @tc.size MEDIUM(中型)
* @tc.desc Test createStreamSync() interface, When mode is invalid.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
......@@ -79,17 +79,18 @@ describe('fileio_stream', function () {
try {
fileio.createStreamSync(fpath, 'ohos');
expect(null).assertFail();
} catch (e) {
expect(fileio.unlinkSync(fpath) == null).assertTrue();
} catch (err) {
console.info('fileio_test_stream_create_stream_sync_002 has failed for ' + err);
expect(err.message == "Invalid argument").assertTrue();
fileio.unlinkSync(fpath);
}
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_READSYNC_0000
* @tc.name fileio_test_stream_read_sync_000
* @tc.desc Test readSync() interface.
* @tc.size MEDIUM(中型)
* @tc.desc Test readSync() interface, read data from stream file.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
......@@ -103,48 +104,46 @@ describe('fileio_stream', function () {
expect(ss !== null).assertTrue();
let len = ss.readSync(new ArrayBuffer(4096));
expect(len == FILE_CONTENT.length).assertTrue();
expect(ss.closeSync() == null).assertTrue();
expect(fileio.unlinkSync(fpath) == null).assertTrue();
} catch (e) {
console.log('fileio_test_stream_read_sync_000 has failed for ' + e);
ss.closeSync();
fileio.unlinkSync(fpath);
} catch (err) {
console.info('fileio_test_stream_read_sync_000 has failed for ' + err);
expect(null).assertFail();
}
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_READSYNC_0010
* @tc.number SUB_DF_FILEIO_STREAM_READSYNC_0100
* @tc.name fileio_test_stream_read_sync_001
* @tc.desc Test the readSync method of class Stream.
* @tc.size MEDIUM(中型)
* @tc.desc Test the readSync method of class Stream,When offset equals buffer length..
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_stream_read_sync_001', 0, async function () {
let bufLen = 5;
expect(FILE_CONTENT.length > bufLen).assertTrue();
let fpath = await nextFileName('fileio_test_stream_read_sync_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let ss = fileio.createStreamSync(fpath, 'r+');
let len = ss.readSync(new ArrayBuffer(bufLen), {
offset: 1
let len = ss.readSync(new ArrayBuffer(4096), {
offset: 4096
});
expect(len == (bufLen - 1)).assertTrue();
expect(ss.closeSync() == null).assertTrue();
expect(fileio.unlinkSync(fpath) == null).assertTrue();
} catch (e) {
console.log('fileio_test_stream_read_sync_001 has failed for ' + e);
expect(len == 0).assertTrue();
ss.closeSync();
fileio.unlinkSync(fpath);
} catch (err) {
console.info('fileio_test_stream_read_sync_001 has failed for ' + err);
expect(null).assertFail();
}
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_READSYNC_0020
* @tc.number SUB_DF_FILEIO_STREAM_READSYNC_0200
* @tc.name fileio_test_stream_read_sync_002
* @tc.desc Test the readSync method of class Stream.
* @tc.size MEDIUM(中型)
* @tc.desc Test the readSync method of class Stream,When the length is 1.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
......@@ -159,19 +158,19 @@ describe('fileio_stream', function () {
length: 1
});
expect(len == 1).assertTrue();
expect(ss.closeSync() == null).assertTrue();
expect(fileio.unlinkSync(fpath) == null).assertTrue();
} catch (e) {
console.log('fileio_test_stream_read_sync_002 has failed for ' + e);
ss.closeSync();
fileio.unlinkSync(fpath);
} catch (err) {
console.info('fileio_test_stream_read_sync_002 has failed for ' + err);
expect(null).assertFail();
}
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_READSYNC_0030
* @tc.number SUB_DF_FILEIO_STREAM_READSYNC_0300
* @tc.name fileio_test_stream_read_sync_003
* @tc.desc Test the readSync method of class Stream.
* @tc.size MEDIUM(中型)
* @tc.desc Test the readSync method of class Stream,When the position is 1.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
......@@ -186,73 +185,73 @@ describe('fileio_stream', function () {
position: 1
});
expect(len == (FILE_CONTENT.length - 1)).assertTrue();
expect(ss.closeSync() == null).assertTrue();
expect(fileio.unlinkSync(fpath) == null).assertTrue();
} catch (e) {
console.log('fileio_test_stream_read_sync_003 has failed for ' + e);
ss.closeSync();
fileio.unlinkSync(fpath);
} catch (err) {
console.info('fileio_test_stream_read_sync_003 has failed for ' + err);
expect(null).assertFail();
}
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_READSYNC_0040
* @tc.number SUB_DF_FILEIO_STREAM_READSYNC_0400
* @tc.name fileio_test_stream_read_sync_004
* @tc.desc Test the readSync method of class Stream.
* @tc.size MEDIUM(中型)
* @tc.desc Test the readSync method of class Stream,When the offset is greater than the buffer length.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_stream_read_sync_004', 0, async function () {
let ss;
const invalidOffset = 99999;
let fpath = await nextFileName('fileio_test_stream_read_sync_004');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
ss = fileio.createStreamSync(fpath, 'r+');
ss.readSync(new ArrayBuffer(4096), {
offset: invalidOffset
offset: 4097
});
expect(null).assertFail();
} catch (e) {
expect(ss.closeSync() == null).assertTrue();
expect(fileio.unlinkSync(fpath) == null).assertTrue();
} catch (err) {
console.info('fileio_test_stream_read_sync_004 has failed for ' + err);
expect(err.message == "Invalid option.offset, buffer limit exceeded").assertTrue();
ss.closeSync();
fileio.unlinkSync(fpath);
}
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_READSYNC_0050
* @tc.number SUB_DF_FILEIO_STREAM_READSYNC_0500
* @tc.name fileio_test_stream_read_sync_005
* @tc.desc Test the readSync method of class Stream.
* @tc.size MEDIUM(中型)
* @tc.desc Test the readSync method of class Stream, 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_sync_005', 0, async function () {
let ss;
const invalidLength = 9999;
let fpath = await nextFileName('fileio_test_stream_read_sync_005');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
ss = fileio.createStreamSync(fpath, 'r+');
ss.readSync(new ArrayBuffer(4096), {
length: invalidLength
length: 4097
});
expect(null).assertFail();
} catch (e) {
expect(ss.closeSync() == null).assertTrue();
expect(fileio.unlinkSync(fpath) == null).assertTrue();
} catch (err) {
console.info('fileio_test_stream_read_sync_005 has failed for ' + err);
expect(err.message == "Invalid option.length, buffer limit exceeded").assertTrue();
ss.closeSync();
fileio.unlinkSync(fpath);
}
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_READSYNC_0060
* @tc.number SUB_DF_FILEIO_STREAM_READSYNC_0600
* @tc.name fileio_test_stream_read_sync_006
* @tc.desc Test the readSync method of class Stream.
* @tc.size MEDIUM(中型)
* @tc.desc Test the readSync method of class Stream, When position is equal to the length of the file content plus one.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
......@@ -268,10 +267,10 @@ describe('fileio_stream', function () {
position: invalidPos
});
expect(len == 0).assertTrue();
expect(ss.closeSync() == null).assertTrue();
expect(fileio.unlinkSync(fpath) == null).assertTrue();
} catch (e) {
console.log('fileio_test_stream_read_sync_006 has failed for ' + e);
ss.closeSync();
fileio.unlinkSync(fpath);
} catch (err) {
console.info('fileio_test_stream_read_sync_006 has failed for ' + err);
expect(null).assertFail();
}
});
......@@ -279,8 +278,8 @@ describe('fileio_stream', function () {
/**
* @tc.number SUB_DF_FILEIO_STREAM_WRITESYNC_0000
* @tc.name fileio_test_stream_write_sync_000
* @tc.desc Test writeSync() interface.
* @tc.size MEDIUM(中型)
* @tc.desc Test writeSync() interface, Write data to stream file.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
......@@ -293,10 +292,10 @@ describe('fileio_stream', function () {
let ss = fileio.createStreamSync(fpath, 'r+');
expect(ss !== null).assertTrue();
expect(ss.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
expect(ss.closeSync() == null).assertTrue();
expect(fileio.unlinkSync(fpath) == null).assertTrue();
} catch (e) {
console.log('fileio_test_stream_write_sync_000 has failed for ' + e);
ss.closeSync();
fileio.unlinkSync(fpath);
} catch (err) {
console.info('fileio_test_stream_write_sync_000 has failed for ' + err);
expect(null).assertFail();
}
});
......
......@@ -18,101 +18,106 @@ import {
describe, it, expect,
} from '../../Common';
describe('fileio_stream', function () {
describe('fileio_stream_close', function () {
/**
* @tc.number SUB_DF_FILEIO_STREAM_FDOPENSTREAMSYNC_0000
* @tc.name fileio_test_stream_fdopen_stream_sync_000
* @tc.desc Test fdopenStreamSync() interface
* @tc.size MEDIUM(中型)
* @tc.number SUB_DF_FILEIO_STREAM_CLOSESYNC_0000
* @tc.name fileio_test_stream_close_sync_000
* @tc.desc Test closeSync() interface,Close file stream.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_stream_fdopen_stream_sync_000', 0, async function () {
let fpath = await nextFileName('fileio_test_stream_fdopen_stream_sync_000');
it('fileio_test_stream_close_sync_000', 0, async function () {
let fpath = await nextFileName('fileio_test_stream_close_sync_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let fd = fileio.openSync(fpath, 0o2);
let ss = fileio.fdopenStreamSync(fd, 'r+');
expect(ss !== null).assertTrue();
expect(ss.closeSync() == null).assertTrue();
expect(fileio.unlinkSync(fpath) == null).assertTrue();
} catch (e) {
console.log('fileio_test_stream_fdopen_stream_sync_000 has failed for ' + e);
ss.closeSync();
fileio.unlinkSync(fpath);
} catch (err) {
console.info('fileio_test_stream_close_sync_000 has failed for ' + err);
expect(null).assertFail();
}
})
/**
* @tc.number SUB_DF_FILEIO_STREAM_FDOPENSTREAMSYNC_0010
* @tc.name fileio_test_stream_fdopen_stream_sync_001
* @tc.desc Test fdopenStreamSync() interface
* @tc.size MEDIUM(中型)
* @tc.number SUB_DF_FILEIO_STREAM_CLOSESYNC_0100
* @tc.name fileio_test_stream_close_sync_001
* @tc.desc Test closeSync() interface,When there are parameters.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_stream_fdopen_stream_sync_001', 0, function () {
it('fileio_test_stream_close_sync_001', 0, async function () {
let fpath = await nextFileName('fileio_test_stream_close_sync_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let ss = fileio.fdopenStreamSync(-1, 'r+');
expect(null).assertFail();
} catch (e) {
console.log('fileio_test_stream_fdopen_stream_sync_001 has failed for ' + e);
let fd = fileio.openSync(fpath, 0o2);
let ss = fileio.fdopenStreamSync(fd, 'r+');
expect(ss !== null).assertTrue();
ss.closeSync(1);
} catch (err) {
console.info('fileio_test_stream_close_sync_001 has failed for ' + err);
expect(err.message == "Number of arguments unmatched").assertTrue();
fileio.unlinkSync(fpath);
}
})
/**
* @tc.number SUB_DF_FILEIO_STREAM_FDOPENSTREAMASYNC_0000
* @tc.name fileio_test_stream_fdopen_stream_async_000
* @tc.desc Test fdopenStreamSync() interface
* @tc.size MEDIUM(中型)
* @tc.number SUB_DF_FILEIO_STREAM_CLOSEASYNC_0000
* @tc.name fileio_test_stream_close_async_000
* @tc.desc Test close() interface,return in promise mode.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_stream_fdopen_stream_async_000', 0, async function (done) {
let fpath = await nextFileName('fileio_test_stream_fdopen_stream_async_000');
it('fileio_test_stream_close_async_000', 0, async function (done) {
let fpath = await nextFileName('fileio_test_stream_close_async_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let fd = await fileio.openSync(fpath, 0o2);
let ss = await fileio.fdopenStreamSync(fd, 'r+');
expect(ss !== null).assertTrue();
expect(ss.closeSync() == null).assertTrue();
expect(fileio.unlinkSync(fpath) == null).assertTrue();
await ss.close();
fileio.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileio_test_stream_fdopen_stream_async_000 has failed for ' + e);
} catch (err) {
console.info('fileio_test_stream_close_async_000 has failed for ' + err);
expect(null).assertFail();
}
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_FDOPENSTREAMASYNC_0010
* @tc.name fileio_test_stream_fdopen_stream_async_001
* @tc.desc Test fdopenStreamSync() interface
* @tc.size MEDIUM(中型)
* @tc.number SUB_DF_FILEIO_STREAM_CLOSEASYNC_0100
* @tc.name fileio_test_stream_close_async_001
* @tc.desc Test close() interface,return in callback mode.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_stream_fdopen_stream_async_001', 0, async function (done) {
let fpath = await nextFileName('fileio_test_stream_fdopen_stream_async_001');
it('fileio_test_stream_close_async_001', 0, async function (done) {
let fpath = await nextFileName('fileio_test_stream_close_async_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let fd = await fileio.openSync(fpath, 0o2);
let ss = await fileio.fdopenStreamSync(fd, 'r+');
expect(ss !== null).assertTrue();
ss.close(function (err, stream) {
expect(fileio.unlinkSync(fpath) == null).assertTrue();
ss.close(function (err) {
fileio.unlinkSync(fpath);
})
done();
} catch (e) {
console.log('fileio_test_stream_fdopen_stream_async_001 has failed for ' + e);
} catch (err) {
console.info('fileio_test_stream_close_async_001 has failed for ' + err);
expect(null).assertFail();
}
});
......
......@@ -18,13 +18,13 @@ import {
describe, it, expect,
} from '../../Common';
describe('fileio_stream', function () {
describe('fileio_stream_flush', function () {
/**
* @tc.number SUB_DF_FILEIO_STREAM_FLUSHSYNC_0000
* @tc.name fileio_test_stream_flush_sync_000
* @tc.desc Test flushSync() interface
* @tc.size MEDIUM(中型)
* @tc.desc Test flushSync() interface, refresh file stream.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
......@@ -37,20 +37,46 @@ describe('fileio_stream', function () {
let ss = fileio.createStreamSync(fpath, 'r+');
expect(ss !== null).assertTrue();
expect(ss.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
expect(ss.flushSync() == null).assertTrue();
expect(ss.closeSync() == null).assertTrue();
expect(fileio.unlinkSync(fpath) == null).assertTrue();
} catch (e) {
console.log('fileio_test_stream_flush_sync_000 has failed for ' + e);
ss.flushSync();
ss.closeSync();
fileio.unlinkSync(fpath);
} catch (err) {
console.info('fileio_test_stream_flush_sync_000 has failed for ' + err);
expect(null).assertFail();
}
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_FLUSHSYNC_0100
* @tc.name fileio_test_stream_flush_sync_001
* @tc.desc Test flushSync() interface, When there are parameters.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_stream_flush_sync_001', 0, async function () {
let fpath = await nextFileName('fileio_test_stream_flush_sync_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let ss = fileio.createStreamSync(fpath, 'r+');
expect(ss !== null).assertTrue();
expect(ss.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
try {
ss.flushSync(1);
} catch (err) {
console.info('fileio_test_stream_flush_sync_001 has failed for ' + err);
expect(err.message == "Number of arguments unmatched").assertTrue();
ss.closeSync();
fileio.unlinkSync(fpath);
}
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_FLUSHASYNC_0000
* @tc.name fileio_test_stream_flush_async_000
* @tc.desc Test flushSync() interface
* @tc.size MEDIUM(中型)
* @tc.desc Test flush() interface, refresh the file stream and return in promise mode.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
......@@ -62,25 +88,24 @@ describe('fileio_stream', function () {
try {
let ss = await fileio.createStreamSync(fpath, 'r+');
expect(ss !== null).assertTrue();
expect(ss.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
ss.flush().then(
function (err) {
expect(!err).assertTrue();
expect(ss.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
expect(ss.closeSync() == null).assertTrue();
expect(fileio.unlinkSync(fpath) == null).assertTrue();
ss.closeSync();
fileio.unlinkSync(fpath);
})
done();
} catch (e) {
console.log('fileio_test_stream_flush_async_000 has failed for ' + e);
} catch (err) {
console.info('fileio_test_stream_flush_async_000 has failed for ' + err);
expect(null).assertFail();
}
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_FLUSHASYNC_0010
* @tc.number SUB_DF_FILEIO_STREAM_FLUSHASYNC_0100
* @tc.name fileio_test_stream_flush_async_001
* @tc.desc Test flushSync() interface
* @tc.size MEDIUM(中型)
* @tc.desc Test flush() interface, refresh the file stream and return in callback mode.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
......@@ -94,13 +119,14 @@ describe('fileio_stream', function () {
expect(ss !== null).assertTrue();
expect(ss.writeSync(FILE_CONTENT) == FILE_CONTENT.length).assertTrue();
ss.flush(function (err) {
expect(ss.closeSync() == null).assertTrue();
expect(fileio.unlinkSync(fpath) == null).assertTrue();
ss.closeSync();
fileio.unlinkSync(fpath);
done();
})
} catch (e) {
console.log('fileio_test_stream_flush_async_001 has failed for ' + e);
} catch (err) {
console.info('fileio_test_stream_flush_async_001 has failed for ' + err);
expect(null).assertFail();
}
});
});
......@@ -18,13 +18,13 @@ import {
describe, it, expect,
} from '../../Common';
describe('fileio_stream', function () {
describe('fileio_stream_read', function () {
/**
* @tc.number SUB_DF_FILEIO_STREAM_READASYNC_0000
* @tc.name fileio_test_stream_read_async_000
* @tc.desc Test readAsync() interface
* @tc.size MEDIUM(中型)
* @tc.desc Test read() interface,return in promise mode.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
......@@ -38,20 +38,20 @@ describe('fileio_stream', function () {
expect(ss !== null).assertTrue();
let readout = await ss.read(new ArrayBuffer(4096));
expect(readout.bytesRead == FILE_CONTENT.length).assertTrue();
expect(ss.closeSync() == null).assertTrue();
expect(fileio.unlinkSync(fpath) == null).assertTrue();
ss.closeSync();
fileio.unlinkSync(fpath);
done();
} catch (e) {
console.log('fileio_test_stream_read_async_000 has failed for ' + e);
} catch (err) {
console.info('fileio_test_stream_read_async_000 has failed for ' + err);
expect(null).assertFail();
}
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_READASYNC_0010
* @tc.number SUB_DF_FILEIO_STREAM_READASYNC_0100
* @tc.name fileio_test_stream_read_async_001
* @tc.desc Test readAsync() interface
* @tc.size MEDIUM(中型)
* @tc.desc Test read() interface, return in callback mode.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
......@@ -65,12 +65,279 @@ describe('fileio_stream', function () {
expect(ss !== null).assertTrue();
ss.read(new ArrayBuffer(4096), null, function (err, readout) {
expect(readout.bytesRead == FILE_CONTENT.length).assertTrue();
expect(ss.closeSync() == null).assertTrue();
expect(fileio.unlinkSync(fpath) == null).assertTrue();
ss.closeSync();
fileio.unlinkSync(fpath);
});
} catch (e) {
console.log('fileio_test_stream_read_async_001 has failed for ' + e);
} catch (err) {
console.info('fileio_test_stream_read_async_001 has failed for ' + err);
expect(null).assertFail();
}
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_READASYNC_0200
* @tc.name fileio_test_stream_read_async_002
* @tc.desc Test read() interface, When the offset is 1 and the length is 5.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_stream_read_async_002', 0, async function (done) {
let fpath = await nextFileName('fileio_test_stream_read_async_002');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let ss = fileio.createStreamSync(fpath, 'r+');
expect(ss !== null).assertTrue();
let options = {
offset: 1,
length: 5
}
let readout = await ss.read(new ArrayBuffer(4096),options);
expect(readout.bytesRead == 5).assertTrue();
ss.closeSync();
fileio.unlinkSync(fpath);
done();
} catch (err) {
console.info('fileio_test_stream_read_async_002 has failed for ' + err);
expect(null).assertFail();
}
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_READASYNC_0300
* @tc.name fileio_test_stream_read_async_003
* @tc.desc Test read() interface, When offset equals buffer length.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_stream_read_async_003', 0, async function (done) {
let fpath = await nextFileName('fileio_test_stream_read_async_003');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let ss = fileio.createStreamSync(fpath, 'r+');
expect(ss !== null).assertTrue();
let readout = await ss.read(new ArrayBuffer(4096), {offset: 4096});
expect(readout.bytesRead == 0).assertTrue();
ss.closeSync();
fileio.unlinkSync(fpath);
done();
} catch (err) {
console.info('fileio_test_stream_read_async_003 has failed for ' + err);
expect(null).assertFail();
}
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_READASYNC_0400
* @tc.name fileio_test_stream_read_async_004
* @tc.desc Test read() interface, When the offset is 1 and the position is 5.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_stream_read_async_004', 0, async function (done) {
let fpath = await nextFileName('fileio_test_stream_read_async_004');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let ss = fileio.createStreamSync(fpath, 'r+');
expect(ss !== null).assertTrue();
let options = {
offset: 1,
position:5
}
let readout = await ss.read(new ArrayBuffer(4096),options);
expect(readout.bytesRead == FILE_CONTENT.length).assertTrue();
ss.closeSync();
fileio.unlinkSync(fpath);
done();
} catch (err) {
console.info('fileio_test_stream_read_async_004 has failed for ' + err);
expect(null).assertFail();
}
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_READASYNC_0500
* @tc.name fileio_test_stream_read_async_005
* @tc.desc Test read() interface, When the offset is negative.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_stream_read_async_005', 0, async function (done) {
let fpath = await nextFileName('fileio_test_stream_read_async_005');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let ss = fileio.createStreamSync(fpath, 'r+');
expect(ss !== null).assertTrue();
try {
await ss.read(new ArrayBuffer(4096), {offset: -1});
} catch (err) {
console.info('fileio_test_stream_read_async_005 has failed for ' + err);
expect(err.message == "Failed GetReadArg").assertTrue();
ss.closeSync();
fileio.unlinkSync(fpath);
done();
}
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_READASYNC_0600
* @tc.name fileio_test_stream_read_async_006
* @tc.desc Test read() interface, When offset+length>buffer.size.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_stream_read_async_006', 0, async function (done) {
let fpath = await nextFileName('fileio_test_stream_read_async_006');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let ss = fileio.createStreamSync(fpath, 'r+');
expect(ss !== null).assertTrue();
try {
await ss.read(new ArrayBuffer(4096), {offset: 1,length:4096});
} catch (err) {
console.info('fileio_test_stream_read_async_006 has failed for ' + err);
expect(err.message == "Failed GetReadArg").assertTrue();
ss.closeSync();
fileio.unlinkSync(fpath);
done();
}
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_READASYNC_0700
* @tc.name fileio_test_stream_read_async_007
* @tc.desc Test read() interface, When the offset is greater than the buffer length.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_stream_read_async_007', 0, async function (done) {
let fpath = await nextFileName('fileio_test_stream_read_async_007');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let ss = fileio.createStreamSync(fpath, 'r+');
expect(ss !== null).assertTrue();
try {
await ss.read(new ArrayBuffer(4096), {offset: 4097});
} catch (err) {
console.info('fileio_test_stream_read_async_007 has failed for ' + err);
expect(err.message == "Failed GetReadArg").assertTrue();
ss.closeSync();
fileio.unlinkSync(fpath);
done();
}
});
/**
* @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);
}
});
});
......@@ -18,13 +18,13 @@ import {
describe, it, expect,
} from '../../Common';
describe('fileio_stream', function () {
describe('fileio_stream_write', function () {
/**
* @tc.number SUB_DF_FILEIO_STREAM_WRITEASYNC_0000
* @tc.name fileio_test_stream_write_async_000
* @tc.desc Test Stream.write() interface
* @tc.size MEDIUM(中型)
* @tc.desc Test write() interface,When the position is 1,return in promise mode.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
......@@ -41,21 +41,22 @@ describe('fileio_stream', function () {
position: 1
}).then(function (len) {
expect(len == length).assertTrue();
expect(fileio.unlinkSync(fpath) == null).assertTrue();
fileio.unlinkSync(fpath);
ss.closeSync();
done();
})
} catch (e) {
console.log('fileio_test_stream_write_async_000 has failed for ' + e);
} catch (err) {
console.info('fileio_test_stream_write_async_000 has failed for ' + err);
expect(null).assertFail();
done();
}
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_WRITEASYNC_0010
* @tc.number SUB_DF_FILEIO_STREAM_WRITEASYNC_0100
* @tc.name fileio_test_stream_write_async_001
* @tc.desc Test Stream.write() interface
* @tc.size MEDIUM(中型)
* @tc.desc Test write() interface,return in callback mode.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
......@@ -67,17 +68,368 @@ describe('fileio_stream', function () {
try {
let ss = fileio.createStreamSync(fpath, 'r+');
expect(ss !== null).assertTrue();
let length = 4096;
let offset = 1;
ss.write(new ArrayBuffer(length), { offset: offset, encoding: 'utf-8' }, function (err, bytesWritten) {
expect(bytesWritten == (length - offset)).assertTrue();
expect(fileio.unlinkSync(fpath) == null).assertTrue();
ss.write(new ArrayBuffer(4096), { offset: 1, encoding: 'utf-8' }, function (err, bytesWritten) {
expect(bytesWritten == 4095).assertTrue();
fileio.unlinkSync(fpath);
ss.closeSync();
done();
});
} catch (e) {
console.log('fileio_test_stream_write_async_001 has failed for ' + e);
} catch (err) {
console.info('fileio_test_stream_write_async_001 has failed for ' + err);
expect(null).assertFail();
done();
}
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_WRITEASYNC_0200
* @tc.name fileio_test_stream_write_async_002
* @tc.desc Test write() interface,When the offset is 1.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_stream_write_async_002', 0, async function (done) {
let fpath = await nextFileName('fileio_test_stream_write_async_002');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let ss = fileio.createStreamSync(fpath, 'r+');
expect(ss !== null).assertTrue();
let content = "hello, world";
let bytesWritten = await ss.write(content, { offset: 1, length: 5, encoding: 'utf-8' });
expect(bytesWritten == 5).assertTrue();
fileio.unlinkSync(fpath);
ss.closeSync();
done();
} catch (err) {
console.info('fileio_test_stream_write_async_002 has failed for ' + err);
expect(null).assertFail();
done();
}
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_WRITEASYNC_0300
* @tc.name fileio_test_stream_write_async_003
* @tc.desc Test write() interface,When the length is 1.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_stream_write_async_003', 0, async function (done) {
let fpath = await nextFileName('fileio_test_stream_write_async_003');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let ss = fileio.createStreamSync(fpath, 'r+');
expect(ss !== null).assertTrue();
let content = "hello, world";
let bytesWritten = await ss.write(content, { length: 1, encoding: 'utf-8' });
expect(bytesWritten == 1).assertTrue();
fileio.unlinkSync(fpath);
ss.closeSync();
done();
} catch (err) {
console.info('fileio_test_stream_write_async_003 has failed for ' + err);
expect(null).assertFail();
done();
}
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_WRITEASYNC_0400
* @tc.name fileio_test_stream_write_async_004
* @tc.desc Test write() interface,When there is only the first parameter.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_stream_write_async_004', 0, async function (done) {
let fpath = await nextFileName('fileio_test_stream_write_async_004');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let ss = fileio.createStreamSync(fpath, 'r+');
expect(ss !== null).assertTrue();
let content = "hello, world";
let bytesWritten = await ss.write(content);
expect(bytesWritten == content.length).assertTrue();
fileio.unlinkSync(fpath);
ss.closeSync();
done();
} catch (err) {
console.info('fileio_test_stream_write_async_004 has failed for ' + err);
expect(null).assertFail();
done();
}
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_WRITEASYNC_0500
* @tc.name fileio_test_stream_write_async_005
* @tc.desc Test write() interface,When offset equals buffer length.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_stream_write_async_005', 0, async function (done) {
let fpath = await nextFileName('fileio_test_stream_write_async_005');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let ss = fileio.createStreamSync(fpath, 'r+');
expect(ss !== null).assertTrue();
let content = "hello, world";
let bytesWritten = await ss.write(content, {offset: content.length});
expect(bytesWritten == 0).assertTrue();
fileio.unlinkSync(fpath);
ss.closeSync();
done();
} catch (err) {
console.info('fileio_test_stream_write_async_005 has failed for ' + err);
expect(null).assertFail();
done();
}
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_WRITEASYNC_0600
* @tc.name fileio_test_stream_write_async_006
* @tc.desc Test write() interface,When offset+length>buffer.size.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_stream_write_async_006', 0, async function (done) {
let fpath = await nextFileName('fileio_test_stream_write_async_006');
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,{offset: 5, length:10});
done();
} catch (err) {
console.info('fileio_test_stream_write_async_006 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_0700
* @tc.name fileio_test_stream_write_async_007
* @tc.desc Test write() interface,When the offset is greater than the buffer length.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_stream_write_async_007', 0, async function (done) {
let fpath = await nextFileName('fileio_test_stream_write_async_007');
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, {offset:content.length+1});
} catch (err) {
console.info('fileio_test_stream_write_async_007 has failed for ' + err);
expect(err.message == "Invalid option.offset, buffer limit exceeded").assertTrue();
fileio.unlinkSync(fpath);
ss.closeSync();
done();
}
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_WRITEASYNC_0800
* @tc.name fileio_test_stream_write_async_008
* @tc.desc Test write() interface,when encoding invalid.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_stream_write_async_008', 0, async function (done) {
let fpath = await nextFileName('fileio_test_stream_write_async_008');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let ss = fileio.createStreamSync(fpath, 'r+');
expect(ss !== null).assertTrue();
try {
await ss.write("hello, world", {encoding: 'GB2312' });
} catch (err) {
console.info('fileio_test_stream_write_async_008 has failed for ' + err);
expect(err.message == "Illegal write buffer or encoding").assertTrue();
ss.closeSync();
fileio.unlinkSync(fpath);
done();
}
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_WRITEASYNC_0900
* @tc.name fileio_test_stream_write_async_009
* @tc.desc Test write() interface,When there are no parameters.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_stream_write_async_009', 0, async function (done) {
let fpath = await nextFileName('fileio_test_stream_write_async_009');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
let ss = fileio.createStreamSync(fpath, 'r+');
expect(ss !== null).assertTrue();
try {
await ss.write();
} catch (err) {
console.info('fileio_test_stream_write_async_009 has failed for ' + err);
expect(err.message == "Number of arguments unmatched").assertTrue();
fileio.unlinkSync(fpath);
ss.closeSync();
done();
}
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_WRITEASYNC_1000
* @tc.name fileio_test_stream_write_async_010
* @tc.desc Test write() interface,When the offset is negative.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_stream_write_async_010', 0, async function (done) {
let fpath = await nextFileName('fileio_test_stream_write_async_010');
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, {offset:-1});
} catch (err) {
console.info('fileio_test_stream_write_async_010 has failed for ' + err);
expect(err.message == "Invalid option.offset, positive integer is desired").assertTrue();
fileio.unlinkSync(fpath);
ss.closeSync();
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.
先完成此消息的编辑!
想要评论请 注册