mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
23 lines
489 B
JavaScript
23 lines
489 B
JavaScript
common = require("../common");
|
|
assert = common.assert
|
|
path = require('path'),
|
|
Buffer = require('buffer').Buffer
|
|
fs = require('fs')
|
|
fn = path.join(common.fixturesDir, 'write.txt');
|
|
|
|
|
|
foo = 'foo'
|
|
var fd = fs.openSync(fn, 'w');
|
|
|
|
written = fs.writeSync(fd, '');
|
|
assert.strictEqual(0, written);
|
|
|
|
fs.writeSync(fd, foo);
|
|
|
|
bar = 'bár'
|
|
written = fs.writeSync(fd, new Buffer(bar), 0, Buffer.byteLength(bar));
|
|
assert.ok(written > 3);
|
|
fs.closeSync(fd);
|
|
|
|
assert.equal(fs.readFileSync(fn), 'foobár');
|