@Test
  public void testBlobVarLencodedLength() {
    int[][] values = {
      /*
       * decoded length, encoded length ceil((n bytes * 8 bits/input byte) / 7 bits/encoded byte) +
       * 1 header
       */
      { 1, 3 }, { 2, 4 }, { 3, 5 }, { 4, 6 }, { 5, 7 }, { 6, 8 }, { 7, 9 }, { 8, 11 } };

    for (int[] pair : values) {
      assertEquals(pair[1], OrderedBytes.blobVarEncodedLength(pair[0]));
      assertEquals(pair[0], OrderedBytes.blobVarDecodedLength(pair[1]));
    }
  }
Test length estimation algorithms for BlobVar encoding. Does not cover 0-length input case
properly.
hbase-common/src/test/java/org/apache/hadoop/hbase/util/TestOrderedBytes.java