You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

32 lines
763 B

require('../common');
var path = require('path'),
Buffer = require('buffer').Buffer,
fs = require('fs'),
filename = path.join(fixturesDir, 'write.txt'),
expected = new Buffer('hello'),
openCalled = 0,
writeCalled = 0;
fs.open(filename, 'w', 0644, function (err, fd) {
openCalled++;
if (err) throw err;
fs.write(fd, expected, 0, expected.length, null, function(err, written) {
writeCalled++;
if (err) throw err;
assert.equal(expected.length, written);
fs.closeSync(fd);
var found = fs.readFileSync(filename);
assert.deepEqual(expected.toString(), found);
fs.unlinkSync(filename);
});
});
process.addListener("exit", function () {
assert.equal(1, openCalled);
assert.equal(1, writeCalled);
});