2017-04-12 09:34:27 +02:00
|
|
|
'use strict';
|
2017-12-24 22:38:11 -08:00
|
|
|
require('../common');
|
2017-04-12 09:34:27 +02:00
|
|
|
|
|
|
|
// This test ensures that writeSync does support inputs which
|
|
|
|
// are then correctly converted into string buffers.
|
|
|
|
|
|
|
|
const assert = require('assert');
|
|
|
|
const fs = require('fs');
|
|
|
|
const path = require('path');
|
|
|
|
|
2017-12-24 22:38:11 -08:00
|
|
|
const tmpdir = require('../common/tmpdir');
|
|
|
|
|
|
|
|
const filePath = path.join(tmpdir.path, 'test_buffer_type');
|
2017-05-03 21:07:54 -07:00
|
|
|
const v = [true, false, 0, 1, Infinity, () => {}, {}, [], undefined, null];
|
2017-04-12 09:34:27 +02:00
|
|
|
|
2017-12-24 22:38:11 -08:00
|
|
|
tmpdir.refresh();
|
2017-04-12 09:34:27 +02:00
|
|
|
|
|
|
|
v.forEach((value) => {
|
|
|
|
const fd = fs.openSync(filePath, 'w');
|
|
|
|
fs.writeSync(fd, value);
|
2017-04-28 04:06:42 +03:00
|
|
|
assert.strictEqual(fs.readFileSync(filePath).toString(), String(value));
|
2019-07-30 07:50:21 +01:00
|
|
|
fs.closeSync(fd);
|
2017-04-12 09:34:27 +02:00
|
|
|
});
|