@Test void writeVarint_ports() {
    // normal case
    byte[] bytes = new byte[WriteBuffer.varintSizeInBytes(80)];
    WriteBuffer.wrap(bytes).writeVarint(80);

    assertThat(bytes)
      .containsExactly(0b0101_0000);

    // largest value to not require more than 2 bytes (14 bits set)
    bytes = new byte[WriteBuffer.varintSizeInBytes(16383)];
    WriteBuffer.wrap(bytes).writeVarint(16383);

    assertThat(bytes)
      .containsExactly(0b1111_1111, 0b0111_1111);

    // worst case is a byte longer than fixed 16
    bytes = new byte[WriteBuffer.varintSizeInBytes(65535)];
    WriteBuffer.wrap(bytes).writeVarint(65535);

    assertThat(bytes)
      .containsExactly(0b1111_1111, 0b1111_1111, 0b0000_0011);

    // most bits
    bytes = new byte[WriteBuffer.varintSizeInBytes(0xFFFFFFFF)];
    WriteBuffer.wrap(bytes).writeVarint(0xFFFFFFFF);

    // we have a total of 32 bits encoded
    assertThat(bytes)
      .containsExactly(0b1111_1111, 0b1111_1111, 0b1111_1111, 0b1111_1111, 0b0000_1111);
  }
Uses test data and codepoint wrapping trick from okhttp3.FormBodyTest
zipkin/src/test/java/zipkin2/internal/WriteBufferTest.java