mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 05:38:47 +02:00

This commits reverts da69d13623
PR-URL: https://github.com/nodejs/node/pull/58220
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: LiviaMedeiros <livia@cirno.name>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
30 lines
884 B
JavaScript
30 lines
884 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
|
|
// 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.
|
|
|
|
if (!common.enoughTestMem) {
|
|
common.skip('skipped due to memory requirements');
|
|
}
|
|
|
|
const assert = require('assert');
|
|
const {
|
|
Buffer,
|
|
constants: {
|
|
MAX_STRING_LENGTH,
|
|
},
|
|
} = require('buffer');
|
|
|
|
const len = MAX_STRING_LENGTH + 1;
|
|
const message = {
|
|
code: 'ERR_STRING_TOO_LONG',
|
|
name: 'Error',
|
|
};
|
|
assert.throws(() => Buffer(len).toString('utf8'), message);
|
|
assert.throws(() => Buffer.allocUnsafeSlow(len).toString('utf8'), message);
|
|
assert.throws(() => Buffer.alloc(len).toString('utf8'), message);
|
|
assert.throws(() => Buffer.allocUnsafe(len).toString('utf8'), message);
|
|
assert.throws(() => Buffer.allocUnsafeSlow(len).toString('utf8'), message);
|