You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have noticed a behaviour that i can not explain thus i am asking this question. To me it seems that the behaviour of append and prepend differs. I would like to explain.
Lets say that i would like to append a buffer of 5 bytes !!!that has zero bytes in it!!! to another one that has a capasity of 20 then it all works as expected i.e. the capasity is not increased and the zero bytes included in the buffer that had the capacity of 5 are also appended correctly.
However if i try to do the same trick with prepend then the capsity is increased but not to the expected one i.e. it is 24 instead of 25 and to me it seems like the zero byte is not prepended correctly.
here is an simple test in type script
import { expect } from 'chai';
import ByteBuffer = require("bytebuffer");
import { PrintUtils } from '../ts/utility/PrintUtils';
describe('Prepends to an existing ByteBuffer some other buffer', () => {
it('should prepends another buffer to an existing one ', () => {
var buffer = new ByteBuffer(20);
PrintUtils.printBuffer(buffer);
var testAppend5bytes = new ByteBuffer(5);
testAppend5bytes.writeInt32(34124356);
// need to flip the buffer before it can be used
testAppend5bytes.flip();
PrintUtils.printBuffer(testAppend5bytes);
buffer.prepend(testAppend5bytes, "binary", 0);
PrintUtils.printBuffer(buffer);
expect(25).to.equal(buffer.capacity());
});
});
The text was updated successfully, but these errors were encountered:
I have noticed a behaviour that i can not explain thus i am asking this question. To me it seems that the behaviour of append and prepend differs. I would like to explain.
Lets say that i would like to append a buffer of 5 bytes !!!that has zero bytes in it!!! to another one that has a capasity of 20 then it all works as expected i.e. the capasity is not increased and the zero bytes included in the buffer that had the capacity of 5 are also appended correctly.
However if i try to do the same trick with prepend then the capsity is increased but not to the expected one i.e. it is 24 instead of 25 and to me it seems like the zero byte is not prepended correctly.
here is an simple test in type script
The text was updated successfully, but these errors were encountered: