Decoder { public void write(byte[] data) { write(data, 0, data.length); } Decoder(Charset charset, Consumer<int[]> onChar);  Decoder(int initialSize, Charset charset, Consumer<int[]> onChar); void setCharset(Charset charset); void write(byte[] data); void write(byte[] data, int start, int len); void setConsumer(Consumer<int[]> inputHandler);  }
@Test public void testDecoderUnderflow() { final ArrayList<Integer> codePoints = new ArrayList<>(); Decoder decoder = new Decoder(10, Charset.forName("UTF-8"), new Consumer<int[]>() { @Override public void accept(int[] event) { codePoints.addAll(list(event)); } }); decoder.write(new byte[]{(byte) 0xE2}); assertEquals(0, codePoints.size()); decoder.write(new byte[]{(byte) 0x82}); assertEquals(0, codePoints.size()); decoder.write(new byte[]{(byte) 0xAC}); assertEquals(1, codePoints.size()); assertEquals('\u20AC', (int)codePoints.get(0)); }