@Override
    public int read() throws IOException {
        if (!ensureDataInBuffer()) {
            return -1;
        }
        return buf[position++] & BYTE_MASK;
    }
@Test
    public void readBufByBuf() throws Exception {
        // given
        byte[] buf = new byte[mockInput.length / 2];
        int streamPos = 0;

        // when - then
        for (int count; (count = in.read(buf)) != -1; ) {
            for (int i = 0; i < count; i++) {
                assertEquals(mockInput[streamPos++], buf[i]);
            }
        }
        assertEquals(mockInput.length, streamPos);
    }