package java7.reflection;

import java.lang.reflect.Array;
import libs.junit.UnitTestRunner;
import org.junit.Test;
import static org.junit.Assert.*;

public class ArraySetTest {

    public static void main(String[] args) {
        UnitTestRunner.run(ArraySetTest.class);
    }

    @Test
    public void setObjectArray() {
        String[] arr = {"beyond"};
        Array.set(arr, 0, "5457");
        assertEquals("5457", Array.get(arr, 0));
    }

    @Test
    public void setPrimitiveArray() {
        int[] arr = {5, 4, 5, 7};
        Array.set(arr, 0, 0);
        assertEquals(0, Array.get(arr, 0));

        //Array.set(arr, 0, "beyond");
    }

}

@@ -265,32 +265,831 @@
 .class);%0A    %7D%0A%0A
+    @Test%0A    public void setNullArray() %7B%0A        try %7B%0A            Object x = null;%0A            Array.set(x, 3, %22a%22);%0A            fail();%0A        %7D catch (NullPointerException e) %7B%0A            assertNull(e.getMessage());%0A        %7D%0A    %7D%0A    %0A    @Test%0A    public void setNonArray() %7B%0A        try %7B%0A            String str = %22abc%22;%0A            Array.set(str, 1, %22a%22);%0A            fail();%0A        %7D catch (IllegalArgumentException e) %7B%0A            assertEquals(%22Argument is not an array%22, e.getMessage());%0A        %7D%0A    %7D%0A    %0A    @Test%0A    public void setArrayBadIndex() %7B%0A        try %7B%0A            int%5B%5D arr = %7B1, 2, 3%7D;%0A            Array.set(arr, -1, 4);%0A            fail();%0A        %7D catch (ArrayIndexOutOfBoundsException e) %7B%0A            assertEquals(null, e.getMessage());%0A        %7D%0A    %7D%0A    %0A
     @Test%0A    pu

test Array.set()