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>
This commit is contained in:
Lauren Spiegel 2016-09-22 20:13:00 -07:00 committed by James M Snell
parent 289d862c6f
commit 927661f8ac

View File

@ -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