public long readLong() { int o = offset; long result = dexBuf.readLong(offset); offset = o + 8; return result; }
public long readLong() { int o = offset; long result = dexBuf.readLong(offset); offset = o + 8; return result; }
public long readLong() { int o = offset; long result = dexBuf.readLong(offset); offset = o + 8; return result; }
public long readLong(int offset) { return dexBuf.readLong(offset); }
public long readLong(int offset) { return dexBuf.readLong(offset); } public int readInt(int offset) { return dexBuf.readInt(offset); }
public long readLong(int offset) { return dexBuf.readLong(offset); } public int readInt(int offset) { return dexBuf.readInt(offset); }
@Test public void testReadLongRandom() { Random r = new Random(1234567890); ByteBuffer byteBuf = ByteBuffer.allocateDirect(8).order(ByteOrder.LITTLE_ENDIAN); byte[] buf = new byte[8]; BaseDexBuffer dexBuf = new BaseDexBuffer(buf); for (int i=0; i<10000; i++) { int val = r.nextInt(); byteBuf.putLong(0, val); byteBuf.position(0); byteBuf.get(buf); Assert.assertEquals(val, dexBuf.readLong(0)); } } }
@Test public void testReadLong() { BaseDexBuffer dexBuf = new BaseDexBuffer(new byte[] {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77}); Assert.assertEquals(0x7766554433221100L, dexBuf.readLong(0)); dexBuf = new BaseDexBuffer(new byte[] {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}); Assert.assertEquals(0, dexBuf.readLong(0)); dexBuf = new BaseDexBuffer(new byte[] {(byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, 0x7f}); Assert.assertEquals(Long.MAX_VALUE, dexBuf.readLong(0)); dexBuf = new BaseDexBuffer(new byte[] {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, (byte)0x80}); Assert.assertEquals(Long.MIN_VALUE, dexBuf.readLong(0)); dexBuf = new BaseDexBuffer(new byte[] {(byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0x80}); Assert.assertEquals(0x80ffffffffffffffL, dexBuf.readLong(0)); dexBuf = new BaseDexBuffer(new byte[] {(byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff}); Assert.assertEquals(-1, dexBuf.readLong(0)); }