/**
 * 
 */
package mathsquared.resultswizard2;

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

import org.junit.Test;

/**
 * @author MathSquared
 * 
 */
public class ArrayUtilsTest {

    /**
     * Test method for {@link mathsquared.resultswizard2.ArrayUtils#deepCopyOf(T[][])}.
     */
    // Timeout to detect infinite recursion with null
    @Test(timeout = 2000)
    public void testDeepCopyOf () {
        // Initialize some arrays

        String[][][] evil = new String[][][] { { {"a", "b"}, {"c"}}, {{"e", "f", "g"}}, { {"h", "i"}, {"j"}, {"k", "l", "m"}}};
        String[][][] result = ArrayUtils.deepCopyOf(evil);
        assertArrayEquals("3-D irregular String array", evil, result);

        Integer[][] easier = new Integer[][] { {1, 2}, {3}, {4, 5, 6}};
        Integer[][] easierResult = ArrayUtils.deepCopyOf(easier);
        assertArrayEquals("2-D irregular Integer array", easier, easierResult);

        Object[][] nul = null;
        assertArrayEquals("Null", ArrayUtils.deepCopyOf(nul), null); // infinite recursion detected by timeout
    }

    /**
     * Test method for {@link mathsquared.resultswizard2.ArrayUtils#checkTies(String[][])}.
     */
    @Test
    public void testCheckTies () {
        String[][] res = new String[][] { {"First"}, {"Second A", "Second B"}, null, {"Fourth A", "Fourth B", "Fourth C"}, null, null, {"Seventh A", "Seventh B"}};
        assertTrue("Valid with several ties", ArrayUtils.checkTies(res));

        String[][] bad = new String[][] { {"First A", "First B"}, {"Second"}};
        assertFalse("Invalid--missing skip", ArrayUtils.checkTies(bad));

        String[][] nul = new String[][] { {"First A", "First B"}, null, null, {"Fourth A", "Fourth B"}};
        assertFalse("Invalid--extraneous null", ArrayUtils.checkTies(nul));
    }

}

@@ -1885,10 +1885,795 @@
 %0A    %7D%0A%0A
+    /**%0A     * Test method for %7B@link mathsquared.resultswizard2.ArrayUtils#checkStructureSame(Object%5B%5D, Object%5B%5D)%7D.%0A     */%0A    @Test%0A    public void testCheckStructureSame () %7B%0A        Integer%5B%5D%5B%5D a = %7B %7B1, 2%7D, null, %7B%7D, %7B3%7D%7D;%0A        Integer%5B%5D%5B%5D b = %7B %7B4, 5%7D, null, %7B%7D, %7B6%7D%7D;%0A        assertTrue(%22Same structure including both null and empty subarray%22, ArrayUtils.checkStructureSame(a, b));%0A%0A        Integer%5B%5D%5B%5D c = %7B %7B7, 8%7D, null, %7B%7D%7D;%0A        assertFalse(%22Second array prefix of first%22, ArrayUtils.checkStructureSame(a, c));%0A        assertFalse(%22First array prefix of second%22, ArrayUtils.checkStructureSame(c, b));%0A%0A        assertTrue(%22Two nulls%22, ArrayUtils.checkStructureSame(null, null));%0A        assertFalse(%22Null and non-null%22, ArrayUtils.checkStructureSame(null, a));%0A    %7D%0A%0A
 %7D%0A

Add a test for ArrayUtils.checkStructureSame