@Test
public void testReadingWitSmallBuffer() throws Exception {

    final String s = "10\r\n1234567890123456\r\n" +
            "40\r\n12345678901234561234567890123456" +
            "12345678901234561234567890123456\r\n0\r\n";
    final ReadableByteChannel channel = new ReadableByteChannelMock(
            new String[] {s}, StandardCharsets.US_ASCII);
    final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, 0, StandardCharsets.US_ASCII);
    final BasicHttpTransportMetrics metrics = new BasicHttpTransportMetrics();
    final ChunkDecoder decoder = new ChunkDecoder(channel, inbuf, metrics);
    final ByteBuffer dst = ByteBuffer.allocate(1024);
    final ByteBuffer tmp = ByteBuffer.allocate(10);
    int bytesRead = 0;
    while (dst.hasRemaining() && !decoder.isCompleted()) {
        final int i = decoder.read(tmp);
        if (i > 0) {
            bytesRead += i;
            tmp.flip();
            dst.put(tmp);
            tmp.compact();
        }
    }
    Assert.assertEquals(80, bytesRead);
    Assert.assertEquals("12345678901234561234567890123456" +
            "12345678901234561234567890123456" +
            "1234567890123456", CodecTestUtils.convert(dst));
    Assert.assertTrue(decoder.isCompleted());
}