diff options
author | Timothy Gu <timothygu99@gmail.com> | 2017-04-03 18:15:13 -0700 |
---|---|---|
committer | Timothy Gu <timothygu99@gmail.com> | 2017-04-12 10:03:26 -0700 |
commit | 2ced07ccaf7682b9ec8fb3bcc3dc8d2bb2798c61 (patch) | |
tree | 31245a1e2025264acf2216876c9e190addd44287 /test/parallel/test-zlib-convenience-methods.js | |
parent | a8f460f12d81f63d95b3f1bc12a89e36cae2b271 (diff) | |
download | node-new-2ced07ccaf7682b9ec8fb3bcc3dc8d2bb2798c61.tar.gz |
zlib: support all ArrayBufferView types
PR-URL: https://github.com/nodejs/node/pull/12223
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'test/parallel/test-zlib-convenience-methods.js')
-rw-r--r-- | test/parallel/test-zlib-convenience-methods.js | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/test/parallel/test-zlib-convenience-methods.js b/test/parallel/test-zlib-convenience-methods.js index df56f21ff4..78bb105906 100644 --- a/test/parallel/test-zlib-convenience-methods.js +++ b/test/parallel/test-zlib-convenience-methods.js @@ -26,24 +26,28 @@ const common = require('../common'); const assert = require('assert'); const zlib = require('zlib'); -const expectStr = 'blahblahblahblahblahblah'; +// Must be a multiple of 4 characters in total to test all ArrayBufferView +// types. +const expectStr = 'blah'.repeat(8); const expectBuf = Buffer.from(expectStr); -const expectUint8Array = new Uint8Array(expectBuf); + const opts = { level: 9, chunkSize: 1024, }; -for (const method of [ - ['gzip', 'gunzip'], - ['gzip', 'unzip'], - ['deflate', 'inflate'], - ['deflateRaw', 'inflateRaw'], +for (const [type, expect] of [ + ['string', expectStr], + ['Buffer', expectBuf], + ...common.getArrayBufferViews(expectBuf).map((obj) => + [obj[Symbol.toStringTag], obj] + ) ]) { - for (const [type, expect] of [ - ['string', expectStr], - ['Buffer', expectBuf], - ['Uint8Array', expectUint8Array] + for (const method of [ + ['gzip', 'gunzip'], + ['gzip', 'unzip'], + ['deflate', 'inflate'], + ['deflateRaw', 'inflateRaw'], ]) { zlib[method[0]](expect, opts, common.mustCall((err, result) => { zlib[method[1]](result, opts, common.mustCall((err, result) => { |