2010-12-05 00:20:34 +01:00
|
|
|
var common = require('../common');
|
|
|
|
var assert = require('assert');
|
2010-05-21 00:13:22 +02:00
|
|
|
var path = require('path'),
|
|
|
|
fs = require('fs'),
|
2010-07-15 20:47:25 +02:00
|
|
|
filepath = path.join(common.fixturesDir, 'x.txt'),
|
2010-05-21 00:13:22 +02:00
|
|
|
fd = fs.openSync(filepath, 'r'),
|
|
|
|
expected = 'xyz\n',
|
|
|
|
readCalled = 0;
|
|
|
|
|
|
|
|
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-21 00:13:22 +02:00
|
|
|
assert.equal(readCalled, 1);
|
2010-06-24 02:40:51 +02:00
|
|
|
});
|