Leb128UtilsTestpublic final class Leb128UtilsTest extends TestCase
Methods Summary |
---|
private void | assertEquals(byte[] expected, byte[] actual)
assertTrue(Arrays.toString(actual), Arrays.equals(expected, actual));
| private byte[] | encodeSignedLeb(int value)
ByteArrayAnnotatedOutput out = new ByteArrayAnnotatedOutput(5);
Leb128.writeSignedLeb128(out, value);
return out.toByteArray();
| private byte[] | encodeUnsignedLeb(int value)
ByteArrayAnnotatedOutput out = new ByteArrayAnnotatedOutput(5);
Leb128.writeUnsignedLeb128(out, value);
return out.toByteArray();
| public void | testDecodeSignedLeb()
assertEquals(0, Leb128.readSignedLeb128(new ByteArrayByteInput((byte) 0)));
assertEquals(1, Leb128.readSignedLeb128(new ByteArrayByteInput((byte) 1)));
assertEquals(-1, Leb128.readSignedLeb128(new ByteArrayByteInput((byte) 0x7f)));
assertEquals(0x3c, Leb128.readSignedLeb128(new ByteArrayByteInput((byte) 0x3c)));
assertEquals(-128, Leb128.readSignedLeb128(
new ByteArrayByteInput((byte) 0x80, (byte) 0x7f)));
| public void | testDecodeUnsignedLeb()
assertEquals(0, Leb128.readUnsignedLeb128(new ByteArrayByteInput((byte) 0)));
assertEquals(1, Leb128.readUnsignedLeb128(new ByteArrayByteInput((byte) 1)));
assertEquals(127, Leb128.readUnsignedLeb128(new ByteArrayByteInput((byte) 0x7f)));
assertEquals(16256, Leb128.readUnsignedLeb128(
new ByteArrayByteInput((byte) 0x80, (byte) 0x7f)));
| public void | testEncodeSignedLeb()
assertEquals(new byte[] { 0 }, encodeSignedLeb(0));
assertEquals(new byte[] { 1 }, encodeSignedLeb(1));
assertEquals(new byte[] { 0x7f }, encodeSignedLeb(-1));
assertEquals(new byte[] { (byte) 0x80, 0x7f }, encodeSignedLeb(-128));
| public void | testEncodeUnsignedLeb()
assertEquals(new byte[] { 0 }, encodeUnsignedLeb(0));
assertEquals(new byte[] { 1 }, encodeUnsignedLeb(1));
assertEquals(new byte[] { 0x7f }, encodeUnsignedLeb(127));
assertEquals(new byte[] { (byte) 0x80, 0x7f }, encodeUnsignedLeb(16256));
assertEquals(new byte[] { (byte) 0xb4, 0x07 }, encodeUnsignedLeb(0x3b4));
assertEquals(new byte[] { (byte) 0x8c, 0x08 }, encodeUnsignedLeb(0x40c));
assertEquals(new byte[] { (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, 0xf },
encodeUnsignedLeb(0xffffffff));
|
|