VarInt { public static int getLength(int v) { return getLength(convertIntToLongNoSignExtend(v)); }  static void encode(int v, OutputStream stream); static void encode(long v, OutputStream stream); static int decodeInt(InputStream stream); static long decodeLong(InputStream stream); static int getLength(int v); static int getLength(long v);  }
@Test public void encodeValuesAndGetLength() throws IOException { assertEquals(LONG_VALUES.length, LONG_ENCODED.length); for (int i = 0; i < LONG_VALUES.length; ++i) { byte[] encoded = encodeLong(LONG_VALUES[i]); assertThat(encoded, equalTo(LONG_ENCODED[i])); assertEquals(LONG_ENCODED[i].length, VarInt.getLength(LONG_VALUES[i])); } assertEquals(INT_VALUES.length, INT_ENCODED.length); for (int i = 0; i < INT_VALUES.length; ++i) { byte[] encoded = encodeInt(INT_VALUES[i]); assertThat(encoded, equalTo(INT_ENCODED[i])); assertEquals(INT_ENCODED[i].length, VarInt.getLength(INT_VALUES[i])); } }