@Test
void testToArray() {

    ByteBuffer buffer = ByteBuffer.allocate(4);
    buffer.putInt(6);
    buffer.flip();
    byte[] bytes = BufferUtils.toArray(buffer);
    assertNotSame(bytes, buffer.array());
    assertEquals(6, ByteBuffer.wrap(bytes).getInt());
    buffer = ByteBuffer.allocateDirect(4);
    buffer.putInt(3);
    buffer.flip();
    bytes = BufferUtils.toArray(buffer);
    assertEquals(3, ByteBuffer.wrap(bytes).getInt());
}