@Test public void testIntegerSize() throws Exception { for (int n = 1; n <= 8; n++) { for (int i = 0; i < 32; i++) { for (int j = 0; j <= i; j++) { int value = Math.toIntExact((1L << j) - 1); ByteBuf buf = Unpooled.buffer(); Hpack.writeInteger(buf, 0, n, value); int calculatedSize = Hpack.integerSize(n, value); final int actualSize = buf.readableBytes(); assertThat(actualSize, is(calculatedSize)); } } } }