2018-06-11 19:14:52 +05:30
|
|
|
'use strict';
|
|
|
|
require('../common');
|
2018-09-28 14:50:04 +09:00
|
|
|
const common = require('../common');
|
2018-06-11 19:14:52 +05:30
|
|
|
const fixtures = require('../common/fixtures');
|
|
|
|
const assert = require('assert');
|
|
|
|
const fs = require('fs');
|
|
|
|
const filepath = fixtures.path('x.txt');
|
|
|
|
const fd = fs.openSync(filepath, 'r');
|
2018-10-01 02:03:47 +09:00
|
|
|
const fsPromises = fs.promises;
|
2018-06-11 19:14:52 +05:30
|
|
|
|
|
|
|
const buffer = new Uint8Array();
|
|
|
|
|
|
|
|
assert.throws(
|
|
|
|
() => fs.readSync(fd, buffer, 0, 10, 0),
|
|
|
|
{
|
|
|
|
code: 'ERR_INVALID_ARG_VALUE',
|
|
|
|
message: 'The argument \'buffer\' is empty and cannot be written. ' +
|
2018-08-12 23:35:27 +02:00
|
|
|
'Received Uint8Array []'
|
2018-06-11 19:14:52 +05:30
|
|
|
}
|
|
|
|
);
|
2018-09-28 14:50:04 +09:00
|
|
|
|
|
|
|
assert.throws(
|
|
|
|
() => fs.read(fd, buffer, 0, 1, 0, common.mustNotCall()),
|
|
|
|
{
|
|
|
|
code: 'ERR_INVALID_ARG_VALUE',
|
|
|
|
message: 'The argument \'buffer\' is empty and cannot be written. ' +
|
|
|
|
'Received Uint8Array []'
|
|
|
|
}
|
|
|
|
);
|
2018-10-01 02:03:47 +09:00
|
|
|
|
|
|
|
(async () => {
|
|
|
|
const filehandle = await fsPromises.open(filepath, 'r');
|
|
|
|
assert.rejects(
|
|
|
|
() => filehandle.read(buffer, 0, 1, 0),
|
|
|
|
{
|
|
|
|
code: 'ERR_INVALID_ARG_VALUE',
|
|
|
|
message: 'The argument \'buffer\' is empty and cannot be written. ' +
|
|
|
|
'Received Uint8Array []'
|
|
|
|
}
|
|
|
|
);
|
|
|
|
})();
|