11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_cirequire('../common');
41cb0ef41Sopenharmony_ciconst assert = require('assert');
51cb0ef41Sopenharmony_ciconst zlib = require('zlib');
61cb0ef41Sopenharmony_ci
71cb0ef41Sopenharmony_ci
81cb0ef41Sopenharmony_ci// windowBits is a special case in zlib. On the compression side, 0 is invalid.
91cb0ef41Sopenharmony_ci// On the decompression side, it indicates that zlib should use the value from
101cb0ef41Sopenharmony_ci// the header of the compressed stream.
111cb0ef41Sopenharmony_ci{
121cb0ef41Sopenharmony_ci  const inflate = zlib.createInflate({ windowBits: 0 });
131cb0ef41Sopenharmony_ci  assert(inflate instanceof zlib.Inflate);
141cb0ef41Sopenharmony_ci}
151cb0ef41Sopenharmony_ci
161cb0ef41Sopenharmony_ci{
171cb0ef41Sopenharmony_ci  const gunzip = zlib.createGunzip({ windowBits: 0 });
181cb0ef41Sopenharmony_ci  assert(gunzip instanceof zlib.Gunzip);
191cb0ef41Sopenharmony_ci}
201cb0ef41Sopenharmony_ci
211cb0ef41Sopenharmony_ci{
221cb0ef41Sopenharmony_ci  const unzip = zlib.createUnzip({ windowBits: 0 });
231cb0ef41Sopenharmony_ci  assert(unzip instanceof zlib.Unzip);
241cb0ef41Sopenharmony_ci}
251cb0ef41Sopenharmony_ci
261cb0ef41Sopenharmony_ci{
271cb0ef41Sopenharmony_ci  assert.throws(() => zlib.createGzip({ windowBits: 0 }), {
281cb0ef41Sopenharmony_ci    code: 'ERR_OUT_OF_RANGE',
291cb0ef41Sopenharmony_ci    name: 'RangeError',
301cb0ef41Sopenharmony_ci    message: 'The value of "options.windowBits" is out of range. ' +
311cb0ef41Sopenharmony_ci             'It must be >= 9 and <= 15. Received 0'
321cb0ef41Sopenharmony_ci  });
331cb0ef41Sopenharmony_ci}
34