Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4786ad7

Browse filesBrowse files
lucamaraschiMylesBorins
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 <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>
1 parent 9881da1 commit 4786ad7
Copy full SHA for 4786ad7

File tree

Expand file treeCollapse file tree

1 file changed

+20
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+20
-0
lines changed
Open diff view settings
Collapse file
+20Lines changed: 20 additions & 0 deletions
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.