@Test
public void testSetBufferWithOffsetAndLen() throws Exception {
int bytesLen = 100;
byte[] bytes = TestUtils.randomByteArray(bytesLen);
Buffer src = Buffer.buffer(bytes);
int len = bytesLen - 2;
Buffer b = Buffer.buffer();
b.setByte(0, (byte) '0');
b.setBuffer(1, src, 1, len);
assertEquals(b.length(), len + 1);
byte[] copy = new byte[len];
System.arraycopy(bytes, 1, copy, 0, len);
assertTrue(TestUtils.byteArraysEqual(copy, b.getBytes(1, b.length())));
b.setBuffer(b.length(), src, 1, len);
assertEquals(b.length(), 2 * len + 1);
assertNullPointerException(() -> b.setBuffer(1, null));
assertNullPointerException(() -> b.setBuffer(1, null, 0, len));
}