Skip to content

Commit

Permalink
test: error when empty buffer is passed to fs.read()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
shisama authored and danbev committed Oct 3, 2018
1 parent 1bfd035 commit 097896b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test/parallel/test-fs-read-empty-buffer.js
Original file line number Diff line number Diff line change
@@ -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');
Expand All @@ -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 []'
}
);

0 comments on commit 097896b

Please sign in to comment.