assertEquals(4, write.writeInt(-134217728, false));
assertEquals(4, write.writeInt(-134217728, true));
assertEquals(4, write.writeInt(-134217729, false));
assertEquals(4, write.writeInt(-134217729, true));
Input read = new UnsafeMemoryInput(write.toBytes());
assertEquals(0, read.readInt());
assertEquals(63, read.readInt());
assertEquals(64, read.readInt());
assertEquals(127, read.readInt());
assertEquals(128, read.readInt());
assertEquals(8192, read.readInt());
assertEquals(16384, read.readInt());
assertEquals(2097151, read.readInt());
assertEquals(1048575, read.readInt());
assertEquals(134217727, read.readInt());
assertEquals(268435455, read.readInt());
assertEquals(134217728, read.readInt());
assertEquals(268435456, read.readInt());
assertEquals(-2097151, read.readInt());
assertEquals(-1048575, read.readInt());
assertEquals(-134217727, read.readInt());
assertEquals(-268435455, read.readInt());
assertEquals(-134217728, read.readInt());
assertEquals(-268435456, read.readInt());
assertEquals(true, read.canReadInt());
assertEquals(true, read.canReadInt());
assertEquals(true, read.canReadInt());
assertEquals(0, read.readInt(true));
assertEquals(0, read.readInt(false));
assertEquals(63, read.readInt(true));
assertEquals(63, read.readInt(false));
assertEquals(64, read.readInt(true));
assertEquals(64, read.readInt(false));
assertEquals(127, read.readInt(true));
assertEquals(127, read.readInt(false));
assertEquals(128, read.readInt(true));
assertEquals(128, read.readInt(false));
assertEquals(8191, read.readInt(true));
assertEquals(8191, read.readInt(false));
assertEquals(8192, read.readInt(true));
assertEquals(8192, read.readInt(false));
assertEquals(16383, read.readInt(true));
assertEquals(16383, read.readInt(false));
assertEquals(16384, read.readInt(true));
assertEquals(16384, read.readInt(false));
assertEquals(2097151, read.readInt(true));
assertEquals(2097151, read.readInt(false));
assertEquals(1048575, read.readInt(true));
assertEquals(1048575, read.readInt(false));
assertEquals(134217727, read.readInt(true));
assertEquals(134217727, read.readInt(false));
assertEquals(268435455, read.readInt(true));
assertEquals(268435455, read.readInt(false));
assertEquals(134217728, read.readInt(true));
assertEquals(134217728, read.readInt(false));
assertEquals(268435456, read.readInt(true));
assertEquals(268435456, read.readInt(false));
assertEquals(-64, read.readInt(false));
assertEquals(-64, read.readInt(true));
assertEquals(-65, read.readInt(false));
assertEquals(-65, read.readInt(true));
assertEquals(-8192, read.readInt(false));
assertEquals(-8192, read.readInt(true));
assertEquals(-1048576, read.readInt(false));
assertEquals(-1048576, read.readInt(true));
assertEquals(-134217728, read.readInt(false));
assertEquals(-134217728, read.readInt(true));
assertEquals(-134217729, read.readInt(false));
assertEquals(-134217729, read.readInt(true));
assertEquals(false, read.canReadInt());
Random random = new Random();
for (int i = 0; i < 10000; i++) {
int value = random.nextInt();
write.clear();
write.writeInt(value);
write.writeInt(value, true);
write.writeInt(value, false);
read.setBuffer(write.toBytes());
assertEquals(value, read.readInt());
assertEquals(value, read.readInt(true));
assertEquals(value, read.readInt(false));
}
}