BinaryReader implements AutoCloseable { public int readPushInteger() throws DeserializationException { return readPushBigInteger().intValue(); } BinaryReader(InputStream stream);  BinaryReader(byte[] input); int getPosition(); int getMark(); @Override void close(); void mark(int readlimit); void reset(); void read(byte[] buffer); void read(byte[] buffer, int index, int length); boolean readBoolean(); int readUnsignedByte(); byte readByteKeepPosition(); byte readByte(); byte[] readBytes(int count); double readDouble(); byte[] readEncodedECPoint(); ECPoint readECPoint(); float readFloat(); int readInt(); int readUInt16(); long readUInt32(); long readInt64(); T readSerializable(Class<T> t); List<T> readSerializableListVarBytes(Class<T> t); List<T> readSerializableList(Class<T> t); short readShort(); byte[] readVarBytes(); byte[] readPushData(); byte[] readVarBytes(int max); long readVarInt(); long readVarInt(long max); String readPushString(); int readPushInteger(); BigInteger readPushBigInteger(); static int readUInt16(byte[] bytes);  }
@Test public void readPushInteger0() throws DeserializationException { this.arrayBuilder = new ByteArrayBuilder().setData("10"); readPushInteger(); assertThat(this.readResultInt, is(BigInteger.valueOf(0))); }
@Test public void readPushInteger1() throws DeserializationException { this.arrayBuilder = new ByteArrayBuilder().setPrefix("11"); readPushInteger(); assertThat(this.readResultInt, is(BigInteger.valueOf(1))); }
@Test public void readPushIntegerMinus1() throws DeserializationException { this.arrayBuilder = new ByteArrayBuilder().setPrefix("0f"); readPushInteger(); assertThat(this.readResultInt, is(BigInteger.valueOf(-1))); }
@Test public void readPushInteger16() throws DeserializationException { this.arrayBuilder = new ByteArrayBuilder().setPrefix("20"); readPushInteger(); assertThat(this.readResultInt, is(BigInteger.valueOf(16))); }
@Test(expected = DeserializationException.class) public void failReadPushIntegerUnsupported() throws DeserializationException { this.arrayBuilder = new ByteArrayBuilder().setPrefix("0e"); readPushInteger(); }
@Test public void readPushIntegerMin8BitInt() throws DeserializationException { this.arrayBuilder = new ByteArrayBuilder().setPrefix("0080"); readPushInteger(); assertThat(this.readResultInt, is(BigInteger.valueOf(-128))); }
@Test public void readPushIntegerMax8BitInt() throws DeserializationException { this.arrayBuilder = new ByteArrayBuilder().setPrefix("007f"); readPushInteger(); assertThat(this.readResultInt, is(BigInteger.valueOf(127))); }
@Test public void readPushIntegerMin16BitInt() throws DeserializationException { this.arrayBuilder = new ByteArrayBuilder().setPrefix("010080"); readPushInteger(); assertThat(this.readResultInt, is(BigInteger.valueOf(-32_768))); }
@Test public void readPushInteger16BitInt255() throws DeserializationException { this.arrayBuilder = new ByteArrayBuilder().setPrefix("01ff00"); readPushInteger(); assertThat(this.readResultInt, is(BigInteger.valueOf(255))); }
@Test public void readPushIntegerMax16BitInt() throws DeserializationException { this.arrayBuilder = new ByteArrayBuilder().setPrefix("01ff7f"); readPushInteger(); assertThat(this.readResultInt, is(BigInteger.valueOf(32_767))); }
@Test public void readPushIntegerMin32BitInt() throws DeserializationException { this.arrayBuilder = new ByteArrayBuilder().setPrefix("0200000080"); readPushInteger(); assertThat(this.readResultInt, is(BigInteger.valueOf(-2_147_483_648))); }
@Test public void readPushInteger32BitInt65535() throws DeserializationException { this.arrayBuilder = new ByteArrayBuilder().setPrefix("02ffff0000"); readPushInteger(); assertThat(this.readResultInt, is(BigInteger.valueOf(65_535))); }
@Test public void readPushIntegerMax32BitInt() throws DeserializationException { this.arrayBuilder = new ByteArrayBuilder().setPrefix("02ffffff7f"); readPushInteger(); assertThat(this.readResultInt, is(BigInteger.valueOf(2_147_483_647))); }
@Test public void readPushIntegerMin64BitInt() throws DeserializationException { this.arrayBuilder = new ByteArrayBuilder().setPrefix("030000000000000080"); readPushInteger(); assertThat(this.readResultInt, is(BigInteger.valueOf(-9_223_372_036_854_775_808L))); }
@Test public void readPushInteger64BitInt65535() throws DeserializationException { this.arrayBuilder = new ByteArrayBuilder().setPrefix("03ffffffff00000000"); readPushInteger(); assertThat(this.readResultInt, is(BigInteger.valueOf(4_294_967_295L))); }
@Test public void readPushIntegerMax64BitInt() throws DeserializationException { this.arrayBuilder = new ByteArrayBuilder().setPrefix("03ffffffffffffff7f"); readPushInteger(); assertThat(this.readResultInt, is(BigInteger.valueOf(9_223_372_036_854_775_807L))); }
@Test public void readPushInteger128BitInt() throws DeserializationException { this.arrayBuilder = new ByteArrayBuilder().setPrefix("04ffffffffffffffff0000000000000000"); readPushInteger(); assertThat(this.readResultInt, is(new BigInteger("18446744073709551615"))); }
@Test public void readPushInteger256BitInt() throws DeserializationException { this.arrayBuilder = new ByteArrayBuilder() .setPrefix("050100000000000000feffffffffffffff00000000000000000000000000000000"); readPushInteger(); BigInteger uLong = new BigInteger("18446744073709551615"); BigInteger val = uLong.multiply(uLong); assertThat(this.readResultInt, is(val)); }