11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ciconst common = require('../common');
41cb0ef41Sopenharmony_ciconst fixtures = require('../common/fixtures');
51cb0ef41Sopenharmony_ciconst fs = require('fs');
61cb0ef41Sopenharmony_ciconst read = require('util').promisify(fs.read);
71cb0ef41Sopenharmony_ciconst assert = require('assert');
81cb0ef41Sopenharmony_ciconst filepath = fixtures.path('x.txt');
91cb0ef41Sopenharmony_ciconst fd = fs.openSync(filepath, 'r');
101cb0ef41Sopenharmony_ci
111cb0ef41Sopenharmony_ciconst expected = Buffer.from('xyz\n');
121cb0ef41Sopenharmony_ciconst defaultBufferAsync = Buffer.alloc(16384);
131cb0ef41Sopenharmony_ciconst bufferAsOption = Buffer.allocUnsafe(expected.byteLength);
141cb0ef41Sopenharmony_ci
151cb0ef41Sopenharmony_ciread(fd, common.mustNotMutateObjectDeep({}))
161cb0ef41Sopenharmony_ci  .then(function({ bytesRead, buffer }) {
171cb0ef41Sopenharmony_ci    assert.strictEqual(bytesRead, expected.byteLength);
181cb0ef41Sopenharmony_ci    assert.deepStrictEqual(defaultBufferAsync.byteLength, buffer.byteLength);
191cb0ef41Sopenharmony_ci  })
201cb0ef41Sopenharmony_ci  .then(common.mustCall());
211cb0ef41Sopenharmony_ci
221cb0ef41Sopenharmony_ciread(fd, bufferAsOption, common.mustNotMutateObjectDeep({ position: 0 }))
231cb0ef41Sopenharmony_ci  .then(function({ bytesRead, buffer }) {
241cb0ef41Sopenharmony_ci    assert.strictEqual(bytesRead, expected.byteLength);
251cb0ef41Sopenharmony_ci    assert.deepStrictEqual(bufferAsOption.byteLength, buffer.byteLength);
261cb0ef41Sopenharmony_ci  })
271cb0ef41Sopenharmony_ci  .then(common.mustCall());
28