diff options
author | James M Snell <jasnell@gmail.com> | 2016-08-23 14:16:45 -0700 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2016-08-26 07:15:31 -0700 |
commit | 7053922c1a76ac56ef245923ec171b01cd90d2f4 (patch) | |
tree | 0464984232c835fe6e1d3ac2b429bdaaf77a6cbe /test/parallel/test-buffer-no-negative-allocation.js | |
parent | b3e7ac2605c18c041293cd3ab892c963e1145176 (diff) | |
download | node-new-7053922c1a76ac56ef245923ec171b01cd90d2f4.tar.gz |
test: clean up / refactor buffer tests, remove duplication
Remove duplication of buffer tests, separate out into separate
files, update and cleanup code, move to using strictEqual where
possible.
PR-URL: https://github.com/nodejs/node/pull/8256
Reviewed-By: Michaƫl Zasso <mic.besace@gmail.com>
Diffstat (limited to 'test/parallel/test-buffer-no-negative-allocation.js')
-rw-r--r-- | test/parallel/test-buffer-no-negative-allocation.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/parallel/test-buffer-no-negative-allocation.js b/test/parallel/test-buffer-no-negative-allocation.js new file mode 100644 index 0000000000..588a7d49f7 --- /dev/null +++ b/test/parallel/test-buffer-no-negative-allocation.js @@ -0,0 +1,24 @@ +'use strict'; + +require('../common'); +const assert = require('assert'); + +const msg = /"size" argument must not be negative/; + +// Test that negative Buffer length inputs throw errors. + +assert.throws(() => Buffer(-Buffer.poolSize), msg); +assert.throws(() => Buffer(-100), msg); +assert.throws(() => Buffer(-1), msg); + +assert.throws(() => Buffer.alloc(-Buffer.poolSize), msg); +assert.throws(() => Buffer.alloc(-100), msg); +assert.throws(() => Buffer.alloc(-1), msg); + +assert.throws(() => Buffer.allocUnsafe(-Buffer.poolSize), msg); +assert.throws(() => Buffer.allocUnsafe(-100), msg); +assert.throws(() => Buffer.allocUnsafe(-1), msg); + +assert.throws(() => Buffer.allocUnsafeSlow(-Buffer.poolSize), msg); +assert.throws(() => Buffer.allocUnsafeSlow(-100), msg); +assert.throws(() => Buffer.allocUnsafeSlow(-1), msg); |