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.

24 lines
528 B

'use strict';
14 years ago
var common = require('../common');
var assert = require('assert');
var path = require('path');
var fs = require('fs');
var fn = path.join(common.tmpDir, 'write.txt');
common.refreshTmpDir();
var foo = 'foo';
var fd = fs.openSync(fn, 'w');
14 years ago
var written = fs.writeSync(fd, '');
assert.strictEqual(0, written);
fs.writeSync(fd, foo);
var 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');