@Test
public void testWriteZero() {

    try {
        buffer.writeZero(-1);
        fail();
    } catch (IllegalArgumentException e) {
        // Expected
    }
    buffer.clear();
    while (buffer.isWritable()) {
        buffer.writeByte((byte) 0xFF);
    }
    buffer.clear();
    for (int i = 0; i < buffer.capacity();) {
        int length = Math.min(buffer.capacity() - i, random.nextInt(32));
        buffer.writeZero(length);
        i += length;
    }
    assertEquals(0, buffer.readerIndex());
    assertEquals(buffer.capacity(), buffer.writerIndex());
    for (int i = 0; i < buffer.capacity(); i ++) {
        assertEquals(0, buffer.getByte(i));
    }
}