11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_cirequire('../common'); 31cb0ef41Sopenharmony_ci 41cb0ef41Sopenharmony_ci// This test ensures that Node.js throws a RangeError when trying to convert a 51cb0ef41Sopenharmony_ci// gigantic buffer into a string. 61cb0ef41Sopenharmony_ci// Regression test for https://github.com/nodejs/node/issues/649. 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_ciconst assert = require('assert'); 91cb0ef41Sopenharmony_ciconst SlowBuffer = require('buffer').SlowBuffer; 101cb0ef41Sopenharmony_ci 111cb0ef41Sopenharmony_ciconst len = 1422561062959; 121cb0ef41Sopenharmony_ciconst message = { 131cb0ef41Sopenharmony_ci code: 'ERR_INVALID_ARG_VALUE', 141cb0ef41Sopenharmony_ci name: 'RangeError', 151cb0ef41Sopenharmony_ci message: /^The argument 'size' is invalid\. Received [^"]*$/ 161cb0ef41Sopenharmony_ci}; 171cb0ef41Sopenharmony_ciassert.throws(() => Buffer(len).toString('utf8'), message); 181cb0ef41Sopenharmony_ciassert.throws(() => SlowBuffer(len).toString('utf8'), message); 191cb0ef41Sopenharmony_ciassert.throws(() => Buffer.alloc(len).toString('utf8'), message); 201cb0ef41Sopenharmony_ciassert.throws(() => Buffer.allocUnsafe(len).toString('utf8'), message); 211cb0ef41Sopenharmony_ciassert.throws(() => Buffer.allocUnsafeSlow(len).toString('utf8'), message); 22