classlib: fix ByteBuffer.putLong implementation

Fix #737
This commit is contained in:
Alexey Andreev 2023-09-05 09:26:22 +02:00
parent 401fcabeae
commit 83ace9bf3e
2 changed files with 16 additions and 4 deletions

View File

@ -486,10 +486,10 @@ class TByteBufferImpl extends TByteBuffer {
array[start + index + 1] = (byte) (value >> 8);
array[start + index + 2] = (byte) (value >> 16);
array[start + index + 3] = (byte) (value >> 24);
array[start + index + 4] = (byte) (value >> 24);
array[start + index + 5] = (byte) (value >> 24);
array[start + index + 6] = (byte) (value >> 24);
array[start + index + 7] = (byte) (value >> 24);
array[start + index + 4] = (byte) (value >> 32);
array[start + index + 5] = (byte) (value >> 40);
array[start + index + 6] = (byte) (value >> 48);
array[start + index + 7] = (byte) (value >> 56);
}
return this;
}

View File

@ -24,6 +24,7 @@ import static org.junit.Assert.fail;
import java.nio.BufferOverflowException;
import java.nio.BufferUnderflowException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.InvalidMarkException;
import java.nio.ReadOnlyBufferException;
import org.junit.Test;
@ -715,6 +716,17 @@ public class ByteBufferTest {
} catch (IndexOutOfBoundsException e) {
// expected
}
buffer = ByteBuffer.wrap(array).order(ByteOrder.LITTLE_ENDIAN);
buffer.putLong(1, 0x2324252627282930L);
assertThat(buffer.get(1), is((byte) 0x30));
assertThat(buffer.get(2), is((byte) 0x29));
assertThat(buffer.get(3), is((byte) 0x28));
assertThat(buffer.get(4), is((byte) 0x27));
assertThat(buffer.get(5), is((byte) 0x26));
assertThat(buffer.get(6), is((byte) 0x25));
assertThat(buffer.get(7), is((byte) 0x24));
assertThat(buffer.get(8), is((byte) 0x23));
}
@Test