From 3bf28b1b7b5bb0847e25aee27582bc1e05c55c65 Mon Sep 17 00:00:00 2001 From: shisama Date: Fri, 28 Sep 2018 14:50:04 +0900 Subject: [PATCH] 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. --- test/parallel/test-fs-read-empty-buffer.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/parallel/test-fs-read-empty-buffer.js b/test/parallel/test-fs-read-empty-buffer.js index 840e52d60c7a97..34e418eac656bf 100644 --- a/test/parallel/test-fs-read-empty-buffer.js +++ b/test/parallel/test-fs-read-empty-buffer.js @@ -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 []' + } +);