fix bug in short to int conversion in StructPointer
This commit is contained in:
parent
c1cb55e277
commit
57dec34d2c
2 changed files with 22 additions and 1 deletions
|
@ -34,7 +34,7 @@ final class StructPointer{
|
|||
}
|
||||
|
||||
public static int wordSize(long ref) {
|
||||
return (int)dataSize(ref) + (int)ptrCount(ref);
|
||||
return Short.toUnsignedInt(dataSize(ref)) + Short.toUnsignedInt(ptrCount(ref));
|
||||
}
|
||||
|
||||
public static void setFromStructSize(ByteBuffer buffer, int offset, StructSize size) {
|
||||
|
|
21
runtime/src/test/java/org/capnproto/StructPointerTest.java
Normal file
21
runtime/src/test/java/org/capnproto/StructPointerTest.java
Normal file
|
@ -0,0 +1,21 @@
|
|||
package org.capnproto;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class StructPointerTest {
|
||||
|
||||
@Test
|
||||
public void testWordSize() {
|
||||
Assert.assertEquals(
|
||||
3,
|
||||
StructPointer.wordSize(0x0001000200000000L));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWordSizeUnderflow() {
|
||||
Assert.assertEquals(
|
||||
0x1fffe,
|
||||
StructPointer.wordSize(0xffffffff00000000L));
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue