Closed
Description
- Version: v6.7.0
- Platform: Linux 3.13.0-96-generic Ubuntu SMP x86_64 GNU/Linux
- Subsystem: NodeBuffer
It seems if one provides a non integer boundary to the slice function then the later slice calls on the same buffer provide wrong chunks.
Test case to reproduce
it("Should slice Buffer", () => {
let original = new Buffer("1234567890ABCDEFG", "ascii");
let chunk1 = original.slice(0, original.length / 3);
let chunk2 = original.slice(original.length / 3);
let result = Buffer.concat([chunk2, chunk1]);
expect(result).to.be.eqls(original);
});
And the result is:
AssertionError: expected
|Buffer 31 32 33 34 35 36 37 38 39 30 41 42 43 44 45 46| to deeply equal |Buffer 31 32 33 34 35 36 37 38 39 30 41 42 43 44 45 46 `**47**`|
In this test case the result buffer misses the last byte from the original one.
I am not exactly sure what should be the correct behavior but I would be fine either with throwing an exception or round/ceil/floor the provided boundary value.