GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test: skip in test-buffer-tostring-rangeerror on allocation failure · nodejs/node@4c445a8

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • test/parallel
    • test-buffer-tostring-rangeerror.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎test/parallel/test-buffer-tostring-rangeerror.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-buffer-tostring-rangeerror.js
+19-5Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,22 @@ const message = {
2323
code: 'ERR_STRING_TOO_LONG',
2424
name: 'Error',
2525
};
26-
assert.throws(() => Buffer(len).toString('utf8'), message);
27-
assert.throws(() => SlowBuffer(len).toString('utf8'), message);
28-
assert.throws(() => Buffer.alloc(len).toString('utf8'), message);
29-
assert.throws(() => Buffer.allocUnsafe(len).toString('utf8'), message);
30-
assert.throws(() => Buffer.allocUnsafeSlow(len).toString('utf8'), message);
26+
27+
function 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+
40+
test(() => Buffer(len));
41+
test(() => SlowBuffer(len));
42+
test(() => Buffer.alloc(len));
43+
test(() => Buffer.allocUnsafe(len));
44+
test(() => Buffer.allocUnsafeSlow(len));

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.