mirror of https://github.com/lukechilds/node.git
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.
22 lines
490 B
22 lines
490 B
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');
|
||
15 years ago
|
|
||
15 years ago
|
|
||
14 years ago
|
var foo = 'foo';
|
||
15 years ago
|
var fd = fs.openSync(fn, 'w');
|
||
15 years ago
|
|
||
14 years ago
|
var written = fs.writeSync(fd, '');
|
||
15 years ago
|
assert.strictEqual(0, written);
|
||
|
|
||
15 years ago
|
fs.writeSync(fd, foo);
|
||
|
|
||
14 years ago
|
var bar = 'bár';
|
||
15 years ago
|
written = fs.writeSync(fd, new Buffer(bar), 0, Buffer.byteLength(bar));
|
||
|
assert.ok(written > 3);
|
||
15 years ago
|
fs.closeSync(fd);
|
||
|
|
||
15 years ago
|
assert.equal(fs.readFileSync(fn), 'foobár');
|