MCPcopy Index your code
hub / github.com/nodejs/node / test

Function test

test/parallel/test-buffer-tostring-rangeerror.js:27–38  ·  view source on GitHub ↗
(getBuffer)

Source from the content-addressed store, hash-verified

25};
26
27function test(getBuffer) {
28 let buf;
29 try {
30 buf = getBuffer();
31 } catch (e) {
32 // If the buffer allocation fails, we skip the test.
33 if (e.code === 'ERR_MEMORY_ALLOCATION_FAILED' || /Array buffer allocation failed/.test(e.message)) {
34 return;
35 }
36 }
37 assert.throws(() => { buf.toString('utf8'); }, message);
38}
39
40test(() => Buffer(len));
41test(() => Buffer.alloc(len));

Calls 2

testMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…