Skip to content

Commit 922c457

Browse files
lucamaraschievanlucas
authored andcommitted
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. PR-URL: #12355 Reviewed-By: Vse Mozhet Byt <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]>
1 parent db585c9 commit 922c457

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
'use strict';
2+
const common = require('../common');
3+
4+
// This test ensures that writeSync does support inputs which
5+
// are then correctly converted into string buffers.
6+
7+
const assert = require('assert');
8+
const fs = require('fs');
9+
const path = require('path');
10+
11+
const filePath = path.join(common.tmpDir, 'test_buffer_type');
12+
const v = [true, false, 0, 1, Infinity, common.noop, {}, [], undefined, null];
13+
14+
common.refreshTmpDir();
15+
16+
v.forEach((value) => {
17+
const fd = fs.openSync(filePath, 'w');
18+
fs.writeSync(fd, value);
19+
assert.strictEqual(fs.readFileSync(filePath).toString(), value + '');
20+
});

0 commit comments

Comments
 (0)