HexIntegerFormatter { public static StringBuilder formatTo(StringBuilder sb, short v, int flags, int width) { long unsigned = Math.abs(v); unsigned += v < 0 ? 1L << 16 : 0; return format0(sb, unsigned, flags, width); } private  HexIntegerFormatter(); static StringBuilder formatTo(StringBuilder sb, short v, int flags, int width); static StringBuilder formatTo(StringBuilder sb, int v, int flags, int width); static StringBuilder formatTo(StringBuilder sb, long v, int flags, int width); static final int PADDED_WITH_ZEROS; }
@Test public void formatTo() { assertEquals(Integer.toHexString(Short.MAX_VALUE), run(Short.MAX_VALUE, 0, false)); assertEquals("18000", run(Short.MIN_VALUE, 0, false)); assertEquals(Integer.toHexString(Integer.MAX_VALUE), run(Integer.MAX_VALUE, 0, false)); assertEquals(Integer.toHexString(Integer.MIN_VALUE), run(Integer.MIN_VALUE, 0, false)); assertEquals(Long.toHexString(Long.MAX_VALUE), run(Long.MAX_VALUE, 0, false)); assertEquals(Long.toHexString(Long.MIN_VALUE), run(Long.MIN_VALUE, 0, false)); }