UnsafeMemoryOutput write = new UnsafeMemoryOutput(new ByteArrayOutputStream());
Input read = new UnsafeMemoryInput(write.toBytes());
assertEquals(false, read.canReadInt());
write.writeVarInt(400, true);
read = new UnsafeMemoryInput(write.toBytes());
assertEquals(true, read.canReadInt());
read.setLimit(read.limit() - 1);
assertEquals(false, read.canReadInt());