@Test
public void indexOf() throws BufferException {

    ByteBuffer buffer = createCircledByteBuffer(TEST_BYTES1.length);
    buffer.add(TEST_BYTES1);
    // test normal case
    Assert.assertEquals(0, buffer.indexOf(TEST_H));
    Assert.assertEquals(0, buffer.indexOf(TEST_HELLO));
    Assert.assertEquals(0, buffer.indexOf(TEST_BYTES1));
    // test too long now
    buffer.remove();
    Assert.assertEquals(-1, buffer.indexOf(TEST_BYTES1));
    // test end -- buffer should be 1 less now such as ELLO WORLD
    Assert.assertEquals(9, buffer.indexOf(TEST_D));
    // test middle
    Assert.assertEquals(-1, buffer.indexOf(TEST_SPACEH));
    Assert.assertEquals(4, buffer.indexOf(TEST_SPACEW));
    Assert.assertEquals(5, buffer.indexOf(TEST_WORLD));
    buffer.clear();
    Assert.assertEquals(-1, buffer.indexOf(TEST_SPACEH));
}