public int available() {
        if (position < end) {
            return end - position;
        } else {
            return 0;
        }
    }
@Test
    void testAvailable() throws Exception {
        byte[] bytes;
        DataInputDeserializer dis;

        bytes = new byte[] {};
        dis = new DataInputDeserializer(bytes, 0, bytes.length);
        assertThat(dis.available()).isEqualTo(bytes.length);

        bytes = new byte[] {1, 2, 3};
        dis = new DataInputDeserializer(bytes, 0, bytes.length);
        assertThat(dis.available()).isEqualTo(bytes.length);

        dis.readByte();
        assertThat(dis.available()).isEqualTo(2);
        dis.readByte();
        assertThat(dis.available()).isOne();
        dis.readByte();
        assertThat(dis.available()).isZero();

        assertThatThrownBy(dis::readByte).isInstanceOf(IOException.class);
        assertThat(dis.available()).isZero();
    }