package com.techshroom.unplanned.test;

import static org.junit.Assert.assertArrayEquals;

import org.junit.BeforeClass;
import org.junit.Test;

import com.techshroom.unplanned.core.util.Arrays2;

/**
 * Test class for Arrays2.
 * 
 * @author Kenzie Togami
 */
public class Arrays2Test {
	private static Object[] CREATE_equivarray;
	private static int[] SPL_original, SPL_normalcp, SPL_reversecp, SPL_bigstepcp, SPL_rbigstepcp;

	/**
	 * Setup for test.
	 * 
	 * @throws Exception
	 */
	@BeforeClass
	public static void setUp() throws Exception {
		CREATE_equivarray = new Object[1];
		SPL_original = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
		SPL_normalcp = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
		SPL_reversecp = new int[] { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
		SPL_bigstepcp = new int[] { 0, 2, 4, 6, 8 };
		SPL_rbigstepcp = new int[] { 9, 7, 5, 3, 1 };
	}

	/**
	 * Arrays2 can create an array.
	 */
	@Test
	public void createsArray() {
		assertArrayEquals(CREATE_equivarray, Arrays2.newArray(Object.class, CREATE_equivarray.length));
	}

	/**
	 * Arrays2 can splice an array.
	 */
	@Test
	public void splicesArray() {
		// check that no in place mods occur
		int[] test, defensiveCopy = SPL_original.clone();
		// splice no args: copy
		test = Arrays2.splice(SPL_original);
		assertArrayEquals(defensiveCopy, SPL_original);
		assertArrayEquals(SPL_normalcp, test);
		// splice 0, -1, -1: reverse copy
		test = Arrays2.splice(SPL_original, 0, -1, -1);
		assertArrayEquals(defensiveCopy, SPL_original);
		assertArrayEquals(SPL_reversecp, test);
		// splice 0, -1, 2: every other object
		test = Arrays2.splice(SPL_original, 0, -1, 2);
		assertArrayEquals(defensiveCopy, SPL_original);
		assertArrayEquals(SPL_bigstepcp, test);
		// splice 0, -1, -2: reverse every other object
		test = Arrays2.splice(SPL_original, 0, -1, -2);
		assertArrayEquals(defensiveCopy, SPL_original);
		assertArrayEquals(SPL_rbigstepcp, test);
	}
}

@@ -1229,15 +1229,11 @@
 ice 
-no args
+%5B:%5D
 : co
@@ -1377,25 +1377,22 @@
  splice 
-0, -1, -1
+%5B::-1%5D
 : revers
@@ -1436,21 +1436,62 @@
 iginal, 
-0, -1
+Arrays2.SPLICE_DEFAULT, Arrays2.SPLICE_DEFAULT
 , -1);%0A%09
@@ -1593,24 +1593,21 @@
  splice 
-0, -1, 2
+%5B::2%5D
 : every 
@@ -1657,21 +1657,62 @@
 iginal, 
-0, -1
+Arrays2.SPLICE_DEFAULT, Arrays2.SPLICE_DEFAULT
 , 2);%0A%09%09
@@ -1813,25 +1813,22 @@
  splice 
-0, -1, 
+%5B::
 -2
+%5D
 : revers
@@ -1890,13 +1890,54 @@
 al, 
-0, -1
+Arrays2.SPLICE_DEFAULT, Arrays2.SPLICE_DEFAULT
 , -2

fix test