Browse Source

test: add assertions to zero length buffer test

1) Add missing assertion that slicing a 0 length buffer does not throw
2) Add assertion that slicing a 0 length buffer has a length of 0

PR-URL: https://github.com/nodejs/node/pull/8729
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
v6.x
Lauren Spiegel 8 years ago
committed by Jeremiah Senkpiel
parent
commit
81ed50c5da
  1. 3
      test/parallel/test-buffer-slice.js

3
test/parallel/test-buffer-slice.js

@ -52,7 +52,8 @@ assert.equal(buf.slice('0', '-111'), '');
// try to slice a zero length Buffer
// see https://github.com/joyent/node/issues/5881
Buffer.alloc(0).slice(0, 1);
assert.doesNotThrow(() => Buffer.alloc(0).slice(0, 1));
assert.strictEqual(Buffer.alloc(0).slice(0, 1).length, 0);
{
// Single argument slice

Loading…
Cancel
Save