node/test/pummel/test-blob-slice-with-large-size.js
Zhenwei Jin bf8afe7644
buffer: remove lines setting indexes to integer value
PR-URL: https://github.com/nodejs/node/pull/52588
Refs: https://github.com/nodejs/node/issues/52585
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2024-05-06 12:45:31 +00:00

22 lines
479 B
JavaScript

'use strict';
const common = require('../common');
// Buffer with size > INT32_MAX
common.skipIf32Bits();
const assert = require('assert');
const size = 2 ** 31;
try {
const buf = Buffer.allocUnsafe(size);
const blob = new Blob([buf]);
const slicedBlob = blob.slice(size - 1, size);
assert.strictEqual(slicedBlob.size, 1);
} catch (e) {
if (e.code !== 'ERR_MEMORY_ALLOCATION_FAILED') {
throw e;
}
common.skip('insufficient space for Buffer.allocUnsafe');
}