From bf18ed8b9c17fa4840d0be550e0143b9ccb80196 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Fri, 20 Jan 2017 21:41:23 -0800 Subject: [PATCH] test,zlib: check string strategies The Zlib constructor accepts strategy constants that are integers. Current code will also work with string versions of those integers. Add test for this situation. Fixes: https://github.com/nodejs/node/issues/10932 --- test/parallel/test-zlib-deflate-constructors.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/parallel/test-zlib-deflate-constructors.js b/test/parallel/test-zlib-deflate-constructors.js index 2f23dc595ec0b0..a235ef45bd0d4f 100644 --- a/test/parallel/test-zlib-deflate-constructors.js +++ b/test/parallel/test-zlib-deflate-constructors.js @@ -83,7 +83,12 @@ assert.doesNotThrow( ); assert.doesNotThrow( - () => { new zlib.Deflate({ strategy: zlib.constants.Z_DEFAULT_STRATEGY}); } + () => { new zlib.Deflate({strategy: zlib.constants.Z_DEFAULT_STRATEGY}); } +); + +// Valid strategies are integer values. Accepts equivalent string value too. +assert.doesNotThrow( + () => { new zlib.Deflate({strategy: '' + zlib.constants.Z_RLE}); } ); // Throws if opts.strategy is invalid