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