diff --git a/storage/storagefileiojstest/src/main/js/default/test/FileIODir.test.js b/storage/storagefileiojstest/src/main/js/default/test/FileIODir.test.js index bc8ee0ed3a0bdb9e020472455709a64e3658bf8d..f9fcf0f0661b9138b2d74d3148f4004f9b4b1cc9 100644 --- a/storage/storagefileiojstest/src/main/js/default/test/FileIODir.test.js +++ b/storage/storagefileiojstest/src/main/js/default/test/FileIODir.test.js @@ -38,11 +38,11 @@ describe('fileIOTestDir', function () { it('fileio_test_dir_open_sync_000', 0, async function () { let dpath = await nextFileName('fileio_test_dir_open_sync_000') + 'd' try { - expect(fileio.mkdirSync(dpath) !== null).assertTrue(); + fileio.mkdirSync(dpath); let dd = fileio.opendirSync(dpath); expect(dd !== null).assertTrue(); - expect(dd.closeSync() == null).assertTrue(); - expect(fileio.rmdirSync(dpath) !== null).assertTrue(); + dd.closeSync(); + fileio.rmdirSync(dpath); } catch (e) { console.log('fileio_test_dir_open_sync_000 has failed for ' + e); @@ -71,13 +71,14 @@ describe('fileIOTestDir', function () { * @tc.desc Function of API, dpath value is not exist. */ it('fileio_test_dir_open_sync_002', 0, async function () { - let dpath = await nextFileName('fileio_test_dir_open_sync_003') + 'd' + let dpath = await nextFileName('fileio_test_dir_open_sync_002') + 'd' try { fileio.opendirSync(dpath); expect(null).assertFail(); } catch (e) { console.log('fileio_test_dir_open_sync_002 has failed for ' + e); + expect(e.message == 'No such file or directory').assertTrue(); } }); @@ -87,7 +88,7 @@ describe('fileIOTestDir', function () { * @tc.desc Function of API, dpath too long. */ it('fileio_test_dir_open_sync_003', 0, async function () { - let dpath = await nextFileName('fileio_dir11'); + let dpath = await nextFileName('fileio_test_dir_open_sync_003'); fileio.mkdirSync(dpath); try { for (let i = 0; i < 16; i++) { @@ -124,7 +125,7 @@ describe('fileIOTestDir', function () { * @tc.desc Function of API, uri dir too many layers. */ it('fileio_test_dir_open_sync_005', 0, async function () { - let dpath = await nextFileName('dir'); + let dpath = await nextFileName('fileio_test_dir_open_sync_005'); fileio.mkdirSync(dpath); try { for (let i = 0; i < 1024; i++) { @@ -152,6 +153,7 @@ describe('fileIOTestDir', function () { } catch (e) { console.log('fileio_test_dir_open_sync_006 has failed for ' + e); + expect(e.message == 'No such file or directory').assertTrue(); } }); @@ -164,14 +166,14 @@ describe('fileIOTestDir', function () { let dpath = await nextFileName('fileio_test_dir_read_sync_000') + 'd' let fpath = dpath + '/f0' try { - expect(typeof(fileio.mkdirSync(dpath)) == 'undefined').assertTrue(); + fileio.mkdirSync(dpath); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); let dd = fileio.opendirSync(dpath); expect(dd !== null).assertTrue(); expect(dd.readSync() !== null).assertTrue(); - expect(dd.closeSync() == null).assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); - expect(fileio.rmdirSync(dpath) !== null).assertTrue(); + dd.closeSync(); + fileio.unlinkSync(fpath); + fileio.rmdirSync(dpath); } catch (e) { console.log('fileio_test_dir_read_sync_000 has failed for ' + e); @@ -188,10 +190,10 @@ describe('fileIOTestDir', function () { let dpath = await nextFileName('fileio_test_dir_read_sync_001') + 'd' let fpathArray = new Array(dpath + '/f1', dpath + '/f2', dpath + '/d3'); try { - expect(fileio.mkdirSync(dpath) !== null).assertTrue(); + fileio.mkdirSync(dpath); for (let i = 0; i < 3; i++) { if (i == 2) { - expect(fileio.mkdirSync(fpathArray[i]) !== null).assertTrue(); + fileio.mkdirSync(fpathArray[i]) } else { expect(prepareFile(fpathArray[i], FILE_CONTENT)).assertTrue(); } @@ -199,23 +201,19 @@ describe('fileIOTestDir', function () { let dd = fileio.opendirSync(dpath); expect(dd !== null).assertTrue(); for (let i = 0; i < 3; i++) { - if (i == 2) { - let bool = typeof(dd.readSync()); - expect(bool == 'object').assertTrue(); - console.log('---bool=' + bool); - } else { - expect(dd.readSync() !== null).assertTrue(); - } + let bool = typeof (dd.readSync()); + expect(bool == 'object').assertTrue(); + console.log('---bool=' + bool); } - expect(dd.closeSync() == null).assertTrue(); + dd.closeSync(); for (let i = 0; i < 3; i++) { if (i == 2) { - expect(fileio.rmdirSync(fpathArray[i]) !== null).assertTrue(); + fileio.rmdirSync(fpathArray[i]); } else { - expect(fileio.unlinkSync(fpathArray[i]) !== null).assertTrue(); + fileio.unlinkSync(fpathArray[i]); } } - expect(fileio.rmdirSync(dpath) !== null).assertTrue(); + fileio.rmdirSync(dpath); } catch (e) { console.log('fileio_test_dir_read_sync_001 has failed for ' + e); @@ -232,10 +230,10 @@ describe('fileIOTestDir', function () { let dpath = await nextFileName('fileio_test_dir_read_sync_002') + 'd' let fpathArray = new Array(dpath + '/f1', dpath + '/f2', dpath + '/d3'); try { - expect(fileio.mkdirSync(dpath) !== null).assertTrue(); + fileio.mkdirSync(dpath) for (let i = 0; i < 3; i++) { if (i == 2) { - expect(fileio.mkdirSync(fpathArray[i]) !== null).assertTrue(); + fileio.mkdirSync(fpathArray[i]) } else { expect(prepareFile(fpathArray[i], FILE_CONTENT)).assertTrue(); } @@ -245,21 +243,21 @@ describe('fileIOTestDir', function () { for (let i = 0; i < 3; i++) { expect(dd.readSync() !== null).assertTrue(); } - expect(dd.readSync() == null).assertTrue(); - expect(null).assertFail(); - } - catch (e) { - console.log('fileio_test_dir_read_sync_002 has failed for ' + e); - expect(dd.closeSync() == null).assertTrue(); + expect(dd.readSync() !== null).assertTrue(); + dd.closeSync(); for (let i = 0; i < 3; i++) { if (i == 2) { - expect(fileio.rmdirSync(fpathArray[i]) !== null).assertTrue(); + fileio.rmdirSync(fpathArray[i]); } else { - expect(fileio.unlinkSync(fpathArray[i]) !== null).assertTrue(); + fileio.unlinkSync(fpathArray[i]); } } - expect(fileio.rmdirSync(dpath) !== null).assertTrue(); - } + fileio.rmdirSync(dpath); + } + catch (e) { + console.log('fileio_test_dir_read_sync_002 has failed for ' + e); + expect(null).assertFail(); + } }); /** @@ -271,16 +269,16 @@ describe('fileIOTestDir', function () { let dpath = await nextFileName('fileio_test_dir_read_sync_003') + 'd' let dd; try { - expect(fileio.mkdirSync(dpath) !== null).assertTrue(); + fileio.mkdirSync(dpath); dd = fileio.opendirSync(dpath); expect(dd !== null).assertTrue(); - expect(dd.readSync() == null).assertTrue(); - expect(null).assertFail(); - } + expect(dd.readSync() !== null).assertTrue(); + dd.closeSync(); + fileio.rmdirSync(dpath); + } catch (e) { - expect(dd.closeSync() == null).assertTrue(); - expect(fileio.rmdirSync(dpath) !== null).assertTrue(); console.log('fileio_test_dir_read_sync_003 has failed for ' + e); + expect(null).assertFail(); } }); @@ -294,7 +292,7 @@ describe('fileIOTestDir', function () { let fpath = dpath + '/f1' let dd try { - expect(fileio.mkdirSync(dpath) !== null).assertTrue(); + fileio.mkdirSync(dpath); expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); dd = fileio.opendirSync(dpath); expect(dd !== null).assertTrue(); @@ -302,10 +300,11 @@ describe('fileIOTestDir', function () { expect(null).assertFail(); } catch (e) { - expect(dd.closeSync() == null).assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); - expect(fileio.rmdirSync(dpath) !== null).assertTrue(); console.log('fileio_test_dir_read_sync_004 has failed for ' + e); + expect(e.message == 'Number of arguments unmatched').assertTrue(); + dd.closeSync(); + fileio.unlinkSync(fpath); + fileio.rmdirSync(dpath); } }); @@ -318,18 +317,18 @@ describe('fileIOTestDir', function () { let dpath = await nextFileName('fileio_test_dir_read_sync_005') + 'd' let fpath = dpath + '/f' try { - expect(typeof(fileio.mkdirSync(dpath)) == 'undefined').assertTrue(); + fileio.mkdirSync(dpath); for (let i = 0; i < 10001; i++) { - expect(prepareFile(fpath + i, 'test_text')).assertTrue(); + expect(prepareFile(fpath + i, 'test_text')).assertTrue(); } let dd = fileio.opendirSync(dpath); expect(dd !== null).assertTrue(); expect(dd.readSync() !== null).assertTrue(); - expect(dd.closeSync() == null).assertTrue(); + dd.closeSync(); for (let i = 0; i < 10001; i++) { fileio.unlinkSync(fpath + i); } - expect(fileio.rmdirSync(dpath) !== null).assertTrue(); + fileio.rmdirSync(dpath); } catch (e) { console.log('fileio_test_dir_read_sync_005 has failed for ' + e); @@ -345,15 +344,36 @@ describe('fileIOTestDir', function () { it('fileio_test_dir_close_sync_000', 0, async function () { let dpath = await nextFileName('fileio_test_dir_close_sync_000') + 'd' try { - expect(fileio.mkdirSync(dpath) !== null).assertTrue(); + fileio.mkdirSync(dpath); let dd = fileio.opendirSync(dpath); expect(dd !== null).assertTrue(); - expect(dd.closeSync() == null).assertTrue(); - expect(fileio.rmdirSync(dpath) !== null).assertTrue(); + dd.closeSync(); + fileio.rmdirSync(dpath); } catch (e) { console.log('fileio_test_dir_close_sync_000 has failed for ' + e); expect(null).assertFail(); } }); + + /** + * @tc.number SUB_STORAGE_FileIO_dir_CloseSync_0100 + * @tc.name fileio_test_dir_close_sync_001 + * @tc.desc Function of API, closeSync. error parameter. + */ + it('fileio_test_dir_close_sync_001', 0, async function () { + let dpath = await nextFileName('fileio_test_dir_close_sync_001') + 'd' + try { + fileio.mkdirSync(dpath); + let dd = fileio.opendirSync(dpath); + expect(dd !== null).assertTrue(); + dd.closeSync(-1); + expect(null).assertFail(); + } + catch (e) { + console.log('fileio_test_dir_close_sync_001 has failed for ' + e); + expect(e.message == 'Dir has been closed yet').assertTrue(); + fileio.rmdirSync(dpath); + } + }); }); diff --git a/storage/storagefileiojstest/src/main/js/default/test/FileIOStat.test.js b/storage/storagefileiojstest/src/main/js/default/test/FileIOStat.test.js index ab0fcf26e12e20634f4b943d853c0c37709c9212..07ca9c5d493d94245369687452162404b19e5915 100644 --- a/storage/storagefileiojstest/src/main/js/default/test/FileIOStat.test.js +++ b/storage/storagefileiojstest/src/main/js/default/test/FileIOStat.test.js @@ -41,7 +41,7 @@ describe('fileIOTestStat', function () { try { let stat = fileio.statSync(fpath); expect(stat !== null).assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + fileio.unlinkSync(fpath); } catch (e) { console.log('fileio_test_stat_stat_sync_000 has failed for ' + e); @@ -62,6 +62,7 @@ describe('fileIOTestStat', function () { } catch (e) { console.log('fileio_test_stat_stat_sync_001 has failed for ' + e); + expect(e.message == 'No such file or directory').assertTrue(); } }); @@ -72,11 +73,11 @@ describe('fileIOTestStat', function () { */ it('fileio_test_stat_stat_sync_002', 0, async function () { let dpath = await nextFileName('fileio_test_stat_stat_sync_002') + 'd'; - expect(fileio.mkdirSync(dpath) !== null).assertTrue(); + fileio.mkdirSync(dpath); try { let stat = fileio.statSync(dpath); expect(stat !== null).assertTrue(); - expect(fileio.rmdirSync(dpath) !== null).assertTrue(); + fileio.rmdirSync(dpath); } catch (e) { console.log('fileio_test_stat_stat_sync_002 has failed for ' + e); @@ -118,7 +119,7 @@ describe('fileIOTestStat', function () { try { let stat = fileio.statSync(fpath); expect(typeof(stat.dev) == 'number').assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + fileio.unlinkSync(fpath); } catch (e) { console.log('fileio_test_stat_dev_000 has failed for ' + e); @@ -137,7 +138,7 @@ describe('fileIOTestStat', function () { try { let stat = fileio.statSync(fpath); expect(typeof(stat.ino) == 'number').assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + fileio.unlinkSync(fpath); } catch (e) { console.log('fileio_test_stat_ino_000 has failed for ' + e); @@ -156,7 +157,7 @@ describe('fileIOTestStat', function () { try { let stat = fileio.statSync(fpath); expect(typeof(stat.mode) == 'number').assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + fileio.unlinkSync(fpath); } catch (e) { console.log('fileio_test_stat_mode_000 has failed for ' + e); @@ -175,7 +176,7 @@ describe('fileIOTestStat', function () { try { let stat = fileio.statSync(fpath); expect(typeof(stat.nlink) == 'number').assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + fileio.unlinkSync(fpath); } catch (e) { console.log('fileio_test_stat_nlink_000 has failed for ' + e); @@ -194,7 +195,7 @@ describe('fileIOTestStat', function () { try { let stat = fileio.statSync(fpath); expect(typeof(stat.uid) == 'number').assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + fileio.unlinkSync(fpath); } catch (e) { console.log('fileio_test_stat_uid_000 has failed for ' + e); @@ -213,7 +214,7 @@ describe('fileIOTestStat', function () { try { let stat = fileio.statSync(fpath); expect(typeof(stat.gid) == 'number').assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + fileio.unlinkSync(fpath); } catch (e) { console.log('fileio_test_stat_gid_000 has failed for ' + e); @@ -232,7 +233,7 @@ describe('fileIOTestStat', function () { try { let stat = fileio.statSync(fpath); expect(typeof(stat.rdev) == 'number').assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + fileio.unlinkSync(fpath); } catch (e) { console.log('fileio_test_stat_rdev_000 has failed for ' + e); @@ -251,7 +252,7 @@ describe('fileIOTestStat', function () { try { let stat = fileio.statSync(fpath); expect(typeof(stat.size) == 'number').assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + fileio.unlinkSync(fpath); } catch (e) { console.log('fileio_test_stat_size_000 has failed for ' + e); @@ -259,25 +260,6 @@ describe('fileIOTestStat', function () { } }); - /** - * @tc.number SUB_STORAGE_FileIO_Stat_blksize_0000 - * @tc.name fileio_test_stat_blksize_000 - * @tc.desc Function of API. Gets the size of the disk block containing the file. - */ - it('fileio_test_stat_blksize_000', 0, async function () { - let fpath = await nextFileName('fileio_test_stat_blksize_000'); - expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); - try { - let stat = fileio.statSync(fpath); - expect(typeof(stat.blksize) == 'number').assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); - } - catch (e) { - console.log('fileio_test_stat_blksize_000 has failed for ' + e); - expect(null).assertFail(); - } - }); - /** * @tc.number SUB_STORAGE_FileIO_Stat_blocks_0000 * @tc.name fileio_test_stat_blocks_000 @@ -289,7 +271,7 @@ describe('fileIOTestStat', function () { try { let stat = fileio.statSync(fpath); expect(typeof(stat.blocks) == 'number').assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + fileio.unlinkSync(fpath); } catch (e) { console.log('fileio_test_stat_blocks_000 has failed for ' + e); @@ -308,7 +290,7 @@ describe('fileIOTestStat', function () { try { let stat = fileio.statSync(fpath); expect(typeof(stat.atime) == 'number').assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + fileio.unlinkSync(fpath); } catch (e) { console.log('fileio_test_stat_atime_000 has failed for ' + e); @@ -327,7 +309,7 @@ describe('fileIOTestStat', function () { try { let stat = fileio.statSync(fpath); expect(typeof(stat.mtime) == 'number').assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + fileio.unlinkSync(fpath); } catch (e) { console.log('fileio_test_stat_mtime_000 has failed for ' + e); @@ -346,7 +328,7 @@ describe('fileIOTestStat', function () { try { let stat = fileio.statSync(fpath); expect(typeof(stat.ctime) == 'number').assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + fileio.unlinkSync(fpath); } catch (e) { console.log('fileio_test_stat_ctime_000 has failed for ' + e); @@ -365,7 +347,7 @@ describe('fileIOTestStat', function () { try { let stat = fileio.statSync(fpath); expect(typeof(stat.isBlockDevice()) == 'boolean').assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + fileio.unlinkSync(fpath); } catch (e) { console.log('fileio_test_stat_is_block_device_000 has failed for ' + e); @@ -384,7 +366,7 @@ describe('fileIOTestStat', function () { try { let stat = fileio.statSync(fpath); expect(!stat.isBlockDevice()).assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + fileio.unlinkSync(fpath); } catch (e) { console.log('fileio_test_stat_is_block_device_001 has failed for ' + e); @@ -406,8 +388,9 @@ describe('fileIOTestStat', function () { expect(null).assertFail(); } catch (e) { - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); console.log('fileio_test_stat_is_block_device_002 has failed for ' + e); + expect(e.message == 'Number of arguments unmatched').assertTrue(); + fileio.unlinkSync(fpath); } }); @@ -422,7 +405,7 @@ describe('fileIOTestStat', function () { try { let stat = fileio.statSync(fpath); expect(typeof(stat.isCharacterDevice()) == 'boolean').assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + fileio.unlinkSync(fpath); } catch (e) { console.log('fileio_test_stat_is_character_device_000 has failed for ' + e); @@ -441,7 +424,7 @@ describe('fileIOTestStat', function () { try { let stat = fileio.statSync(fpath); expect(!stat.isCharacterDevice()).assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + fileio.unlinkSync(fpath); } catch (e) { console.log('fileio_test_stat_is_character_device_001 has failed for ' + e); @@ -464,7 +447,8 @@ describe('fileIOTestStat', function () { } catch (e) { console.log('fileio_test_stat_is_character_device_002 has failed for ' + e); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + expect(e.message == 'Number of arguments unmatched').assertTrue(); + fileio.unlinkSync(fpath); } }); @@ -479,7 +463,7 @@ describe('fileIOTestStat', function () { try { let stat = fileio.statSync(fpath); expect(typeof(stat.isDirectory()) == 'boolean').assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + fileio.unlinkSync(fpath); } catch (e) { console.log('fileio_test_stat_is_directory_000 has failed for ' + e); @@ -498,7 +482,7 @@ describe('fileIOTestStat', function () { try { let stat = fileio.statSync(fpath); expect(!stat.isDirectory()).assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + fileio.unlinkSync(fpath); } catch (e) { console.log('fileio_test_stat_is_directory_001 has failed for ' + e); @@ -514,10 +498,10 @@ describe('fileIOTestStat', function () { it('fileio_test_stat_is_directory_002', 0, async function () { let dpath = await nextFileName('fileio_test_stat_is_directory_002') + 'd' try { - expect(fileio.mkdirSync(dpath) !== null).assertTrue(); + fileio.mkdirSync(dpath); let stat = fileio.statSync(dpath); expect(stat.isDirectory()).assertTrue(); - expect(fileio.rmdirSync(dpath) !== null).assertTrue(); + fileio.rmdirSync(dpath); } catch (e) { console.log('fileio_test_stat_is_directory_002 has failed for ' + e); @@ -533,14 +517,15 @@ describe('fileIOTestStat', function () { it('fileio_test_stat_is_directory_003', 0, async function () { let dpath = await nextFileName('fileio_test_stat_is_directory_003') + 'd' try { - expect(fileio.mkdirSync(dpath) !== null).assertTrue(); + fileio.mkdirSync(dpath); let stat = fileio.statSync(dpath); expect(stat.isDirectory(-1) == null).assertTrue(); expect(null).assertFail(); } catch (e) { console.log('fileio_test_stat_is_directory_003 has failed for ' + e); - expect(fileio.rmdirSync(dpath) !== null).assertTrue(); + expect(e.message == 'Number of arguments unmatched').assertTrue(); + fileio.rmdirSync(dpath); } }); @@ -555,7 +540,7 @@ describe('fileIOTestStat', function () { try { let stat = fileio.statSync(fpath); expect(typeof(stat.isFIFO()) == 'boolean').assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + fileio.unlinkSync(fpath); } catch (e) { console.log('fileio_test_stat_is_fifo_000 has failed for ' + e); @@ -574,7 +559,7 @@ describe('fileIOTestStat', function () { try { let stat = fileio.statSync(fpath); expect(!stat.isFIFO()).assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + fileio.unlinkSync(fpath); } catch (e) { console.log('fileio_test_stat_is_fifo_001 has failed for ' + e); @@ -597,7 +582,8 @@ describe('fileIOTestStat', function () { } catch (e) { console.log('fileio_test_stat_is_fifo_002 has failed for ' + e); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + expect(e.message == 'Number of arguments unmatched').assertTrue(); + fileio.unlinkSync(fpath); } }); @@ -612,7 +598,7 @@ describe('fileIOTestStat', function () { try { let stat = fileio.statSync(fpath); expect(typeof(stat.isFile()) == 'boolean').assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + fileio.unlinkSync(fpath); } catch (e) { console.log('fileio_test_stat_is_file_000 has failed for ' + e); @@ -631,7 +617,7 @@ describe('fileIOTestStat', function () { try { let stat = fileio.statSync(fpath); expect(stat.isFile()).assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + fileio.unlinkSync(fpath); console.log('---fileio_test_stat_is_file_001 is passed!'); } catch (e) { @@ -648,10 +634,10 @@ describe('fileIOTestStat', function () { it('fileio_test_stat_is_file_002', 0, async function () { let dpath = await nextFileName('fileio_test_stat_is_file_002'); try { - expect(fileio.mkdirSync(dpath) !== null).assertTrue(); + fileio.mkdirSync(dpath); let stat = fileio.statSync(dpath); expect(!stat.isFile()).assertTrue(); - expect(fileio.rmdirSync(dpath) !== null).assertTrue(); + fileio.rmdirSync(dpath); } catch (e) { console.log('fileio_test_stat_is_file_002 has failed for ' + e); @@ -667,14 +653,15 @@ describe('fileIOTestStat', function () { it('fileio_test_stat_is_file_003', 0, async function () { let dpath = await nextFileName('fileio_test_stat_is_file_003'); try { - expect(fileio.mkdirSync(dpath) !== null).assertTrue(); + fileio.mkdirSync(dpath); let stat = fileio.statSync(dpath); expect(stat.isFile(-1) == null).assertTrue(); expect(null).assertFail(); } catch (e) { - expect(fileio.rmdirSync(dpath) !== null).assertTrue(); console.log('fileio_test_stat_is_file_003 has failed for ' + e); + expect(e.message == 'Number of arguments unmatched').assertTrue(); + fileio.rmdirSync(dpath); } }); @@ -689,7 +676,7 @@ describe('fileIOTestStat', function () { try { let stat = fileio.statSync(fpath); expect(typeof(stat.isSocket()) == 'boolean').assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + fileio.unlinkSync(fpath); } catch (e) { console.log('fileio_test_stat_is_socket_000 has failed for ' + e); @@ -708,7 +695,7 @@ describe('fileIOTestStat', function () { try { let stat = fileio.statSync(fpath); expect(!stat.isSocket()).assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + fileio.unlinkSync(fpath); } catch (e) { console.log('fileio_test_stat_is_socket_001 has failed for ' + e); @@ -731,7 +718,8 @@ describe('fileIOTestStat', function () { } catch (e) { console.log('fileio_test_stat_is_socket_002 has failed for ' + e); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + expect(e.message == 'Number of arguments unmatched').assertTrue(); + fileio.unlinkSync(fpath); } }); @@ -746,7 +734,7 @@ describe('fileIOTestStat', function () { try { let stat = fileio.statSync(fpath); expect(typeof(stat.isSymbolicLink()) == 'boolean').assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + fileio.unlinkSync(fpath); } catch (e) { console.log('fileio_test_stat_is_symbolic_link_000 has failed for ' + e); @@ -765,7 +753,7 @@ describe('fileIOTestStat', function () { try { let stat = fileio.statSync(fpath); expect(!stat.isSymbolicLink()).assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + fileio.unlinkSync(fpath); } catch (e) { console.log('fileio_test_stat_is_symbolic_link_001 has failed for ' + e); @@ -788,7 +776,8 @@ describe('fileIOTestStat', function () { } catch (e) { console.log('fileio_test_stat_is_symbolic_link_002 has failed for ' + e); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + expect(e.message == 'Number of arguments unmatched').assertTrue(); + fileio.unlinkSync(fpath); } }); diff --git a/storage/storagefileiojstest/src/main/js/default/test/FileIOStream.test.js b/storage/storagefileiojstest/src/main/js/default/test/FileIOStream.test.js index 0aaa0e44148d1355ab0608d8b091a4529d7b286e..0f97813cde66400abbdecad88c2d36d76f0c0249 100644 --- a/storage/storagefileiojstest/src/main/js/default/test/FileIOStream.test.js +++ b/storage/storagefileiojstest/src/main/js/default/test/FileIOStream.test.js @@ -44,8 +44,8 @@ describe('fileIOTestStream', function () { try { let ss = fileio.createStreamSync(fpath, 'r'); expect(ss !== null).assertTrue(); - expect(ss.closeSync() !== null).assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + ss.closeSync(); + fileio.unlinkSync(fpath); console.log('fileio_test_stream_create_stream_sync_000 is passed!'); } catch (e) { @@ -85,13 +85,13 @@ describe('fileIOTestStream', function () { expect(ss !== null).assertTrue(); let wlen = ss.writeSync(text); expect(wlen !== null).assertTrue(); - expect(ss.closeSync() !== null).assertTrue(); + ss.closeSync(); expect(fileToReadOnly(fpath)).assertTrue(); ss = fileio.createStreamSync(fpath, 'r'); let rlen = ss.readSync(new ArrayBuffer(4096)); expect(rlen == text.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_create_stream_sync_002 has failed for ' + e); @@ -109,8 +109,8 @@ describe('fileIOTestStream', function () { try { let ss = fileio.createStreamSync(fpath, 'w'); expect(ss !== null).assertTrue(); - expect(ss.closeSync() !== null).assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + ss.closeSync(); + fileio.unlinkSync(fpath); } catch (e) { console.log('fileio_test_stream_create_stream_sync_003 has failed for ' + e); @@ -133,17 +133,16 @@ describe('fileIOTestStream', function () { expect(ss !== null).assertTrue(); let wlen = ss.writeSync(text); expect(wlen !== null).assertTrue(); - expect(ss.closeSync() !== null).assertTrue(); + ss.closeSync(); expect(fileToReadOnly(fpath)).assertTrue(); ss = fileio.createStreamSync(fpath, 'r'); let rlen = ss.readSync(new ArrayBuffer(4096)); expect(rlen == text.length + 1).assertTrue(); - expect(ss.closeSync() !== null).assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + ss.closeSync(); + fileio.unlinkSync(fpath); } catch (e) { console.log('fileio_test_stream_create_stream_sync_004 has failed for ' + e); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); expect(null).assertFail(); } }); @@ -158,8 +157,8 @@ describe('fileIOTestStream', function () { try { let ss = fileio.createStreamSync(fpath, 'a'); expect(ss !== null).assertTrue(); - expect(ss.closeSync() !== null).assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + ss.closeSync(); + fileio.unlinkSync(fpath); } catch (e) { console.log('fileio_test_stream_create_stream_sync_005 has failed for ' + e); @@ -178,8 +177,8 @@ describe('fileIOTestStream', function () { try { let ss = fileio.createStreamSync(fpath, 'r+'); expect(ss !== null).assertTrue(); - expect(ss.closeSync() !== null).assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + ss.closeSync(); + fileio.unlinkSync(fpath); } catch (e) { console.log('fileio_test_stream_create_stream_sync_006 has failed for ' + e); @@ -217,13 +216,13 @@ describe('fileIOTestStream', function () { expect(ss !== null).assertTrue(); let wlen = ss.writeSync(text); expect(wlen !== null).assertTrue(); - expect(ss.closeSync() !== null).assertTrue(); + ss.closeSync(); expect(fileToReadOnly(fpath)).assertTrue(); ss = fileio.createStreamSync(fpath, 'r'); let rlen = ss.readSync(new ArrayBuffer(4096)); expect(rlen == text.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_create_stream_sync_008 has failed for ' + e); @@ -241,8 +240,8 @@ describe('fileIOTestStream', function () { try { let ss = fileio.createStreamSync(fpath, 'w+'); expect(ss !== null).assertTrue(); - expect(ss.closeSync() !== null).assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + ss.closeSync(); + fileio.unlinkSync(fpath); } catch (e) { console.log('fileio_test_stream_create_stream_sync_009 has failed for ' + e); @@ -264,13 +263,13 @@ describe('fileIOTestStream', function () { expect(ss !== null).assertTrue(); let wlen = ss.writeSync(text); expect(wlen !== null).assertTrue(); - expect(ss.closeSync() !== null).assertTrue(); + ss.closeSync(); expect(fileToReadOnly(fpath)).assertTrue(); ss = fileio.createStreamSync(fpath, 'r'); let rlen = ss.readSync(new ArrayBuffer(4096)); expect(rlen == text.length + 1).assertTrue(); - expect(ss.closeSync() !== null).assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + ss.closeSync(); + fileio.unlinkSync(fpath); } catch (e) { console.log('fileio_test_stream_create_stream_sync_010 has failed for ' + e); @@ -288,8 +287,8 @@ describe('fileIOTestStream', function () { try { let ss = fileio.createStreamSync(fpath, 'a+'); expect(ss !== null).assertTrue(); - expect(ss.closeSync() !== null).assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + ss.closeSync(); + fileio.unlinkSync(fpath); } catch (e) { console.log('fileio_test_stream_create_stream_sync_011 has failed for ' + e); @@ -309,8 +308,8 @@ describe('fileIOTestStream', function () { try { let ss = fileio.createStreamSync(fpath, 'rb'); expect(ss !== null).assertTrue(); - expect(ss.closeSync() !== null).assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + ss.closeSync(); + fileio.unlinkSync(fpath); } catch (e) { console.log('fileio_test_stream_create_stream_sync_012 has failed for ' + e); @@ -349,13 +348,13 @@ describe('fileIOTestStream', function () { expect(ss !== null).assertTrue(); let wlen = ss.writeSync(text); expect(wlen !== null).assertTrue(); - expect(ss.closeSync() !== null).assertTrue(); + ss.closeSync(); expect(fileToReadOnly(fpath)).assertTrue(); ss = fileio.createStreamSync(fpath, 'r'); let rlen = ss.readSync(new ArrayBuffer(4096)); expect(rlen == text.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_create_stream_sync_014 has failed for ' + e); @@ -373,8 +372,8 @@ describe('fileIOTestStream', function () { try { let ss = fileio.createStreamSync(fpath, 'wb'); expect(ss !== null).assertTrue(); - expect(ss.closeSync() !== null).assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + ss.closeSync(); + fileio.unlinkSync(fpath); } catch (e) { console.log('fileio_test_stream_create_stream_sync_015 has failed for ' + e); @@ -397,13 +396,13 @@ describe('fileIOTestStream', function () { expect(ss !== null).assertTrue(); let wlen = ss.writeSync(text); expect(wlen !== null).assertTrue(); - expect(ss.closeSync() !== null).assertTrue(); + ss.closeSync(); expect(fileToReadOnly(fpath)).assertTrue(); ss = fileio.createStreamSync(fpath, 'r'); let rlen = ss.readSync(new ArrayBuffer(4096)); expect(rlen == text.length + 1).assertTrue(); - expect(ss.closeSync() !== null).assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + ss.closeSync(); + fileio.unlinkSync(fpath); console.log('fileio_test_stream_create_stream_sync_016 is passed!'); } catch (e) { @@ -422,8 +421,8 @@ describe('fileIOTestStream', function () { try { let ss = fileio.createStreamSync(fpath, 'ab'); expect(ss !== null).assertTrue(); - expect(ss.closeSync() !== null).assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + ss.closeSync(); + fileio.unlinkSync(fpath); } catch (e) { console.log('fileio_test_stream_create_stream_sync_017 has failed for ' + e); @@ -442,8 +441,8 @@ describe('fileIOTestStream', function () { try { let ss = fileio.createStreamSync(fpath, 'rb+'); expect(ss !== null).assertTrue(); - expect(ss.closeSync() !== null).assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + ss.closeSync(); + fileio.unlinkSync(fpath); } catch (e) { console.log('fileio_test_stream_create_stream_sync_018 has failed for ' + e); @@ -481,13 +480,13 @@ describe('fileIOTestStream', function () { expect(ss !== null).assertTrue(); let wlen = ss.writeSync(text); expect(wlen !== null).assertTrue(); - expect(ss.closeSync() !== null).assertTrue(); + ss.closeSync(); expect(fileToReadOnly(fpath)).assertTrue(); ss = fileio.createStreamSync(fpath, 'r'); let rlen = ss.readSync(new ArrayBuffer(4096)); expect(rlen == text.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_create_stream_sync_020 has failed for ' + e); @@ -505,8 +504,8 @@ describe('fileIOTestStream', function () { try { let ss = fileio.createStreamSync(fpath, 'wb+'); expect(ss !== null).assertTrue(); - expect(ss.closeSync() !== null).assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + ss.closeSync(); + fileio.unlinkSync(fpath); } catch (e) { console.log('fileio_test_stream_create_stream_sync_021 has failed for ' + e); @@ -528,13 +527,13 @@ describe('fileIOTestStream', function () { expect(ss !== null).assertTrue(); let wlen = ss.writeSync(text); expect(wlen !== null).assertTrue(); - expect(ss.closeSync() !== null).assertTrue(); + ss.closeSync(); expect(fileToReadOnly(fpath)).assertTrue(); ss = fileio.createStreamSync(fpath, 'r'); let rlen = ss.readSync(new ArrayBuffer(4096)); expect(rlen == text.length + 1).assertTrue(); - expect(ss.closeSync() !== null).assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + ss.closeSync(); + fileio.unlinkSync(fpath); } catch (e) { console.log('fileio_test_stream_create_stream_sync_022 has failed for ' + e); @@ -552,8 +551,8 @@ describe('fileIOTestStream', function () { try { let ss = fileio.createStreamSync(fpath, 'ab+'); expect(ss !== null).assertTrue(); - expect(ss.closeSync() !== null).assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + ss.closeSync(); + fileio.unlinkSync(fpath); } catch (e) { console.log('fileio_test_stream_create_stream_sync_023 has failed for ' + e); @@ -572,7 +571,7 @@ describe('fileIOTestStream', function () { expect(null).assertFail(); } catch (e) { - console.log('fileio_test_stream_create_stream_sync_024 is passed!' + e); + console.log('fileio_test_stream_create_stream_sync_024 has failed for ' + e); } }); @@ -589,8 +588,8 @@ describe('fileIOTestStream', function () { expect(null).assertFail(); } catch (e) { - console.log('fileio_test_stream_create_stream_sync_025 is passed!' + e); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + console.log('fileio_test_stream_create_stream_sync_025 has failed for ' + e); + fileio.unlinkSync(fpath); } }); @@ -689,8 +688,8 @@ describe('fileIOTestStream', function () { let fd = fileio.openSync(fpath, 0o0); let ss = fileio.fdopenStreamSync(fd, 'r'); expect(ss !== null).assertTrue(); - expect(ss.closeSync() !== null).assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + ss.closeSync(); + fileio.unlinkSync(fpath); } catch (e) { console.log('fileio_test_stream_fdopen_stream_sync_000 has failed for ' + e); @@ -733,13 +732,13 @@ describe('fileIOTestStream', function () { expect(ss !== null).assertTrue(); let wlen = ss.writeSync(text); expect(wlen !== null).assertTrue(); - expect(ss.closeSync() !== null).assertTrue(); + ss.closeSync(); expect(fileToReadOnly(fpath)).assertTrue(); ss = fileio.createStreamSync(fpath, 'r'); let rlen = ss.readSync(new ArrayBuffer(4096)); expect(rlen == text.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_fdopen_stream_sync_002 has failed for ' + e); @@ -758,8 +757,8 @@ describe('fileIOTestStream', function () { let fd = fileio.openSync(fpath, 0o101, 0o222); let ss = fileio.fdopenStreamSync(fd, 'w'); expect(ss !== null).assertTrue(); - expect(ss.closeSync() !== null).assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + ss.closeSync(); + fileio.unlinkSync(fpath); } catch (e) { console.log('fileio_test_stream_fdopen_stream_sync_003 has failed for ' + e); @@ -784,13 +783,13 @@ describe('fileIOTestStream', function () { expect(ss !== null).assertTrue(); let wlen = ss.writeSync(text); expect(wlen !== null).assertTrue(); - expect(ss.closeSync() !== null).assertTrue(); + ss.closeSync(); expect(fileToReadOnly(fpath)).assertTrue(); ss = fileio.createStreamSync(fpath, 'r'); let rlen = ss.readSync(new ArrayBuffer(4096)); expect(rlen == text.length + 1).assertTrue(); - expect(ss.closeSync() !== null).assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + ss.closeSync(); + fileio.unlinkSync(fpath); } catch (e) { console.log('fileio_test_stream_fdopen_stream_sync_004 has failed for ' + e); @@ -809,8 +808,8 @@ describe('fileIOTestStream', function () { let fd = fileio.openSync(fpath, 0o101, 0o222); let ss = fileio.fdopenStreamSync(fd, 'a'); expect(ss !== null).assertTrue(); - expect(ss.closeSync() !== null).assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + ss.closeSync(); + fileio.unlinkSync(fpath); } catch (e) { console.log('fileio_test_stream_fdopen_stream_sync_005 has failed for ' + e); @@ -830,8 +829,8 @@ describe('fileIOTestStream', function () { 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(); + ss.closeSync(); + fileio.unlinkSync(fpath); } catch (e) { console.log('fileio_test_stream_fdopen_stream_sync_006 has failed for ' + e); @@ -870,13 +869,13 @@ describe('fileIOTestStream', function () { expect(ss !== null).assertTrue(); let wlen = ss.writeSync(text); expect(wlen !== null).assertTrue(); - expect(ss.closeSync() !== null).assertTrue(); + ss.closeSync(); expect(fileToReadOnly(fpath)).assertTrue(); ss = fileio.createStreamSync(fpath, 'r'); let rlen = ss.readSync(new ArrayBuffer(4096)); expect(rlen == text.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_fdopen_stream_sync_008 has failed for ' + e); @@ -895,8 +894,8 @@ describe('fileIOTestStream', function () { let fd = fileio.openSync(fpath, 0o102, 0o666); let ss = fileio.fdopenStreamSync(fd, 'w+'); expect(ss !== null).assertTrue(); - expect(ss.closeSync() !== null).assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + ss.closeSync(); + fileio.unlinkSync(fpath); } catch (e) { console.log('fileio_test_stream_fdopen_stream_sync_009 has failed for ' + e); @@ -920,13 +919,13 @@ describe('fileIOTestStream', function () { expect(ss !== null).assertTrue(); let wlen = ss.writeSync(text); expect(wlen !== null).assertTrue(); - expect(ss.closeSync() !== null).assertTrue(); + ss.closeSync(); expect(fileToReadOnly(fpath)).assertTrue(); ss = fileio.createStreamSync(fpath, 'r'); let rlen = ss.readSync(new ArrayBuffer(4096)); expect(rlen == text.length + 1).assertTrue(); - expect(ss.closeSync() !== null).assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + ss.closeSync(); + fileio.unlinkSync(fpath); } catch (e) { console.log('fileio_test_stream_fdopen_stream_sync_010 has failed for ' + e); @@ -945,8 +944,8 @@ describe('fileIOTestStream', function () { let fd = fileio.openSync(fpath, 0o102, 0o666); let ss = fileio.fdopenStreamSync(fd, 'a+'); expect(ss !== null).assertTrue(); - expect(ss.closeSync() !== null).assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + ss.closeSync(); + fileio.unlinkSync(fpath); } catch (e) { console.log('fileio_test_stream_fdopen_stream_sync_011 has failed for ' + e); @@ -967,8 +966,8 @@ describe('fileIOTestStream', function () { let fd = fileio.openSync(fpath, 0o0); let ss = fileio.fdopenStreamSync(fd, 'rb'); expect(ss !== null).assertTrue(); - expect(ss.closeSync() !== null).assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + ss.closeSync(); + fileio.unlinkSync(fpath); } catch (e) { console.log('fileio_test_stream_fdopen_stream_sync_012 has failed for ' + e); @@ -1008,13 +1007,13 @@ describe('fileIOTestStream', function () { expect(ss !== null).assertTrue(); let wlen = ss.writeSync(text); expect(wlen !== null).assertTrue(); - expect(ss.closeSync() !== null).assertTrue(); + ss.closeSync(); expect(fileToReadOnly(fpath)).assertTrue(); ss = fileio.createStreamSync(fpath, 'r'); let rlen = ss.readSync(new ArrayBuffer(4096)); expect(rlen == text.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_fdopen_stream_sync_014 has failed for ' + e); @@ -1033,8 +1032,8 @@ describe('fileIOTestStream', function () { let fd = fileio.openSync(fpath, 0o101, 0o222); let ss = fileio.fdopenStreamSync(fd, 'wb'); expect(ss !== null).assertTrue(); - expect(ss.closeSync() !== null).assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + ss.closeSync(); + fileio.unlinkSync(fpath); } catch (e) { console.log('fileio_test_stream_fdopen_stream_sync_015 has failed for ' + e); @@ -1059,13 +1058,13 @@ describe('fileIOTestStream', function () { expect(ss !== null).assertTrue(); let wlen = ss.writeSync(text); expect(wlen !== null).assertTrue(); - expect(ss.closeSync() !== null).assertTrue(); + ss.closeSync(); expect(fileToReadOnly(fpath)).assertTrue(); ss = fileio.createStreamSync(fpath, 'r'); let rlen = ss.readSync(new ArrayBuffer(4096)); expect(rlen == text.length + 1).assertTrue(); - expect(ss.closeSync() !== null).assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + ss.closeSync(); + fileio.unlinkSync(fpath); } catch (e) { console.log('fileio_test_stream_fdopen_stream_sync_016 has failed for ' + e); @@ -1084,8 +1083,8 @@ describe('fileIOTestStream', function () { let fd = fileio.openSync(fpath, 0o101, 0o222); let ss = fileio.fdopenStreamSync(fd, 'ab'); expect(ss !== null).assertTrue(); - expect(ss.closeSync() !== null).assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + ss.closeSync(); + fileio.unlinkSync(fpath); } catch (e) { console.log('fileio_test_stream_fdopen_stream_sync_017 has failed for ' + e); @@ -1105,8 +1104,8 @@ describe('fileIOTestStream', function () { let fd = fileio.openSync(fpath, 0o2); let ss = fileio.fdopenStreamSync(fd, 'rb+'); expect(ss !== null).assertTrue(); - expect(ss.closeSync() !== null).assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + ss.closeSync(); + fileio.unlinkSync(fpath); } catch (e) { console.log('fileio_test_stream_fdopen_stream_sync_018 has failed for ' + e); @@ -1145,13 +1144,13 @@ describe('fileIOTestStream', function () { expect(ss !== null).assertTrue(); let wlen = ss.writeSync(text); expect(wlen !== null).assertTrue(); - expect(ss.closeSync() !== null).assertTrue(); + ss.closeSync(); expect(fileToReadOnly(fpath)).assertTrue(); ss = fileio.createStreamSync(fpath, 'r'); let rlen = ss.readSync(new ArrayBuffer(4096)); expect(rlen == text.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_fdopen_stream_sync_020 has failed for ' + e); @@ -1170,8 +1169,8 @@ describe('fileIOTestStream', function () { let fd = fileio.openSync(fpath, 0o102, 0o666); let ss = fileio.fdopenStreamSync(fd, 'wb+'); expect(ss !== null).assertTrue(); - expect(ss.closeSync() !== null).assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + ss.closeSync(); + fileio.unlinkSync(fpath); } catch (e) { console.log('fileio_test_stream_fdopen_stream_sync_021 has failed for ' + e); @@ -1195,13 +1194,13 @@ describe('fileIOTestStream', function () { expect(ss !== null).assertTrue(); let wlen = ss.writeSync(text); expect(wlen !== null).assertTrue(); - expect(ss.closeSync() !== null).assertTrue(); + ss.closeSync(); expect(fileToReadOnly(fpath)).assertTrue(); ss = fileio.createStreamSync(fpath, 'r'); let rlen = ss.readSync(new ArrayBuffer(4096)); expect(rlen == text.length + 1).assertTrue(); - expect(ss.closeSync() !== null).assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + ss.closeSync(); + fileio.unlinkSync(fpath); } catch (e) { console.log('fileio_test_stream_fdopen_stream_sync_022 has failed for ' + e); @@ -1220,8 +1219,8 @@ describe('fileIOTestStream', function () { let fd = fileio.openSync(fpath, 0o102, 0o666); let ss = fileio.fdopenStreamSync(fd, 'ab+'); expect(ss !== null).assertTrue(); - expect(ss.closeSync() !== null).assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + ss.closeSync(); + fileio.unlinkSync(fpath); } catch (e) { console.log('fileio_test_stream_fdopen_stream_sync_023 has failed for ' + e); @@ -1236,11 +1235,11 @@ describe('fileIOTestStream', function () { */ it('fileio_test_stream_fdopen_stream_sync_024', 0, async function () { try { - expect(fileio.fdopenStreamSync(null, 'r') == null).assertTrue(); + fileio.fdopenStreamSync(null, 'r') expect(null).assertFail(); } catch (e) { - console.log('---fileio_test_stream_fdopen_stream_sync_024 is passed!' + e); + console.log('fileio_test_stream_fdopen_stream_sync_024 has failed for ' + e); } }); @@ -1258,8 +1257,8 @@ describe('fileIOTestStream', function () { expect(null).assertFail(); } catch (e) { - console.log('---fileio_test_stream_fdopen_stream_sync_025 is passed!' + e); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + console.log('fileio_test_stream_fdopen_stream_sync_025 has failed for ' + e); + fileio.unlinkSync(fpath); } }); @@ -1277,8 +1276,8 @@ describe('fileIOTestStream', function () { expect(ss !== null).assertTrue(); let len = ss.readSync(new ArrayBuffer(4096)); expect(len == text.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_sync_000 has failed for ' + e); @@ -1302,8 +1301,8 @@ describe('fileIOTestStream', function () { position: 1 }); expect(len == text.length - 1).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_sync_001 has failed for ' + e); @@ -1327,8 +1326,8 @@ describe('fileIOTestStream', function () { offset: 1 }); expect(len == text.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_sync_002 has failed for ' + e); @@ -1351,8 +1350,8 @@ describe('fileIOTestStream', function () { length: 1 }); expect(len == 1).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_sync_003 has failed for ' + e); @@ -1377,8 +1376,8 @@ describe('fileIOTestStream', function () { } catch (e) { console.log('fileio_test_stream_read_sync_004 has failed for ' + e); - expect(ss.closeSync() !== null).assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + ss.closeSync(); + fileio.unlinkSync(fpath); } }); @@ -1398,8 +1397,8 @@ describe('fileIOTestStream', function () { position: -1 }); expect(len == text.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_sync_005 has failed for ' + e); @@ -1426,8 +1425,8 @@ describe('fileIOTestStream', function () { } catch (e) { console.log('fileio_test_stream_read_sync_006 has failed for ' + e); - expect(ss.closeSync() !== null).assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + ss.closeSync(); + fileio.unlinkSync(fpath); } }); @@ -1444,8 +1443,8 @@ describe('fileIOTestStream', function () { let ss = fileio.createStreamSync(fpath, 'r+'); expect(ss !== null).assertTrue(); expect(ss.writeSync(text) == text.length).assertTrue(); - expect(ss.closeSync() !== null).assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + ss.closeSync(); + fileio.unlinkSync(fpath); console.log('---fileio_test_stream_write_sync_000 is passed!'); } catch (e) { @@ -1473,8 +1472,8 @@ describe('fileIOTestStream', function () { } catch (e) { console.log('fileio_test_stream_write_sync_001 has failed for ' + e); - expect(ss.closeSync() !== null).assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + ss.closeSync(); + fileio.unlinkSync(fpath); } }); @@ -1493,13 +1492,13 @@ describe('fileIOTestStream', function () { let ss = fileio.fdopenStreamSync(fd, 'w'); expect(ss !== null).assertTrue(); expect(ss.writeSync('aaa') !== null).assertTrue(); - expect(ss.closeSync() !== null).assertTrue(); + ss.closeSync(); expect(fileToReadOnly(fpath)).assertTrue(); ss = fileio.createStreamSync(fpath, 'r'); let rlen = ss.readSync(new ArrayBuffer(4096)); expect(rlen == 3).assertTrue(); - expect(ss.closeSync() !== null).assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + ss.closeSync(); + fileio.unlinkSync(fpath); } catch (e) { console.log('fileio_test_stream_write_sync_002 has failed for ' + e); @@ -1522,13 +1521,13 @@ describe('fileIOTestStream', function () { let ss = fileio.fdopenStreamSync(fd, 'w'); expect(ss !== null).assertTrue(); expect(ss.writeSync('aaa') !== null).assertTrue(); - expect(ss.closeSync() !== null).assertTrue(); + ss.closeSync(); expect(fileToReadOnly(fpath)).assertTrue(); ss = fileio.createStreamSync(fpath, 'r'); let rlen = ss.readSync(new ArrayBuffer(4096)); expect(rlen == 3).assertTrue(); - expect(ss.closeSync() !== null).assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + ss.closeSync(); + fileio.unlinkSync(fpath); } catch (e) { console.log('fileio_test_stream_write_sync_003 has failed for ' + e); @@ -1550,12 +1549,12 @@ describe('fileIOTestStream', function () { expect(ss !== null).assertTrue(); let wlen = ss.writeSync(text); expect(wlen == text.length).assertTrue(); - expect(ss.closeSync() !== null).assertTrue(); + ss.closeSync(); ss = fileio.createStreamSync(fpath, 'r+'); let rlen = ss.readSync(new ArrayBuffer(4096)); expect(rlen == text.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_write_sync_004 has failed for ' + e); @@ -1580,17 +1579,16 @@ describe('fileIOTestStream', function () { expect(ss.writeSync(writeStrArray[i], { encoding: encodingArray[i] }) !== null).assertTrue(); - expect(ss.closeSync() !== null).assertTrue(); + ss.closeSync(); ss = fileio.createStreamSync(fpath, 'r+'); let rlen = ss.readSync(new ArrayBuffer(4096)); expect(rlen !== null).assertTrue(); - expect(ss.closeSync() !== null).assertTrue(); + ss.closeSync(); } - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + fileio.unlinkSync(fpath); } catch (e) { console.log('fileio_test_stream_write_sync_005 has failed for ' + e); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); expect(null).assertFail(); } }); @@ -1612,13 +1610,13 @@ describe('fileIOTestStream', function () { expect(ss.writeSync('aaa', { position: 1 }) !== null).assertTrue(); - expect(ss.closeSync() !== null).assertTrue(); + ss.closeSync(); expect(fileToReadOnly(fpath)).assertTrue(); ss = fileio.createStreamSync(fpath, 'r'); let rlen = ss.readSync(new ArrayBuffer(4096)); expect(rlen == 4).assertTrue(); - expect(ss.closeSync() !== null).assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + ss.closeSync(); + fileio.unlinkSync(fpath); } catch (e) { console.log('fileio_test_stream_write_sync_006 has failed for ' + e); @@ -1643,13 +1641,13 @@ describe('fileIOTestStream', function () { expect(ss.writeSync('aaa', { offset: 1 }) !== null).assertTrue(); - expect(ss.closeSync() !== null).assertTrue(); + ss.closeSync(); expect(fileToReadOnly(fpath)).assertTrue(); ss = fileio.createStreamSync(fpath, 'r'); let rlen = ss.readSync(new ArrayBuffer(4096)); expect(rlen == 2).assertTrue(); - expect(ss.closeSync() !== null).assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + ss.closeSync(); + fileio.unlinkSync(fpath); } catch (e) { console.log('fileio_test_stream_write_sync_007 has failed for ' + e); @@ -1673,12 +1671,12 @@ describe('fileIOTestStream', function () { length: text.length }); expect(wlen == text.length).assertTrue(); - expect(ss.closeSync() !== null).assertTrue(); + ss.closeSync(); ss = fileio.createStreamSync(fpath, 'r+'); let rlen = ss.readSync(new ArrayBuffer(4096)); expect(rlen == text.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_write_sync_008 has failed for ' + e); @@ -1701,7 +1699,7 @@ describe('fileIOTestStream', function () { expect(null).assertFail(); } catch (e) { - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + fileio.unlinkSync(fpath); console.log('fileio_test_stream_write_sync_009 has failed for ' + e); } }); @@ -1724,8 +1722,8 @@ describe('fileIOTestStream', function () { } catch (e) { console.log('fileio_test_stream_write_sync_010 has failed for ' + e); - expect(ss.closeSync() !== null).assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + ss.closeSync(); + fileio.unlinkSync(fpath); } }); @@ -1747,8 +1745,8 @@ describe('fileIOTestStream', function () { } catch (e) { console.log('fileio_test_stream_write_sync_011 has failed for ' + e); - expect(ss.closeSync() !== null).assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + ss.closeSync(); + fileio.unlinkSync(fpath); } }); @@ -1770,8 +1768,8 @@ describe('fileIOTestStream', function () { } catch (e) { console.log('fileio_test_stream_write_sync_012 has failed for ' + e); - expect(ss.closeSync() !== null).assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + ss.closeSync(); + fileio.unlinkSync(fpath); } }); @@ -1793,8 +1791,8 @@ describe('fileIOTestStream', function () { offset: 1, length: 1, }) == 1).assertTrue(); - expect(ss.closeSync() !== null).assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + ss.closeSync(); + fileio.unlinkSync(fpath); console.log('---fileio_test_stream_write_sync_013 is passed!'); } catch (e) { @@ -1819,8 +1817,8 @@ describe('fileIOTestStream', function () { offset: 2, length: 2, }) == 2).assertTrue(); - expect(ss.closeSync() !== null).assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + ss.closeSync(); + fileio.unlinkSync(fpath); console.log('---fileio_test_stream_write_sync_014 is passed!'); } catch (e) { @@ -1844,12 +1842,12 @@ describe('fileIOTestStream', function () { let ss = fileio.fdopenStreamSync(fd, 'w'); expect(ss !== null).assertTrue(); expect(ss.writeSync(randomString(4096)) !== null).assertTrue(); - expect(ss.closeSync() !== null).assertTrue(); + ss.closeSync(); expect(fileToReadOnly(fpath)).assertTrue(); ss = fileio.createStreamSync(fpath, 'r'); let rlen = ss.readSync(new ArrayBuffer(4096)); - expect(ss.closeSync() !== null).assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + ss.closeSync(); + fileio.unlinkSync(fpath); } catch (e) { console.log('fileio_test_stream_write_read_4k_sync has failed for ' + e); @@ -1870,9 +1868,9 @@ describe('fileIOTestStream', function () { let ss = fileio.createStreamSync(fpath, 'r+'); expect(ss !== null).assertTrue(); expect(ss.writeSync(text) == text.length).assertTrue(); - expect(ss.flushSync() !== null).assertTrue(); - expect(ss.closeSync() !== null).assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + ss.flushSync(); + ss.closeSync(); + fileio.unlinkSync(fpath); } catch (e) { console.log('fileio_test_stream_flush_sync_001 has failed for ' + e); @@ -1891,13 +1889,13 @@ describe('fileIOTestStream', function () { try { let ss = fileio.createStreamSync(fpath, 'r+'); expect(ss !== null).assertTrue(); - expect(ss.closeSync() !== null).assertTrue(); + ss.closeSync(); ss.flushSync(); expect(null).assertFail(); } catch (e) { console.log('fileio_test_stream_flush_sync_001 has failed for ' + e); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + fileio.unlinkSync(fpath); } }); @@ -1911,8 +1909,8 @@ describe('fileIOTestStream', function () { expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); try { let ss = fileio.createStreamSync(fpath, 'r+'); - expect(ss.closeSync() !== null).assertTrue(); - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + ss.closeSync(); + fileio.unlinkSync(fpath); } catch (e) { console.log('fileio_test_stream_close_sync_000 has failed for ' + e); @@ -1931,12 +1929,12 @@ describe('fileIOTestStream', function () { let ss; try { ss = fileio.createStreamSync(fpath, 'r+'); - expect(ss.closeSync() !== null).assertTrue(); - expect(ss.closeSync() == null).assertTrue(); + ss.closeSync(); + ss.closeSync(); expect(null).assertFail(); } catch (e) { - expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + fileio.unlinkSync(fpath); console.log('fileio_test_stream_close_sync_001 has failed for ' + e); } });