WriteLength extends UnsignedIntLEByteValue { public static WriteLength of(byte... values) { return new WriteLength(values); } private  WriteLength(byte... values); private  WriteLength(long value); private  WriteLength(String length); private  WriteLength(ByteBuf byteBuf); static WriteLength of(byte... values); static WriteLength of(long value); static WriteLength of(LengthSupplier lengthSupplier); static WriteLength of(String length); static WriteLength of(ByteBuf byteBuf); static final int NUM_BYTES; }
@Test public void ofBytes() { assertEquals(0L, WriteLength.of(NULL_BYTE, NULL_BYTE, NULL_BYTE, NULL_BYTE).getAsLong()); assertThrows(IllegalArgumentException.class, () -> WriteLength.of(NULL_BYTE, NULL_BYTE, NULL_BYTE, NULL_BYTE, NULL_BYTE)); }
@Test public void ofLong() { assertByte(WriteLength.of(1), "0x01000000"); assertByte(WriteLength.of(65535), "0xffff0000"); assertThrows(IllegalArgumentException.class, () -> WriteLength.of(-1)); assertThrows(IllegalArgumentException.class, () -> WriteLength.of(4294967296L)); }
@Test public void ofString() { assertByte(WriteLength.of("1"), "0x01000000"); }
@Test public void testToString() { assertThat(WriteLength.of("1").toString(), containsString("longValue=1,")); }