Skip to content

Commit a29631b

Browse files
shisamajasnell
shisama
authored andcommitted
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: #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>
1 parent 59feb53 commit a29631b

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

test/parallel/test-fs-read-empty-buffer.js

+10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use strict';
22
require('../common');
3+
const common = require('../common');
34
const fixtures = require('../common/fixtures');
45
const assert = require('assert');
56
const fs = require('fs');
@@ -16,3 +17,12 @@ assert.throws(
1617
'Received Uint8Array []'
1718
}
1819
);
20+
21+
assert.throws(
22+
() => fs.read(fd, buffer, 0, 1, 0, common.mustNotCall()),
23+
{
24+
code: 'ERR_INVALID_ARG_VALUE',
25+
message: 'The argument \'buffer\' is empty and cannot be written. ' +
26+
'Received Uint8Array []'
27+
}
28+
);

0 commit comments

Comments
 (0)