package com.github.basking2.sdsai.itrex.iterators;

import org.junit.Test;

import java.util.NoSuchElementException;

import static java.util.Arrays.asList;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertFalse;

public class BufferIteratorTest {

    @Test(expected = NoSuchElementException.class)
    public void testEmpty() {
        final BufferIterator bi = new BufferIterator(10, asList("a", "b", "c").iterator());

        bi.next();
        bi.next();
        bi.next();
        bi.next();
    }

    @Test
    public void testBufferFill() {
        final BufferIterator bi = new BufferIterator(10, asList("a", "b", "c").iterator());

        assertTrue(bi.hasNext());
        assertEquals("a", bi.next());
        assertTrue(bi.hasNext());
        assertEquals("b", bi.next());
        assertTrue(bi.hasNext());
        assertEquals("c", bi.next());
        assertFalse(bi.hasNext());
    }
}

@@ -69,16 +69,67 @@
 .Test;%0A%0A
+import java.util.ArrayList;%0Aimport java.util.List;%0A
 import j
@@ -1020,11 +1020,525 @@
 );%0A    %7D
+%0A%0A    @Test%0A    public void testIterationLargerThanBufferSize() %7B%0A%0A        final List%3CInteger%3E source = new ArrayList%3C%3E();%0A%0A        for (int i = 0; i %3C 132; i++) %7B%0A            source.add((int)(Math.random() * Integer.MAX_VALUE));%0A        %7D%0A%0A        assertTrue(source.size() %3E 0);%0A%0A        final BufferIterator bi = new BufferIterator(10, source.iterator());%0A%0A        for (int i = 0; i %3C source.size(); i++) %7B%0A            assertTrue(bi.hasNext());%0A            assertEquals(source.get(i), bi.next());%0A        %7D%0A    %7D
 %0A%7D%0A

Improve testing.