@Test(expected = ArrayIndexOutOfBoundsException.class) public void testArrayOutOfBounds() { byte[] str = new byte[8]; FastFormat.toZeroPaddedString(str, 4, 64L, 4, 16, new byte[] {'P'}); }
public static byte[] toZeroPaddedString(long num, int width, int radix, byte[] prefix) { Preconditions.checkArgument(num >= 0); String strNum = Long.toString(num, radix); byte[] ret = new byte[Math.max(strNum.length(), width) + prefix.length]; if (toZeroPaddedString(ret, 0, strNum, width, prefix) != ret.length) throw new RuntimeException(" Did not format to expected width " + num + " " + width + " " + radix + " " + new String(prefix, UTF_8)); return ret; }
FastFormat { public static byte[] toZeroPaddedString(long num, int width, int radix, byte[] prefix) { Preconditions.checkArgument(num >= 0); String strNum = Long.toString(num, radix); byte[] ret = new byte[Math.max(strNum.length(), width) + prefix.length]; if (toZeroPaddedString(ret, 0, strNum, width, prefix) != ret.length) throw new RuntimeException(" Did not format to expected width " + num + " " + width + " " + radix + " " + new String(prefix, UTF_8)); return ret; } }
FastFormat { public static byte[] toZeroPaddedString(long num, int width, int radix, byte[] prefix) { Preconditions.checkArgument(num >= 0); String strNum = Long.toString(num, radix); byte[] ret = new byte[Math.max(strNum.length(), width) + prefix.length]; if (toZeroPaddedString(ret, 0, strNum, width, prefix) != ret.length) throw new RuntimeException(" Did not format to expected width " + num + " " + width + " " + radix + " " + new String(prefix, UTF_8)); return ret; }  }
FastFormat { public static byte[] toZeroPaddedString(long num, int width, int radix, byte[] prefix) { Preconditions.checkArgument(num >= 0); String strNum = Long.toString(num, radix); byte[] ret = new byte[Math.max(strNum.length(), width) + prefix.length]; if (toZeroPaddedString(ret, 0, strNum, width, prefix) != ret.length) throw new RuntimeException(" Did not format to expected width " + num + " " + width + " " + radix + " " + new String(prefix, UTF_8)); return ret; }  static byte[] toZeroPaddedString(long num, int width, int radix, byte[] prefix); static int toZeroPaddedString(byte[] output, int outputOffset, long num, int width,
      int radix, byte[] prefix); }
FastFormat { public static byte[] toZeroPaddedString(long num, int width, int radix, byte[] prefix) { Preconditions.checkArgument(num >= 0); String strNum = Long.toString(num, radix); byte[] ret = new byte[Math.max(strNum.length(), width) + prefix.length]; if (toZeroPaddedString(ret, 0, strNum, width, prefix) != ret.length) throw new RuntimeException(" Did not format to expected width " + num + " " + width + " " + radix + " " + new String(prefix, UTF_8)); return ret; }  static byte[] toZeroPaddedString(long num, int width, int radix, byte[] prefix); static int toZeroPaddedString(byte[] output, int outputOffset, long num, int width,
      int radix, byte[] prefix);  }