1'use strict'; 2 3require('../common'); 4const fixtures = require('../common/fixtures'); 5const fs = require('fs'); 6const assert = require('assert'); 7const filepath = fixtures.path('x.txt'); 8const fd = fs.openSync(filepath, 'r'); 9 10const expected = Buffer.from('xyz\n'); 11 12function runTest(defaultBuffer, options) { 13 const result = fs.readSync(fd, defaultBuffer, options); 14 assert.strictEqual(result, expected.length); 15 assert.deepStrictEqual(defaultBuffer, expected); 16} 17 18// Test passing in an empty options object 19runTest(Buffer.allocUnsafe(expected.length), { position: 0 }); 20 21// Test not passing in any options object 22runTest(Buffer.allocUnsafe(expected.length)); 23 24// Test passing in options 25runTest(Buffer.allocUnsafe(expected.length), { offset: 0, 26 length: expected.length, 27 position: 0 }); 28