mirror of
https://github.com/nodejs/node.git
synced 2026-11-25 23:01:06 -05:00
PR-URL: https://github.com/nodejs/node/pull/16114 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
23 lines
665 B
JavaScript
23 lines
665 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const fixtures = require('../common/fixtures');
|
|
const assert = require('assert');
|
|
const fs = require('fs');
|
|
const filepath = fixtures.path('x.txt');
|
|
const fd = fs.openSync(filepath, 'r');
|
|
const expected = 'xyz\n';
|
|
|
|
fs.read(fd,
|
|
expected.length,
|
|
0,
|
|
'utf-8',
|
|
common.mustCall((err, str, bytesRead) => {
|
|
assert.ifError(err);
|
|
assert.strictEqual(str, expected);
|
|
assert.strictEqual(bytesRead, expected.length);
|
|
}));
|
|
|
|
const r = fs.readSync(fd, expected.length, 0, 'utf-8');
|
|
assert.strictEqual(r[0], expected);
|
|
assert.strictEqual(r[1], expected.length);
|