@Test
public void testEquals() {

    ByteBuf a, b;
    // Different length.
    a = wrappedBuffer(new byte[] { 1  });
    b = wrappedBuffer(new byte[] { 1, 2 });
    assertFalse(ByteBufUtil.equals(a, b));
    a.release();
    b.release();
    // Same content, same firstIndex, short length.
    a = wrappedBuffer(new byte[] { 1, 2, 3 });
    b = wrappedBuffer(new byte[] { 1, 2, 3 });
    assertTrue(ByteBufUtil.equals(a, b));
    a.release();
    b.release();
    // Same content, different firstIndex, short length.
    a = wrappedBuffer(new byte[] { 1, 2, 3 });
    b = wrappedBuffer(new byte[] { 0, 1, 2, 3, 4 }, 1, 3);
    assertTrue(ByteBufUtil.equals(a, b));
    a.release();
    b.release();
    // Different content, same firstIndex, short length.
    a = wrappedBuffer(new byte[] { 1, 2, 3 });
    b = wrappedBuffer(new byte[] { 1, 2, 4 });
    assertFalse(ByteBufUtil.equals(a, b));
    a.release();
    b.release();
    // Different content, different firstIndex, short length.
    a = wrappedBuffer(new byte[] { 1, 2, 3 });
    b = wrappedBuffer(new byte[] { 0, 1, 2, 4, 5 }, 1, 3);
    assertFalse(ByteBufUtil.equals(a, b));
    a.release();
    b.release();
    // Same content, same firstIndex, long length.
    a = wrappedBuffer(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 });
    b = wrappedBuffer(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 });
    assertTrue(ByteBufUtil.equals(a, b));
    a.release();
    b.release();
    // Same content, different firstIndex, long length.
    a = wrappedBuffer(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 });
    b = wrappedBuffer(new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}, 1, 10);
    assertTrue(ByteBufUtil.equals(a, b));
    a.release();
    b.release();
    // Different content, same firstIndex, long length.
    a = wrappedBuffer(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 });
    b = wrappedBuffer(new byte[] { 1, 2, 3, 4, 6, 7, 8, 5, 9, 10 });
    assertFalse(ByteBufUtil.equals(a, b));
    a.release();
    b.release();
    // Different content, different firstIndex, long length.
    a = wrappedBuffer(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 });
    b = wrappedBuffer(new byte[] { 0, 1, 2, 3, 4, 6, 7, 8, 5, 9, 10, 11 }, 1, 10);
    assertFalse(ByteBufUtil.equals(a, b));
    a.release();
    b.release();
}