node/test/parallel/test-fs-read-zero-length.js
abouthiroppy d86ff5fc29 test: refactor test-fs-read-zero-length.js
PR-URL: https://github.com/nodejs/node/pull/10729
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2017-01-17 12:34:58 -05:00

20 lines
649 B
JavaScript

'use strict';
const common = require('../common');
const assert = require('assert');
const path = require('path');
const Buffer = require('buffer').Buffer;
const fs = require('fs');
const filepath = path.join(common.fixturesDir, 'x.txt');
const fd = fs.openSync(filepath, 'r');
const bufferAsync = Buffer.alloc(0);
const bufferSync = Buffer.alloc(0);
fs.read(fd, bufferAsync, 0, 0, 0, common.mustCall((err, bytesRead) => {
assert.strictEqual(bytesRead, 0);
assert.deepStrictEqual(bufferAsync, Buffer.alloc(0));
}));
const r = fs.readSync(fd, bufferSync, 0, 0, 0);
assert.deepStrictEqual(bufferSync, Buffer.alloc(0));
assert.strictEqual(r, 0);