package ru.job4j;

import org.junit.Test;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.*;

/**
 * Task 4.1.1
 * Test working iterator array
 *
 * @author Anton Vasilyuk on 03.06.2017.
 * @version 1.0
 * @since 0.1
 */
public class IteratorArrayTest {

    /**.
     * Test working iterator
     */
    @Test
    public void whenNeedGetAllElementFromMultidimensionalArray() {
        IteratorArray iter = new IteratorArray(new int[][] {{1, 2}, {3, 4}});
        int[] arrayResult = new int[4];
        int[] check = {1, 2, 3, 4};
        int num = 0;

        for (int i = 0; i < arrayResult.length; i++) {
            arrayResult[i] = (Integer) iter.next();
        }
        for (int i = 0; i < arrayResult.length; i++) {
            if (arrayResult[i] != check[i]) {num++;}
        }

        boolean expect = true;
        boolean fact = false;
        if (num == 0) {fact = true;}
        assertThat(fact, is(expect));
    }
}
@@ -35,16 +35,59 @@
 t.Test;%0A
+%0Aimport java.util.NoSuchElementException;%0A%0A
 import s
@@ -990,10 +990,625 @@
 );%0A    %7D
+%0A%0A    @Test%0A    public void whenIterateTreeTimeArrayThenHasNextIsTrue() %7B%0A        IteratorArray iter = new IteratorArray(new int%5B%5D%5B%5D %7B%7B1, 2%7D, %7B3, 4%7D%7D);%0A        iter.next();%0A        iter.next();%0A        iter.next();%0A        boolean fact = iter.hasNext();%0A        assertThat(fact, is(true));%0A    %7D%0A%0A    @Test%0A    public void whenNotArrayThenErorNSEE() %7B%0A        int%5B%5D%5B%5D value = null;%0A        IteratorArray iter = new IteratorArray(value);%0A        try %7B%0A            iter.hasNext();%0A        %7D catch (NoSuchElementException nee) %7B%0A            assertThat(nee.getMessage(), is(%22No numbers in iterators.%22));%0A        %7D%0A    %7D
 %0A%7D

add file for chapter_003_4.1.1