summaryrefslogtreecommitdiff
path: root/tests/node_compat/test/parallel/test-buffer-tostring-rangeerror.js
diff options
context:
space:
mode:
Diffstat (limited to 'tests/node_compat/test/parallel/test-buffer-tostring-rangeerror.js')
-rw-r--r--tests/node_compat/test/parallel/test-buffer-tostring-rangeerror.js18
1 files changed, 11 insertions, 7 deletions
diff --git a/tests/node_compat/test/parallel/test-buffer-tostring-rangeerror.js b/tests/node_compat/test/parallel/test-buffer-tostring-rangeerror.js
index dbc69747e..9ec11056c 100644
--- a/tests/node_compat/test/parallel/test-buffer-tostring-rangeerror.js
+++ b/tests/node_compat/test/parallel/test-buffer-tostring-rangeerror.js
@@ -8,18 +8,22 @@
'use strict';
require('../common');
-// This test ensures that Node.js throws a RangeError when trying to convert a
-// gigantic buffer into a string.
+// This test ensures that Node.js throws an Error when trying to convert a
+// large buffer into a string.
// Regression test for https://github.com/nodejs/node/issues/649.
const assert = require('assert');
-const SlowBuffer = require('buffer').SlowBuffer;
+const {
+ SlowBuffer,
+ constants: {
+ MAX_STRING_LENGTH,
+ },
+} = require('buffer');
-const len = 1422561062959;
+const len = MAX_STRING_LENGTH + 1;
const message = {
- code: 'ERR_INVALID_ARG_VALUE',
- name: 'RangeError',
- message: /^The argument 'size' is invalid\. Received [^"]*$/
+ code: 'ERR_STRING_TOO_LONG',
+ name: 'Error',
};
assert.throws(() => Buffer(len).toString('utf8'), message);
assert.throws(() => SlowBuffer(len).toString('utf8'), message);