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.
23 lines
559 B
23 lines
559 B
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const path = require('path');
|
|
const fs = require('fs');
|
|
const fn = path.join(common.tmpDir, 'write.txt');
|
|
|
|
common.refreshTmpDir();
|
|
|
|
const foo = 'foo';
|
|
const fd = fs.openSync(fn, 'w');
|
|
|
|
let written = fs.writeSync(fd, '');
|
|
assert.strictEqual(0, written);
|
|
|
|
fs.writeSync(fd, foo);
|
|
|
|
const bar = 'bár';
|
|
written = fs.writeSync(fd, Buffer.from(bar), 0, Buffer.byteLength(bar));
|
|
assert.ok(written > 3);
|
|
fs.closeSync(fd);
|
|
|
|
assert.strictEqual(fs.readFileSync(fn, 'utf8'), 'foobár');
|
|
|