}
@Test
public void pReadVarLong_void() throws Exception {
try {
Stream stream = new Stream();
stream.writeBit(1);
int max = (int )(Math.pow(2, RT.INT62) * Byte.SIZE - 2);
for (NumWithInfo nwi : genNumWithInfos(max)) {
if (nwi.getBits() < max) {
if (nwi.isOverflow() || nwi.isUnderflow()) {
continue;
}
}
stream.writeVarLong(nwi.getNumber().longValue());
}
stream.writeBit(1);
stream.readBit();
for (NumWithInfo nwi : genNumWithInfos(max)) {
if (nwi.getBits() < max) {
if (nwi.isOverflow() || nwi.isUnderflow()) {
continue;
}
}
if (nwi.isNormal()) {
assertEquals(nwi.getNumber().longValue(), stream.readVarLong());
} else {
BigInteger flow = BigInteger.valueOf(2).pow(nwi.getBits());
BigInteger left = nwi.getNumber();
BigInteger right = BigInteger.valueOf(stream.readVarLong());
if (nwi.isOverflow()) {
left = left.subtract(flow);
} else {
left = left.add(flow);
}
assertEquals(left, right);
}
}
assertEquals(1, stream.getData().readable());
} finally {
}
}