static int encode(
        final UnsafeBuffer encodingBuffer,
        final int offset,
        final int captureLength,
        final int length,
        final DirectBuffer srcBuffer,
        final int srcOffset)
    {
        final int encodedLength = encodeLogHeader(encodingBuffer, offset, captureLength, length);
        encodingBuffer.putBytes(offset + encodedLength, srcBuffer, srcOffset, captureLength);
        return encodedLength + captureLength;
    }
@Test
    void encodeBufferSmallerThanMaxCaptureSize()
    {
        final UnsafeBuffer srcBuffer = new UnsafeBuffer(new byte[256]);
        final int offset = 24;
        final int srcOffset = 20;
        final int length = 128;
        srcBuffer.setMemory(srcOffset, length, (byte)111);

        final int encodedLength = encode(buffer, offset, length, length, srcBuffer, srcOffset);

        assertEquals(LOG_HEADER_LENGTH + length, encodedLength);
        assertEquals(length, buffer.getInt(offset, LITTLE_ENDIAN));
        assertEquals(length, buffer.getInt(offset + SIZE_OF_INT, LITTLE_ENDIAN));
        assertNotEquals(0, buffer.getLong(offset + SIZE_OF_INT * 2, LITTLE_ENDIAN));
        for (int i = 0; i < length; i++)
        {
            assertEquals(111, buffer.getByte(offset + LOG_HEADER_LENGTH + i));
        }
    }