node/test/parallel/test-zlib-maxOutputLength.js
Antoine du Hamel 761d4f45af
test: ensure assertions are reached on more tests
PR-URL: https://github.com/nodejs/node/pull/60500
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Zijian Liu <lxxyxzj@gmail.com>
2025-11-06 08:41:55 +00:00

23 lines
633 B
JavaScript

'use strict';
const common = require('../common');
const assert = require('assert');
const zlib = require('zlib');
const encoded = Buffer.from('G38A+CXCIrFAIAM=', 'base64');
// Async
zlib.brotliDecompress(encoded, { maxOutputLength: 64 }, common.expectsError({
code: 'ERR_BUFFER_TOO_LARGE',
message: 'Cannot create a Buffer larger than 64 bytes'
}));
// Sync
assert.throws(function() {
zlib.brotliDecompressSync(encoded, { maxOutputLength: 64 });
}, RangeError);
// Async
zlib.brotliDecompress(encoded, { maxOutputLength: 256 }, common.mustSucceed());
// Sync
zlib.brotliDecompressSync(encoded, { maxOutputLength: 256 });