2015-05-19 13:00:06 +02:00
|
|
|
'use strict';
|
2016-01-13 21:42:45 +01:00
|
|
|
const common = require('../common');
|
|
|
|
const assert = require('assert');
|
|
|
|
const path = require('path');
|
|
|
|
const fs = require('fs');
|
|
|
|
const filepath = path.join(common.fixturesDir, 'x.txt');
|
|
|
|
const fd = fs.openSync(filepath, 'r');
|
|
|
|
const expected = 'xyz\n';
|
|
|
|
let readCalled = 0;
|
2010-05-20 18:13:22 -04:00
|
|
|
|
|
|
|
fs.read(fd, expected.length, 0, 'utf-8', function(err, str, bytesRead) {
|
|
|
|
readCalled++;
|
|
|
|
|
|
|
|
assert.ok(!err);
|
|
|
|
assert.equal(str, expected);
|
|
|
|
assert.equal(bytesRead, expected.length);
|
|
|
|
});
|
|
|
|
|
|
|
|
var r = fs.readSync(fd, expected.length, 0, 'utf-8');
|
|
|
|
assert.equal(r[0], expected);
|
|
|
|
assert.equal(r[1], expected.length);
|
|
|
|
|
2011-10-15 01:08:36 +02:00
|
|
|
process.on('exit', function() {
|
2010-05-20 18:13:22 -04:00
|
|
|
assert.equal(readCalled, 1);
|
2010-06-23 17:40:51 -07:00
|
|
|
});
|