package org.apache.logging.log4j.core.util;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import org.junit.Test;

public class CyclicBufferTest {

    @Test
    public void testCyclicBuffer() {
        final CyclicBuffer<Integer> buffer = new CyclicBuffer<>(Integer.class, 3);

        assertTrue(buffer.isEmpty());
        buffer.add(1);
        assertFalse(buffer.isEmpty());
        Integer[] items = buffer.removeAll();
        assertTrue("Incorrect number of items", items.length == 1);

        assertTrue(buffer.isEmpty());
        buffer.add(1);
        buffer.add(2);
        buffer.add(3);
        buffer.add(4);
        items = buffer.removeAll();
        assertTrue("Incorrect number of items", items.length == 3);
        assertTrue(buffer.isEmpty());
    }

}

@@ -38,16 +38,66 @@
 .util;%0A%0A
+import static org.junit.Assert.assertArrayEquals;%0A
 import s
@@ -132,16 +132,16 @@
 tFalse;%0A
-
 import s
@@ -263,28 +263,1311 @@
 oid test
-CyclicBuffer
+Size0() %7B%0A        final CyclicBuffer%3CInteger%3E buffer = new CyclicBuffer%3C%3E(Integer.class, 0);%0A%0A        assertTrue(buffer.isEmpty());%0A        buffer.add(1);%0A        assertTrue(buffer.isEmpty());%0A        Integer%5B%5D items = buffer.removeAll();%0A        assertTrue(%22Incorrect number of items%22, items.length == 0);%0A%0A        assertTrue(buffer.isEmpty());%0A        buffer.add(1);%0A        buffer.add(2);%0A        buffer.add(3);%0A        buffer.add(4);%0A        items = buffer.removeAll();%0A        assertTrue(%22Incorrect number of items%22, items.length == 0);%0A        assertTrue(buffer.isEmpty());%0A    %7D%0A%0A    @Test%0A    public void testSize1() %7B%0A        final CyclicBuffer%3CInteger%3E buffer = new CyclicBuffer%3C%3E(Integer.class, 1);%0A%0A        assertTrue(buffer.isEmpty());%0A        buffer.add(1);%0A        assertFalse(buffer.isEmpty());%0A        Integer%5B%5D items = buffer.removeAll();%0A        assertTrue(%22Incorrect number of items%22, items.length == 1);%0A%0A        assertTrue(buffer.isEmpty());%0A        buffer.add(1);%0A        buffer.add(2);%0A        buffer.add(3);%0A        buffer.add(4);%0A        items = buffer.removeAll();%0A        assertTrue(%22Incorrect number of items%22, items.length == 1);%0A        assertArrayEquals(new Integer%5B%5D %7B 4 %7D, items);%0A        assertTrue(buffer.isEmpty());%0A    %7D%0A%0A    @Test%0A    public void testSize3
 () %7B%0A   
@@ -2110,37 +2110,279 @@
   assert
-True(buffer.isEmpty()
+ArrayEquals(new Integer%5B%5D %7B 2, 3, 4 %7D, items);%0A        assertTrue(buffer.isEmpty());%0A    %7D%0A%0A    @Test(expected = IllegalArgumentException.class)%0A    public void testSizeNegative() %7B%0A        final CyclicBuffer%3CInteger%3E buffer = new CyclicBuffer%3C%3E(Integer.class, -1
 );%0A    %7D

Allow for bufferSize=0 in SMTP appender. Add tests.