0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/simple/test-fs-write-sync.js

23 lines
484 B
JavaScript
Raw Normal View History

common = require("../common");
assert = common.assert
2010-06-10 23:59:06 +02:00
path = require('path'),
Buffer = require('buffer').Buffer
fs = require('fs')
2010-10-22 19:02:30 +02:00
fn = path.join(common.tmpDir, 'write.txt');
2010-06-10 23:59:06 +02:00
foo = 'foo'
var fd = fs.openSync(fn, 'w');
2010-08-17 06:10:49 +02:00
written = fs.writeSync(fd, '');
assert.strictEqual(0, written);
2010-06-10 23:59:06 +02:00
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);
2010-06-10 23:59:06 +02:00
assert.equal(fs.readFileSync(fn), 'foobár');