Skip to content

Commit

Permalink
test: buffer should always be stringified
Browse files Browse the repository at this point in the history
This test makes sure that independently of the buffer type, the input
is always stringified and generates a valid input.

PR-URL: #12355
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
  • Loading branch information
lucamaraschi authored and evanlucas committed May 2, 2017
1 parent db585c9 commit 922c457
Showing 1 changed file with 20 additions and 0 deletions.
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 + '');
});

0 comments on commit 922c457

Please sign in to comment.