Skip to content

Commit 4786ad7

Browse 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 <[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 9881da1 commit 4786ad7

File tree

1 file changed

+20
-0
lines changed

1 file changed

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

0 commit comments

Comments
(0)