test: error when empty buffer is passed to fs.read()

Added tests to occur error when empty buffer is passed to fs.read()
to increase coverage.

PR-URL: https://github.com/nodejs/node/pull/23141
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
shisama 2018-09-28 14:50:04 +09:00 committed by Daniel Bevenius
parent 1bfd03565b
commit 097896bafe

View File

@ -1,5 +1,6 @@
'use strict';
require('../common');
const common = require('../common');
const fixtures = require('../common/fixtures');
const assert = require('assert');
const fs = require('fs');
@ -16,3 +17,12 @@ assert.throws(
'Received Uint8Array []'
}
);
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 []'
}
);