@Test public void utf8SizeInBytes() {

  for (int codepoint = 0; codepoint <= 0x10FFFF; codepoint++) {
    if (codepoint == 0xD800) codepoint = 0xDFFF + 1; // skip surrogates
    if (Character.isDefined(codepoint)) {
      String test = new String(Character.toChars(codepoint));
      int expected = test.getBytes(UTF_8).length;
      int actual = WriteBuffer.utf8SizeInBytes(test);
      if (actual != expected) {
        throw new AssertionError(actual + " length != " + expected + " for " + codepoint);
      }
    }
  }
}