Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
test: buffer should always be stringified
This test makes sure that independently of the buffer type, the input
is always stringified and generates a valid input.
  • Loading branch information
lucamaraschi committed Apr 13, 2017
commit 38c76eedb85c0f705c37b2fb917576adc6c82761
20 changes: 20 additions & 0 deletions test/parallel/test-fs-buffertype-writesync.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'use strict';
const common = require('../common');

// 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');

const filePath = path.join(common.tmpDir, 'test_buffer_type');
const v = [true, false, 0, 1, Infinity, common.noop, {}, [], undefined, null];

common.refreshTmpDir();

v.forEach((value) => {
const fd = fs.openSync(filePath, 'w');
fs.writeSync(fd, value);
assert.strictEqual(fs.readFileSync(filePath).toString(), value + '');
});