use of org.apache.flink.shaded.netty4.io.netty.buffer.ByteBuf in project MinecraftForge by MinecraftForge.
the class TestNetStuff method testByteBufUtilsByteReversals.
@Test
public void testByteBufUtilsByteReversals() {
ByteBuf buf = Unpooled.buffer(5, 5);
ByteBufUtils.writeVarInt(buf, 1, 1);
assertEquals("1 is 1", 1, ByteBufUtils.readVarInt(buf, 1));
buf.clear();
ByteBufUtils.writeVarInt(buf, 127, 1);
assertEquals("127 is 127", 127, ByteBufUtils.readVarInt(buf, 1));
buf.clear();
ByteBufUtils.writeVarInt(buf, 128, 2);
assertEquals("128 is 128", 128, ByteBufUtils.readVarInt(buf, 2));
buf.clear();
ByteBufUtils.writeVarInt(buf, 16383, 2);
assertEquals("16383 is 16383", 16383, ByteBufUtils.readVarInt(buf, 2));
buf.clear();
ByteBufUtils.writeVarInt(buf, 16384, 3);
assertEquals("16384 is 16384", 16384, ByteBufUtils.readVarInt(buf, 3));
buf.clear();
ByteBufUtils.writeVarInt(buf, 2097151, 3);
assertEquals("2097151 is 2097151", 2097151, ByteBufUtils.readVarInt(buf, 3));
buf.clear();
ByteBufUtils.writeVarInt(buf, 2097152, 4);
assertEquals("2097152 is 2097152", 2097152, ByteBufUtils.readVarInt(buf, 4));
buf.clear();
ByteBufUtils.writeVarInt(buf, 268435455, 4);
assertEquals("268435455 is 268435455", 268435455, ByteBufUtils.readVarInt(buf, 4));
buf.clear();
ByteBufUtils.writeVarInt(buf, 268435456, 5);
assertEquals("268435456 is 268435456", 268435456, ByteBufUtils.readVarInt(buf, 5));
}
use of org.apache.flink.shaded.netty4.io.netty.buffer.ByteBuf in project LogisticsPipes by RS485.
the class LPBCPipeRenderState method writeData_LP.
@Override
public void writeData_LP(LPDataOutput output) {
output.writeBoolean(true);
ByteBuf buf = Unpooled.buffer(128);
writeData(buf);
output.writeByteBuf(buf);
}
use of org.apache.flink.shaded.netty4.io.netty.buffer.ByteBuf in project LogisticsPipes by RS485.
the class LPBCPipeRenderState method readData_LP.
@Override
public void readData_LP(LPDataInput input) {
if (input.readBoolean()) {
ByteBuf buf = input.readByteBuf();
readData(buf);
}
}
use of org.apache.flink.shaded.netty4.io.netty.buffer.ByteBuf in project LogisticsPipes by RS485.
the class LPDataIOWrapperTest method testReadShort.
@Test
public void testReadShort() throws Exception {
short value = 12;
ByteBuf dataBuffer = buffer(Short.BYTES);
dataBuffer.writeShort(value);
LPDataIOWrapper.provideData(dataBuffer, input -> {
assertEquals(value, input.readShort());
assertEquals(BUFFER_EMPTY_MSG, 0, ((LPDataIOWrapper) input).localBuffer.readableBytes());
});
}
use of org.apache.flink.shaded.netty4.io.netty.buffer.ByteBuf in project LogisticsPipes by RS485.
the class LPDataIOWrapperTest method testReadDouble.
@Test
public void testReadDouble() throws Exception {
double value = 0.1234567890123456F;
ByteBuf dataBuffer = buffer(Double.BYTES);
dataBuffer.writeDouble(value);
LPDataIOWrapper.provideData(dataBuffer, input -> {
assertEquals(value, input.readDouble(), 0.000000000000001);
assertEquals(BUFFER_EMPTY_MSG, 0, ((LPDataIOWrapper) input).localBuffer.readableBytes());
});
}
Aggregations