Home | History | Annotate | Download | only in util
      1 /*
      2  *  Licensed to the Apache Software Foundation (ASF) under one or more
      3  *  contributor license agreements.  See the NOTICE file distributed with
      4  *  this work for additional information regarding copyright ownership.
      5  *  The ASF licenses this file to You under the Apache License, Version 2.0
      6  *  (the "License"); you may not use this file except in compliance with
      7  *  the License.  You may obtain a copy of the License at
      8  *
      9  *     http://www.apache.org/licenses/LICENSE-2.0
     10  *
     11  *  Unless required by applicable law or agreed to in writing, software
     12  *  distributed under the License is distributed on an "AS IS" BASIS,
     13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     14  *  See the License for the specific language governing permissions and
     15  *  limitations under the License.
     16  */
     17 package org.apache.harmony.luni.tests.java.util;
     18 
     19 import java.lang.reflect.Method;
     20 import java.util.Arrays;
     21 import java.util.Comparator;
     22 import java.util.Date;
     23 import java.util.LinkedList;
     24 import java.util.List;
     25 
     26 import tests.support.Support_UnmodifiableCollectionTest;
     27 
     28 public class ArraysTest extends junit.framework.TestCase {
     29 
     30 	public static class ReversedIntegerComparator implements Comparator {
     31 		public int compare(Object o1, Object o2) {
     32 			return -(((Integer) o1).compareTo((Integer) o2));
     33 		}
     34 
     35 		public boolean equals(Object o1, Object o2) {
     36 			return ((Integer) o1).compareTo((Integer) o2) == 0;
     37 		}
     38 	}
     39 
     40     static class MockComparable implements Comparable{
     41         public int compareTo(Object o) {
     42             return 0;
     43         }
     44     }
     45 
     46 	final static int arraySize = 100;
     47 
     48 	static Object[] objArray;
     49 
     50 	static boolean[] booleanArray;
     51 
     52 	static byte[] byteArray;
     53 
     54 	static char[] charArray;
     55 
     56 	static double[] doubleArray;
     57 
     58 	static float[] floatArray;
     59 
     60 	static int[] intArray;
     61 
     62 	static long[] longArray;
     63 
     64 	static Object[] objectArray;
     65 
     66 	static short[] shortArray;
     67 	{
     68 		objArray = new Object[arraySize];
     69 		for (int i = 0; i < objArray.length; i++)
     70 			objArray[i] = new Integer(i);
     71 	}
     72 
     73 	/**
     74 	 * @tests java.util.Arrays#asList(java.lang.Object[])
     75 	 */
     76 	public void test_asList$Ljava_lang_Object() {
     77 		// Test for method java.util.List
     78 		// java.util.Arrays.asList(java.lang.Object [])
     79 		List convertedList = Arrays.asList(objectArray);
     80 		for (int counter = 0; counter < arraySize; counter++) {
     81 			assertTrue(
     82 					"Array and List converted from array do not contain identical elements",
     83 					convertedList.get(counter) == objectArray[counter]);
     84 		}
     85 		convertedList.set(50, new Integer(1000));
     86 		assertTrue("set/get did not work on coverted list", convertedList.get(
     87 				50).equals(new Integer(1000)));
     88 		convertedList.set(50, new Integer(50));
     89 		new Support_UnmodifiableCollectionTest("", convertedList).runTest();
     90 
     91 		Object[] myArray = (Object[]) (objectArray.clone());
     92 		myArray[30] = null;
     93 		myArray[60] = null;
     94 		convertedList = Arrays.asList(myArray);
     95 		for (int counter = 0; counter < arraySize; counter++) {
     96 			assertTrue(
     97 					"Array and List converted from array do not contain identical elements",
     98 					convertedList.get(counter) == myArray[counter]);
     99 		}
    100 
    101 		try {
    102 			Arrays.asList((Object[])null);
    103 			fail("asList with null arg didn't throw NPE");
    104 		} catch (NullPointerException e) {
    105 			// Expected
    106 		}
    107 	}
    108 
    109 	/**
    110 	 * @tests java.util.Arrays#binarySearch(byte[], byte)
    111 	 */
    112 	public void test_binarySearch$BB() {
    113 		// Test for method int java.util.Arrays.binarySearch(byte [], byte)
    114 		for (byte counter = 0; counter < arraySize; counter++)
    115 			assertTrue("Binary search on byte[] answered incorrect position",
    116 					Arrays.binarySearch(byteArray, counter) == counter);
    117 		assertEquals("Binary search succeeded for value not present in array 1",
    118 				-1, Arrays.binarySearch(intArray, (byte) -1));
    119 		assertTrue(
    120 				"Binary search succeeded for value not present in array 2",
    121 				Arrays.binarySearch(intArray, (byte) arraySize) == -(arraySize + 1));
    122 		for (byte counter = 0; counter < arraySize; counter++)
    123 			byteArray[counter] -= 50;
    124 		for (byte counter = 0; counter < arraySize; counter++)
    125 			assertTrue(
    126 					"Binary search on byte[] involving negative numbers answered incorrect position",
    127 					Arrays.binarySearch(byteArray, (byte) (counter - 50)) == counter);
    128 	}
    129 
    130 	/**
    131 	 * @tests java.util.Arrays#binarySearch(char[], char)
    132 	 */
    133 	public void test_binarySearch$CC() {
    134 		// Test for method int java.util.Arrays.binarySearch(char [], char)
    135 		for (char counter = 0; counter < arraySize; counter++)
    136 			assertTrue(
    137 					"Binary search on char[] answered incorrect position",
    138 					Arrays.binarySearch(charArray, (char) (counter + 1)) == counter);
    139 		assertEquals("Binary search succeeded for value not present in array 1",
    140 				-1, Arrays.binarySearch(charArray, '\u0000'));
    141 		assertTrue(
    142 				"Binary search succeeded for value not present in array 2",
    143 				Arrays.binarySearch(charArray, (char) (arraySize + 1)) == -(arraySize + 1));
    144 	}
    145 
    146 	/**
    147 	 * @tests java.util.Arrays#binarySearch(double[], double)
    148 	 */
    149 	public void test_binarySearch$DD() {
    150 		// Test for method int java.util.Arrays.binarySearch(double [], double)
    151 		for (int counter = 0; counter < arraySize; counter++)
    152 			assertTrue(
    153 					"Binary search on double[] answered incorrect position",
    154 					Arrays.binarySearch(doubleArray, (double) counter) == (double) counter);
    155 		assertEquals("Binary search succeeded for value not present in array 1",
    156 				-1, Arrays.binarySearch(doubleArray, (double) -1));
    157 		assertTrue(
    158 				"Binary search succeeded for value not present in array 2",
    159 				Arrays.binarySearch(doubleArray, (double) arraySize) == -(arraySize + 1));
    160 		for (int counter = 0; counter < arraySize; counter++)
    161 			doubleArray[counter] -= (double) 50;
    162 		for (int counter = 0; counter < arraySize; counter++)
    163 			assertTrue(
    164 					"Binary search on double[] involving negative numbers answered incorrect position",
    165 					Arrays.binarySearch(doubleArray, (double) (counter - 50)) == (double) counter);
    166 
    167 		double[] specials = new double[] { Double.NEGATIVE_INFINITY,
    168 				-Double.MAX_VALUE, -2d, -Double.MIN_VALUE, -0d, 0d,
    169 				Double.MIN_VALUE, 2d, Double.MAX_VALUE,
    170 				Double.POSITIVE_INFINITY, Double.NaN };
    171 		for (int i = 0; i < specials.length; i++) {
    172 			int result = Arrays.binarySearch(specials, specials[i]);
    173 			assertTrue(specials[i] + " invalid: " + result, result == i);
    174 		}
    175 		assertEquals("-1d", -4, Arrays.binarySearch(specials, -1d));
    176 		assertEquals("1d", -8, Arrays.binarySearch(specials, 1d));
    177 
    178 	}
    179 
    180 	/**
    181 	 * @tests java.util.Arrays#binarySearch(float[], float)
    182 	 */
    183 	public void test_binarySearch$FF() {
    184 		// Test for method int java.util.Arrays.binarySearch(float [], float)
    185 		for (int counter = 0; counter < arraySize; counter++)
    186 			assertTrue(
    187 					"Binary search on float[] answered incorrect position",
    188 					Arrays.binarySearch(floatArray, (float) counter) == (float) counter);
    189 		assertEquals("Binary search succeeded for value not present in array 1",
    190 				-1, Arrays.binarySearch(floatArray, (float) -1));
    191 		assertTrue(
    192 				"Binary search succeeded for value not present in array 2",
    193 				Arrays.binarySearch(floatArray, (float) arraySize) == -(arraySize + 1));
    194 		for (int counter = 0; counter < arraySize; counter++)
    195 			floatArray[counter] -= (float) 50;
    196 		for (int counter = 0; counter < arraySize; counter++)
    197 			assertTrue(
    198 					"Binary search on float[] involving negative numbers answered incorrect position",
    199 					Arrays.binarySearch(floatArray, (float) counter - 50) == (float) counter);
    200 
    201 		float[] specials = new float[] { Float.NEGATIVE_INFINITY,
    202 				-Float.MAX_VALUE, -2f, -Float.MIN_VALUE, -0f, 0f,
    203 				Float.MIN_VALUE, 2f, Float.MAX_VALUE, Float.POSITIVE_INFINITY,
    204 				Float.NaN };
    205 		for (int i = 0; i < specials.length; i++) {
    206 			int result = Arrays.binarySearch(specials, specials[i]);
    207 			assertTrue(specials[i] + " invalid: " + result, result == i);
    208 		}
    209 		assertEquals("-1f", -4, Arrays.binarySearch(specials, -1f));
    210 		assertEquals("1f", -8, Arrays.binarySearch(specials, 1f));
    211 	}
    212 
    213 	/**
    214 	 * @tests java.util.Arrays#binarySearch(int[], int)
    215 	 */
    216 	public void test_binarySearch$II() {
    217 		// Test for method int java.util.Arrays.binarySearch(int [], int)
    218 		for (int counter = 0; counter < arraySize; counter++)
    219 			assertTrue("Binary search on int[] answered incorrect position",
    220 					Arrays.binarySearch(intArray, counter) == counter);
    221 		assertEquals("Binary search succeeded for value not present in array 1",
    222 				-1, Arrays.binarySearch(intArray, -1));
    223 		assertTrue("Binary search succeeded for value not present in array 2",
    224 				Arrays.binarySearch(intArray, arraySize) == -(arraySize + 1));
    225 		for (int counter = 0; counter < arraySize; counter++)
    226 			intArray[counter] -= 50;
    227 		for (int counter = 0; counter < arraySize; counter++)
    228 			assertTrue(
    229 					"Binary search on int[] involving negative numbers answered incorrect position",
    230 					Arrays.binarySearch(intArray, counter - 50) == counter);
    231 	}
    232 
    233 	/**
    234 	 * @tests java.util.Arrays#binarySearch(long[], long)
    235 	 */
    236 	public void test_binarySearch$JJ() {
    237 		// Test for method int java.util.Arrays.binarySearch(long [], long)
    238 		for (long counter = 0; counter < arraySize; counter++)
    239 			assertTrue("Binary search on long[] answered incorrect position",
    240 					Arrays.binarySearch(longArray, counter) == counter);
    241 		assertEquals("Binary search succeeded for value not present in array 1",
    242 				-1, Arrays.binarySearch(longArray, (long) -1));
    243 		assertTrue(
    244 				"Binary search succeeded for value not present in array 2",
    245 				Arrays.binarySearch(longArray, (long) arraySize) == -(arraySize + 1));
    246 		for (long counter = 0; counter < arraySize; counter++)
    247 			longArray[(int) counter] -= (long) 50;
    248 		for (long counter = 0; counter < arraySize; counter++)
    249 			assertTrue(
    250 					"Binary search on long[] involving negative numbers answered incorrect position",
    251 					Arrays.binarySearch(longArray, counter - (long) 50) == counter);
    252 	}
    253 
    254 	/**
    255 	 * @tests java.util.Arrays#binarySearch(java.lang.Object[],
    256 	 *        java.lang.Object)
    257 	 */
    258 	public void test_binarySearch$Ljava_lang_ObjectLjava_lang_Object() {
    259 		// Test for method int java.util.Arrays.binarySearch(java.lang.Object
    260 		// [], java.lang.Object)
    261 		assertEquals(
    262 				"Binary search succeeded for non-comparable value in empty array",
    263 				-1, Arrays.binarySearch(new Object[] {}, new Object()));
    264 		assertEquals(
    265 				"Binary search succeeded for comparable value in empty array",
    266 				-1, Arrays.binarySearch(new Object[] {}, new Integer(-1)));
    267 		for (int counter = 0; counter < arraySize; counter++)
    268 			assertTrue(
    269 					"Binary search on Object[] answered incorrect position",
    270 					Arrays.binarySearch(objectArray, objArray[counter]) == counter);
    271 		assertEquals("Binary search succeeded for value not present in array 1",
    272 				-1, Arrays.binarySearch(objectArray, new Integer(-1)));
    273 		assertTrue(
    274 				"Binary search succeeded for value not present in array 2",
    275 				Arrays.binarySearch(objectArray, new Integer(arraySize)) == -(arraySize + 1));
    276 
    277         Object object = new Object();
    278         Object[] objects = new MockComparable[] { new MockComparable() };
    279         assertEquals("Should always return 0", 0, Arrays.binarySearch(objects, object));
    280 
    281         Object[] string_objects = new String[] { "one" };
    282         try {
    283             Arrays.binarySearch(string_objects, object);
    284             fail("No expected ClassCastException");
    285         } catch (ClassCastException e) {
    286             // Expected
    287         }
    288 	}
    289 
    290 	/**
    291 	 * @tests java.util.Arrays#binarySearch(java.lang.Object[],
    292 	 *        java.lang.Object, java.util.Comparator)
    293 	 */
    294 	public void test_binarySearch$Ljava_lang_ObjectLjava_lang_ObjectLjava_util_Comparator() {
    295 		// Test for method int java.util.Arrays.binarySearch(java.lang.Object
    296 		// [], java.lang.Object, java.util.Comparator)
    297 		Comparator comp = new ReversedIntegerComparator();
    298 		for (int counter = 0; counter < arraySize; counter++)
    299 			objectArray[counter] = objArray[arraySize - counter - 1];
    300 		assertTrue(
    301 				"Binary search succeeded for value not present in array 1",
    302 				Arrays.binarySearch(objectArray, new Integer(-1), comp) == -(arraySize + 1));
    303 		assertEquals("Binary search succeeded for value not present in array 2",
    304 				-1, Arrays.binarySearch(objectArray, new Integer(arraySize), comp));
    305 		for (int counter = 0; counter < arraySize; counter++)
    306 			assertTrue(
    307 					"Binary search on Object[] with custom comparator answered incorrect position",
    308 					Arrays.binarySearch(objectArray, objArray[counter], comp) == arraySize
    309 							- counter - 1);
    310 	}
    311 
    312 	/**
    313 	 * @tests java.util.Arrays#binarySearch(short[], short)
    314 	 */
    315 	public void test_binarySearch$SS() {
    316 		// Test for method int java.util.Arrays.binarySearch(short [], short)
    317 		for (short counter = 0; counter < arraySize; counter++)
    318 			assertTrue("Binary search on short[] answered incorrect position",
    319 					Arrays.binarySearch(shortArray, counter) == counter);
    320 		assertEquals("Binary search succeeded for value not present in array 1",
    321 				-1, Arrays.binarySearch(intArray, (short) -1));
    322 		assertTrue(
    323 				"Binary search succeeded for value not present in array 2",
    324 				Arrays.binarySearch(intArray, (short) arraySize) == -(arraySize + 1));
    325 		for (short counter = 0; counter < arraySize; counter++)
    326 			shortArray[counter] -= 50;
    327 		for (short counter = 0; counter < arraySize; counter++)
    328 			assertTrue(
    329 					"Binary search on short[] involving negative numbers answered incorrect position",
    330 					Arrays.binarySearch(shortArray, (short) (counter - 50)) == counter);
    331 	}
    332 
    333 	/**
    334 	 * @tests java.util.Arrays#fill(byte[], byte)
    335 	 */
    336 	public void test_fill$BB() {
    337 		// Test for method void java.util.Arrays.fill(byte [], byte)
    338 
    339 		byte d[] = new byte[1000];
    340 		Arrays.fill(d, Byte.MAX_VALUE);
    341 		for (int i = 0; i < d.length; i++)
    342 			assertTrue("Failed to fill byte array correctly",
    343 					d[i] == Byte.MAX_VALUE);
    344 	}
    345 
    346 	/**
    347 	 * @tests java.util.Arrays#fill(byte[], int, int, byte)
    348 	 */
    349 	public void test_fill$BIIB() {
    350 		// Test for method void java.util.Arrays.fill(byte [], int, int, byte)
    351 		byte val = Byte.MAX_VALUE;
    352 		byte d[] = new byte[1000];
    353 		Arrays.fill(d, 400, d.length, val);
    354 		for (int i = 0; i < 400; i++)
    355 			assertTrue("Filled elements not in range", !(d[i] == val));
    356 		for (int i = 400; i < d.length; i++)
    357 			assertTrue("Failed to fill byte array correctly", d[i] == val);
    358 
    359 		int result;
    360 		try {
    361 			Arrays.fill(new byte[2], 2, 1, (byte) 27);
    362 			result = 0;
    363 		} catch (ArrayIndexOutOfBoundsException e) {
    364 			result = 1;
    365 		} catch (IllegalArgumentException e) {
    366 			result = 2;
    367 		}
    368 		assertEquals("Wrong exception1", 2, result);
    369 		try {
    370 			Arrays.fill(new byte[2], -1, 1, (byte) 27);
    371 			result = 0;
    372 		} catch (ArrayIndexOutOfBoundsException e) {
    373 			result = 1;
    374 		} catch (IllegalArgumentException e) {
    375 			result = 2;
    376 		}
    377 		assertEquals("Wrong exception2", 1, result);
    378 		try {
    379 			Arrays.fill(new byte[2], 1, 4, (byte) 27);
    380 			result = 0;
    381 		} catch (ArrayIndexOutOfBoundsException e) {
    382 			result = 1;
    383 		} catch (IllegalArgumentException e) {
    384 			result = 2;
    385 		}
    386 		assertEquals("Wrong exception", 1, result);
    387 	}
    388 
    389 	/**
    390 	 * @tests java.util.Arrays#fill(short[], short)
    391 	 */
    392 	public void test_fill$SS() {
    393 		// Test for method void java.util.Arrays.fill(short [], short)
    394 
    395 		short d[] = new short[1000];
    396 		Arrays.fill(d, Short.MAX_VALUE);
    397 		for (int i = 0; i < d.length; i++)
    398 			assertTrue("Failed to fill short array correctly",
    399 					d[i] == Short.MAX_VALUE);
    400 	}
    401 
    402 	/**
    403 	 * @tests java.util.Arrays#fill(short[], int, int, short)
    404 	 */
    405 	public void test_fill$SIIS() {
    406 		// Test for method void java.util.Arrays.fill(short [], int, int, short)
    407 		short val = Short.MAX_VALUE;
    408 		short d[] = new short[1000];
    409 		Arrays.fill(d, 400, d.length, val);
    410 		for (int i = 0; i < 400; i++)
    411 			assertTrue("Filled elements not in range", !(d[i] == val));
    412 		for (int i = 400; i < d.length; i++)
    413 			assertTrue("Failed to fill short array correctly", d[i] == val);
    414 	}
    415 
    416 	/**
    417 	 * @tests java.util.Arrays#fill(char[], char)
    418 	 */
    419 	public void test_fill$CC() {
    420 		// Test for method void java.util.Arrays.fill(char [], char)
    421 
    422 		char d[] = new char[1000];
    423 		Arrays.fill(d, 'V');
    424 		for (int i = 0; i < d.length; i++)
    425 			assertEquals("Failed to fill char array correctly", 'V', d[i]);
    426 	}
    427 
    428 	/**
    429 	 * @tests java.util.Arrays#fill(char[], int, int, char)
    430 	 */
    431 	public void test_fill$CIIC() {
    432 		// Test for method void java.util.Arrays.fill(char [], int, int, char)
    433 		char val = 'T';
    434 		char d[] = new char[1000];
    435 		Arrays.fill(d, 400, d.length, val);
    436 		for (int i = 0; i < 400; i++)
    437 			assertTrue("Filled elements not in range", !(d[i] == val));
    438 		for (int i = 400; i < d.length; i++)
    439 			assertTrue("Failed to fill char array correctly", d[i] == val);
    440 	}
    441 
    442 	/**
    443 	 * @tests java.util.Arrays#fill(int[], int)
    444 	 */
    445 	public void test_fill$II() {
    446 		// Test for method void java.util.Arrays.fill(int [], int)
    447 
    448 		int d[] = new int[1000];
    449 		Arrays.fill(d, Integer.MAX_VALUE);
    450 		for (int i = 0; i < d.length; i++)
    451 			assertTrue("Failed to fill int array correctly",
    452 					d[i] == Integer.MAX_VALUE);
    453 	}
    454 
    455 	/**
    456 	 * @tests java.util.Arrays#fill(int[], int, int, int)
    457 	 */
    458 	public void test_fill$IIII() {
    459 		// Test for method void java.util.Arrays.fill(int [], int, int, int)
    460 		int val = Integer.MAX_VALUE;
    461 		int d[] = new int[1000];
    462 		Arrays.fill(d, 400, d.length, val);
    463 		for (int i = 0; i < 400; i++)
    464 			assertTrue("Filled elements not in range", !(d[i] == val));
    465 		for (int i = 400; i < d.length; i++)
    466 			assertTrue("Failed to fill int array correctly", d[i] == val);
    467 	}
    468 
    469 	/**
    470 	 * @tests java.util.Arrays#fill(long[], long)
    471 	 */
    472 	public void test_fill$JJ() {
    473 		// Test for method void java.util.Arrays.fill(long [], long)
    474 
    475 		long d[] = new long[1000];
    476 		Arrays.fill(d, Long.MAX_VALUE);
    477 		for (int i = 0; i < d.length; i++)
    478 			assertTrue("Failed to fill long array correctly",
    479 					d[i] == Long.MAX_VALUE);
    480 	}
    481 
    482 	/**
    483 	 * @tests java.util.Arrays#fill(long[], int, int, long)
    484 	 */
    485 	public void test_fill$JIIJ() {
    486 		// Test for method void java.util.Arrays.fill(long [], int, int, long)
    487 		long d[] = new long[1000];
    488 		Arrays.fill(d, 400, d.length, Long.MAX_VALUE);
    489 		for (int i = 0; i < 400; i++)
    490 			assertTrue("Filled elements not in range", !(d[i] == Long.MAX_VALUE));
    491 		for (int i = 400; i < d.length; i++)
    492 			assertTrue("Failed to fill long array correctly",
    493 					d[i] == Long.MAX_VALUE);
    494 	}
    495 
    496 	/**
    497 	 * @tests java.util.Arrays#fill(float[], float)
    498 	 */
    499 	public void test_fill$FF() {
    500 		// Test for method void java.util.Arrays.fill(float [], float)
    501 		float d[] = new float[1000];
    502 		Arrays.fill(d, Float.MAX_VALUE);
    503 		for (int i = 0; i < d.length; i++)
    504 			assertTrue("Failed to fill float array correctly",
    505 					d[i] == Float.MAX_VALUE);
    506 	}
    507 
    508 	/**
    509 	 * @tests java.util.Arrays#fill(float[], int, int, float)
    510 	 */
    511 	public void test_fill$FIIF() {
    512 		// Test for method void java.util.Arrays.fill(float [], int, int, float)
    513 		float val = Float.MAX_VALUE;
    514 		float d[] = new float[1000];
    515 		Arrays.fill(d, 400, d.length, val);
    516 		for (int i = 0; i < 400; i++)
    517 			assertTrue("Filled elements not in range", !(d[i] == val));
    518 		for (int i = 400; i < d.length; i++)
    519 			assertTrue("Failed to fill float array correctly", d[i] == val);
    520 	}
    521 
    522 	/**
    523 	 * @tests java.util.Arrays#fill(double[], double)
    524 	 */
    525 	public void test_fill$DD() {
    526 		// Test for method void java.util.Arrays.fill(double [], double)
    527 
    528 		double d[] = new double[1000];
    529 		Arrays.fill(d, Double.MAX_VALUE);
    530 		for (int i = 0; i < d.length; i++)
    531 			assertTrue("Failed to fill double array correctly",
    532 					d[i] == Double.MAX_VALUE);
    533 	}
    534 
    535 	/**
    536 	 * @tests java.util.Arrays#fill(double[], int, int, double)
    537 	 */
    538 	public void test_fill$DIID() {
    539 		// Test for method void java.util.Arrays.fill(double [], int, int,
    540 		// double)
    541 		double val = Double.MAX_VALUE;
    542 		double d[] = new double[1000];
    543 		Arrays.fill(d, 400, d.length, val);
    544 		for (int i = 0; i < 400; i++)
    545 			assertTrue("Filled elements not in range", !(d[i] == val));
    546 		for (int i = 400; i < d.length; i++)
    547 			assertTrue("Failed to fill double array correctly", d[i] == val);
    548 	}
    549 
    550 	/**
    551 	 * @tests java.util.Arrays#fill(boolean[], boolean)
    552 	 */
    553 	public void test_fill$ZZ() {
    554 		// Test for method void java.util.Arrays.fill(boolean [], boolean)
    555 
    556 		boolean d[] = new boolean[1000];
    557 		Arrays.fill(d, true);
    558 		for (int i = 0; i < d.length; i++)
    559 			assertTrue("Failed to fill boolean array correctly", d[i]);
    560 	}
    561 
    562 	/**
    563 	 * @tests java.util.Arrays#fill(boolean[], int, int, boolean)
    564 	 */
    565 	public void test_fill$ZIIZ() {
    566 		// Test for method void java.util.Arrays.fill(boolean [], int, int,
    567 		// boolean)
    568 		boolean val = true;
    569 		boolean d[] = new boolean[1000];
    570 		Arrays.fill(d, 400, d.length, val);
    571 		for (int i = 0; i < 400; i++)
    572 			assertTrue("Filled elements not in range", !(d[i] == val));
    573 		for (int i = 400; i < d.length; i++)
    574 			assertTrue("Failed to fill boolean array correctly", d[i] == val);
    575 	}
    576 
    577 	/**
    578 	 * @tests java.util.Arrays#fill(java.lang.Object[], java.lang.Object)
    579 	 */
    580 	public void test_fill$Ljava_lang_ObjectLjava_lang_Object() {
    581 		// Test for method void java.util.Arrays.fill(java.lang.Object [],
    582 		// java.lang.Object)
    583 		Object val = new Object();
    584 		Object d[] = new Object[1000];
    585 		Arrays.fill(d, 0, d.length, val);
    586 		for (int i = 0; i < d.length; i++)
    587 			assertTrue("Failed to fill Object array correctly", d[i] == val);
    588 	}
    589 
    590 	/**
    591 	 * @tests java.util.Arrays#fill(java.lang.Object[], int, int,
    592 	 *        java.lang.Object)
    593 	 */
    594 	public void test_fill$Ljava_lang_ObjectIILjava_lang_Object() {
    595 		// Test for method void java.util.Arrays.fill(java.lang.Object [], int,
    596 		// int, java.lang.Object)
    597 		Object val = new Object();
    598 		Object d[] = new Object[1000];
    599 		Arrays.fill(d, 400, d.length, val);
    600 		for (int i = 0; i < 400; i++)
    601 			assertTrue("Filled elements not in range", !(d[i] == val));
    602 		for (int i = 400; i < d.length; i++)
    603 			assertTrue("Failed to fill Object array correctly", d[i] == val);
    604 
    605 		Arrays.fill(d, 400, d.length, null);
    606 		for (int i = 400; i < d.length; i++)
    607 			assertNull("Failed to fill Object array correctly with nulls",
    608 					d[i]);
    609 	}
    610 
    611 	/**
    612 	 * @tests java.util.Arrays#equals(byte[], byte[])
    613 	 */
    614 	public void test_equals$B$B() {
    615 		// Test for method boolean java.util.Arrays.equals(byte [], byte [])
    616 		byte d[] = new byte[1000];
    617 		byte x[] = new byte[1000];
    618 		Arrays.fill(d, Byte.MAX_VALUE);
    619 		Arrays.fill(x, Byte.MIN_VALUE);
    620 		assertTrue("Inequal arrays returned true", !Arrays.equals(d, x));
    621 		Arrays.fill(x, Byte.MAX_VALUE);
    622 		assertTrue("equal arrays returned false", Arrays.equals(d, x));
    623 	}
    624 
    625 	/**
    626 	 * @tests java.util.Arrays#equals(short[], short[])
    627 	 */
    628 	public void test_equals$S$S() {
    629 		// Test for method boolean java.util.Arrays.equals(short [], short [])
    630 		short d[] = new short[1000];
    631 		short x[] = new short[1000];
    632 		Arrays.fill(d, Short.MAX_VALUE);
    633 		Arrays.fill(x, Short.MIN_VALUE);
    634 		assertTrue("Inequal arrays returned true", !Arrays.equals(d, x));
    635 		Arrays.fill(x, Short.MAX_VALUE);
    636 		assertTrue("equal arrays returned false", Arrays.equals(d, x));
    637 	}
    638 
    639 	/**
    640 	 * @tests java.util.Arrays#equals(char[], char[])
    641 	 */
    642 	public void test_equals$C$C() {
    643 		// Test for method boolean java.util.Arrays.equals(char [], char [])
    644 		char d[] = new char[1000];
    645 		char x[] = new char[1000];
    646 		char c = 'T';
    647 		Arrays.fill(d, c);
    648 		Arrays.fill(x, 'L');
    649 		assertTrue("Inequal arrays returned true", !Arrays.equals(d, x));
    650 		Arrays.fill(x, c);
    651 		assertTrue("equal arrays returned false", Arrays.equals(d, x));
    652 	}
    653 
    654 	/**
    655 	 * @tests java.util.Arrays#equals(int[], int[])
    656 	 */
    657 	public void test_equals$I$I() {
    658 		// Test for method boolean java.util.Arrays.equals(int [], int [])
    659 		int d[] = new int[1000];
    660 		int x[] = new int[1000];
    661 		Arrays.fill(d, Integer.MAX_VALUE);
    662 		Arrays.fill(x, Integer.MIN_VALUE);
    663 		assertTrue("Inequal arrays returned true", !Arrays.equals(d, x));
    664 		Arrays.fill(x, Integer.MAX_VALUE);
    665 		assertTrue("equal arrays returned false", Arrays.equals(d, x));
    666 
    667 		assertTrue("wrong result for null array1", !Arrays.equals(new int[2],
    668 				null));
    669 		assertTrue("wrong result for null array2", !Arrays.equals(null,
    670 				new int[2]));
    671 	}
    672 
    673 	/**
    674 	 * @tests java.util.Arrays#equals(long[], long[])
    675 	 */
    676 	public void test_equals$J$J() {
    677 		// Test for method boolean java.util.Arrays.equals(long [], long [])
    678 		long d[] = new long[1000];
    679 		long x[] = new long[1000];
    680 		Arrays.fill(d, Long.MAX_VALUE);
    681 		Arrays.fill(x, Long.MIN_VALUE);
    682 		assertTrue("Inequal arrays returned true", !Arrays.equals(d, x));
    683 		Arrays.fill(x, Long.MAX_VALUE);
    684 		assertTrue("equal arrays returned false", Arrays.equals(d, x));
    685 
    686 		assertTrue("should be false", !Arrays.equals(
    687 				new long[] { 0x100000000L }, new long[] { 0x200000000L }));
    688 
    689 	}
    690 
    691 	/**
    692 	 * @tests java.util.Arrays#equals(float[], float[])
    693 	 */
    694 	public void test_equals$F$F() {
    695 		// Test for method boolean java.util.Arrays.equals(float [], float [])
    696 		float d[] = new float[1000];
    697 		float x[] = new float[1000];
    698 		Arrays.fill(d, Float.MAX_VALUE);
    699 		Arrays.fill(x, Float.MIN_VALUE);
    700 		assertTrue("Inequal arrays returned true", !Arrays.equals(d, x));
    701 		Arrays.fill(x, Float.MAX_VALUE);
    702 		assertTrue("equal arrays returned false", Arrays.equals(d, x));
    703 
    704 		assertTrue("NaN not equals", Arrays.equals(new float[] { Float.NaN },
    705 				new float[] { Float.NaN }));
    706 		assertTrue("0f equals -0f", !Arrays.equals(new float[] { 0f },
    707 				new float[] { -0f }));
    708 	}
    709 
    710 	/**
    711 	 * @tests java.util.Arrays#equals(double[], double[])
    712 	 */
    713 	public void test_equals$D$D() {
    714 		// Test for method boolean java.util.Arrays.equals(double [], double [])
    715 		double d[] = new double[1000];
    716 		double x[] = new double[1000];
    717 		Arrays.fill(d, Double.MAX_VALUE);
    718 		Arrays.fill(x, Double.MIN_VALUE);
    719 		assertTrue("Inequal arrays returned true", !Arrays.equals(d, x));
    720 		Arrays.fill(x, Double.MAX_VALUE);
    721 		assertTrue("equal arrays returned false", Arrays.equals(d, x));
    722 
    723 		assertTrue("should be false", !Arrays.equals(new double[] { 1.0 },
    724 				new double[] { 2.0 }));
    725 
    726 		assertTrue("NaN not equals", Arrays.equals(new double[] { Double.NaN },
    727 				new double[] { Double.NaN }));
    728 		assertTrue("0d equals -0d", !Arrays.equals(new double[] { 0d },
    729 				new double[] { -0d }));
    730 	}
    731 
    732 	/**
    733 	 * @tests java.util.Arrays#equals(boolean[], boolean[])
    734 	 */
    735 	public void test_equals$Z$Z() {
    736 		// Test for method boolean java.util.Arrays.equals(boolean [], boolean
    737 		// [])
    738 		boolean d[] = new boolean[1000];
    739 		boolean x[] = new boolean[1000];
    740 		Arrays.fill(d, true);
    741 		Arrays.fill(x, false);
    742 		assertTrue("Inequal arrays returned true", !Arrays.equals(d, x));
    743 		Arrays.fill(x, true);
    744 		assertTrue("equal arrays returned false", Arrays.equals(d, x));
    745 	}
    746 
    747 	/**
    748 	 * @tests java.util.Arrays#equals(java.lang.Object[], java.lang.Object[])
    749 	 */
    750 	public void test_equals$Ljava_lang_Object$Ljava_lang_Object() {
    751 		// Test for method boolean java.util.Arrays.equals(java.lang.Object [],
    752 		// java.lang.Object [])
    753 		Object d[] = new Object[1000];
    754 		Object x[] = new Object[1000];
    755 		Object o = new Object();
    756 		Arrays.fill(d, o);
    757 		Arrays.fill(x, new Object());
    758 		assertTrue("Inequal arrays returned true", !Arrays.equals(d, x));
    759 		Arrays.fill(x, o);
    760 		d[50] = null;
    761 		x[50] = null;
    762 		assertTrue("equal arrays returned false", Arrays.equals(d, x));
    763 	}
    764 
    765 	/**
    766 	 * @tests java.util.Arrays#sort(byte[])
    767 	 */
    768 	public void test_sort$B() {
    769 		// Test for method void java.util.Arrays.sort(byte [])
    770 		byte[] reversedArray = new byte[arraySize];
    771 		for (int counter = 0; counter < arraySize; counter++)
    772 			reversedArray[counter] = (byte) (arraySize - counter - 1);
    773 		Arrays.sort(reversedArray);
    774 		for (int counter = 0; counter < arraySize; counter++)
    775 			assertTrue("Resulting array not sorted",
    776 					reversedArray[counter] == (byte) counter);
    777 	}
    778 
    779 	/**
    780 	 * @tests java.util.Arrays#sort(byte[], int, int)
    781 	 */
    782 	public void test_sort$BII() {
    783 		// Test for method void java.util.Arrays.sort(byte [], int, int)
    784 		int startIndex = arraySize / 4;
    785 		int endIndex = 3 * arraySize / 4;
    786 		byte[] reversedArray = new byte[arraySize];
    787 		byte[] originalReversedArray = new byte[arraySize];
    788 		for (int counter = 0; counter < arraySize; counter++) {
    789 			reversedArray[counter] = (byte) (arraySize - counter - 1);
    790 			originalReversedArray[counter] = reversedArray[counter];
    791 		}
    792 		Arrays.sort(reversedArray, startIndex, endIndex);
    793 		for (int counter = 0; counter < startIndex; counter++)
    794 			assertTrue("Array modified outside of bounds",
    795 					reversedArray[counter] == originalReversedArray[counter]);
    796 		for (int counter = startIndex; counter < endIndex - 1; counter++)
    797 			assertTrue("Array not sorted within bounds",
    798 					reversedArray[counter] <= reversedArray[counter + 1]);
    799 		for (int counter = endIndex; counter < arraySize; counter++)
    800 			assertTrue("Array modified outside of bounds",
    801 					reversedArray[counter] == originalReversedArray[counter]);
    802 
    803 		//exception testing
    804 		try {
    805 			Arrays.sort(reversedArray, startIndex + 1, startIndex);
    806             fail("IllegalArgumentException expected");
    807 		} catch (IllegalArgumentException ignore) {
    808 		}
    809 
    810         try {
    811 			Arrays.sort(reversedArray, -1, startIndex);
    812             fail("ArrayIndexOutOfBoundsException expected (1)");
    813 		} catch (ArrayIndexOutOfBoundsException ignore) {
    814 		}
    815 
    816 		try {
    817 			Arrays.sort(reversedArray, startIndex, reversedArray.length + 1);
    818             fail("ArrayIndexOutOfBoundsException expected (2)");
    819 		} catch (ArrayIndexOutOfBoundsException ignore) {
    820 		}
    821 
    822 		//exception order testing
    823 		try {
    824 			Arrays.sort(new byte[1], startIndex + 1, startIndex);
    825             fail("IllegalArgumentException expected");
    826 		} catch (IllegalArgumentException ignore) {
    827 		}
    828 	}
    829 
    830 	/**
    831 	 * @tests java.util.Arrays#sort(char[])
    832 	 */
    833 	public void test_sort$C() {
    834 		// Test for method void java.util.Arrays.sort(char [])
    835 		char[] reversedArray = new char[arraySize];
    836 		for (int counter = 0; counter < arraySize; counter++)
    837 			reversedArray[counter] = (char) (arraySize - counter - 1);
    838 		Arrays.sort(reversedArray);
    839 		for (int counter = 0; counter < arraySize; counter++)
    840 			assertTrue("Resulting array not sorted",
    841 					reversedArray[counter] == (char) counter);
    842 
    843 	}
    844 
    845 	/**
    846 	 * @tests java.util.Arrays#sort(char[], int, int)
    847 	 */
    848 	public void test_sort$CII() {
    849 		// Test for method void java.util.Arrays.sort(char [], int, int)
    850 		int startIndex = arraySize / 4;
    851 		int endIndex = 3 * arraySize / 4;
    852 		char[] reversedArray = new char[arraySize];
    853 		char[] originalReversedArray = new char[arraySize];
    854 		for (int counter = 0; counter < arraySize; counter++) {
    855 			reversedArray[counter] = (char) (arraySize - counter - 1);
    856 			originalReversedArray[counter] = reversedArray[counter];
    857 		}
    858 		Arrays.sort(reversedArray, startIndex, endIndex);
    859 		for (int counter = 0; counter < startIndex; counter++)
    860 			assertTrue("Array modified outside of bounds",
    861 					reversedArray[counter] == originalReversedArray[counter]);
    862 		for (int counter = startIndex; counter < endIndex - 1; counter++)
    863 			assertTrue("Array not sorted within bounds",
    864 					reversedArray[counter] <= reversedArray[counter + 1]);
    865 		for (int counter = endIndex; counter < arraySize; counter++)
    866 			assertTrue("Array modified outside of bounds",
    867 					reversedArray[counter] == originalReversedArray[counter]);
    868 
    869 		//exception testing
    870 		try {
    871 			Arrays.sort(reversedArray, startIndex + 1, startIndex);
    872             fail("IllegalArgumentException expected");
    873 		} catch (IllegalArgumentException ignore) {
    874 		}
    875 
    876 		try {
    877 			Arrays.sort(reversedArray, -1, startIndex);
    878             fail("ArrayIndexOutOfBoundsException expected (1)");
    879 		} catch (ArrayIndexOutOfBoundsException ignore) {
    880 		}
    881 
    882 		try {
    883 			Arrays.sort(reversedArray, startIndex, reversedArray.length + 1);
    884             fail("ArrayIndexOutOfBoundsException expected (2)");
    885 		} catch (ArrayIndexOutOfBoundsException ignore) {
    886 		}
    887 
    888 		//exception order testing
    889 		try {
    890 			Arrays.sort(new char[1], startIndex + 1, startIndex);
    891             fail("IllegalArgumentException expected");
    892 		} catch (IllegalArgumentException ignore) {
    893 		}
    894 	}
    895 
    896 	/**
    897 	 * @tests java.util.Arrays#sort(double[])
    898 	 */
    899 	public void test_sort$D() {
    900 		// Test for method void java.util.Arrays.sort(double [])
    901 		double[] reversedArray = new double[arraySize];
    902 		for (int counter = 0; counter < arraySize; counter++)
    903 			reversedArray[counter] = (double) (arraySize - counter - 1);
    904 		Arrays.sort(reversedArray);
    905 		for (int counter = 0; counter < arraySize; counter++)
    906 			assertTrue("Resulting array not sorted",
    907 					reversedArray[counter] == (double) counter);
    908 
    909 		double[] specials1 = new double[] { Double.NaN, Double.MAX_VALUE,
    910 				Double.MIN_VALUE, 0d, -0d, Double.POSITIVE_INFINITY,
    911 				Double.NEGATIVE_INFINITY };
    912 		double[] specials2 = new double[] { 0d, Double.POSITIVE_INFINITY, -0d,
    913 				Double.NEGATIVE_INFINITY, Double.MIN_VALUE, Double.NaN,
    914 				Double.MAX_VALUE };
    915         double[] specials3 = new double[] { 0.0, Double.NaN, 1.0, 2.0, Double.NaN,
    916                 Double.NaN, 1.0, 3.0, -0.0};
    917 		double[] answer = new double[] { Double.NEGATIVE_INFINITY, -0d, 0d,
    918 				Double.MIN_VALUE, Double.MAX_VALUE, Double.POSITIVE_INFINITY,
    919 				Double.NaN };
    920         double[] answer3 = new double[] { -0.0, 0.0, 1.0, 1.0, 2.0, 3.0, Double.NaN,
    921                 Double.NaN, Double.NaN };
    922 
    923 		Arrays.sort(specials1);
    924 		Object[] print1 = new Object[specials1.length];
    925 		for (int i = 0; i < specials1.length; i++)
    926 			print1[i] = new Double(specials1[i]);
    927 		assertTrue("specials sort incorrectly 1: " + Arrays.asList(print1),
    928 				Arrays.equals(specials1, answer));
    929 
    930 		Arrays.sort(specials2);
    931 		Object[] print2 = new Object[specials2.length];
    932 		for (int i = 0; i < specials2.length; i++)
    933 			print2[i] = new Double(specials2[i]);
    934 		assertTrue("specials sort incorrectly 2: " + Arrays.asList(print2),
    935 				Arrays.equals(specials2, answer));
    936 
    937         Arrays.sort(specials3);
    938         Object[] print3 = new Object[specials3.length];
    939         for (int i = 0; i < specials3.length; i++)
    940             print3[i] = new Double(specials3[i]);
    941         assertTrue("specials sort incorrectly 3: " + Arrays.asList(print3),
    942                 Arrays.equals(specials3, answer3));
    943 	}
    944 
    945 	/**
    946 	 * @tests java.util.Arrays#sort(double[], int, int)
    947 	 */
    948 	public void test_sort$DII() {
    949 		// Test for method void java.util.Arrays.sort(double [], int, int)
    950 		int startIndex = arraySize / 4;
    951 		int endIndex = 3 * arraySize / 4;
    952 		double[] reversedArray = new double[arraySize];
    953 		double[] originalReversedArray = new double[arraySize];
    954 		for (int counter = 0; counter < arraySize; counter++) {
    955 			reversedArray[counter] = (double) (arraySize - counter - 1);
    956 			originalReversedArray[counter] = reversedArray[counter];
    957 		}
    958 		Arrays.sort(reversedArray, startIndex, endIndex);
    959 		for (int counter = 0; counter < startIndex; counter++)
    960 			assertTrue("Array modified outside of bounds",
    961 					reversedArray[counter] == originalReversedArray[counter]);
    962 		for (int counter = startIndex; counter < endIndex - 1; counter++)
    963 			assertTrue("Array not sorted within bounds",
    964 					reversedArray[counter] <= reversedArray[counter + 1]);
    965 		for (int counter = endIndex; counter < arraySize; counter++)
    966 			assertTrue("Array modified outside of bounds",
    967 					reversedArray[counter] == originalReversedArray[counter]);
    968 
    969 		//exception testing
    970 		try {
    971 			Arrays.sort(reversedArray, startIndex + 1, startIndex);
    972             fail("IllegalArgumentException expected");
    973 		} catch (IllegalArgumentException ignore) {
    974 		}
    975 
    976 		try {
    977 			Arrays.sort(reversedArray, -1, startIndex);
    978             fail("ArrayIndexOutOfBoundsException expected (1)");
    979 		} catch (ArrayIndexOutOfBoundsException ignore) {
    980 		}
    981 
    982 		try {
    983 			Arrays.sort(reversedArray, startIndex, reversedArray.length + 1);
    984             fail("ArrayIndexOutOfBoundsException expected (2)");
    985 		} catch (ArrayIndexOutOfBoundsException ignore) {
    986 		}
    987 
    988 		//exception order testing
    989 		try {
    990 			Arrays.sort(new double[1], startIndex + 1, startIndex);
    991             fail("IllegalArgumentException expected");
    992 		} catch (IllegalArgumentException ignore) {
    993 		}
    994 	}
    995 
    996 	/**
    997 	 * @tests java.util.Arrays#sort(float[])
    998 	 */
    999 	public void test_sort$F() {
   1000 		// Test for method void java.util.Arrays.sort(float [])
   1001 		float[] reversedArray = new float[arraySize];
   1002 		for (int counter = 0; counter < arraySize; counter++)
   1003 			reversedArray[counter] = (float) (arraySize - counter - 1);
   1004 		Arrays.sort(reversedArray);
   1005 		for (int counter = 0; counter < arraySize; counter++)
   1006 			assertTrue("Resulting array not sorted",
   1007 					reversedArray[counter] == (float) counter);
   1008 
   1009 		float[] specials1 = new float[] { Float.NaN, Float.MAX_VALUE,
   1010 				Float.MIN_VALUE, 0f, -0f, Float.POSITIVE_INFINITY,
   1011 				Float.NEGATIVE_INFINITY };
   1012 		float[] specials2 = new float[] { 0f, Float.POSITIVE_INFINITY, -0f,
   1013 				Float.NEGATIVE_INFINITY, Float.MIN_VALUE, Float.NaN,
   1014 				Float.MAX_VALUE };
   1015 		float[] answer = new float[] { Float.NEGATIVE_INFINITY, -0f, 0f,
   1016 				Float.MIN_VALUE, Float.MAX_VALUE, Float.POSITIVE_INFINITY,
   1017 				Float.NaN };
   1018 
   1019 		Arrays.sort(specials1);
   1020 		Object[] print1 = new Object[specials1.length];
   1021 		for (int i = 0; i < specials1.length; i++)
   1022 			print1[i] = new Float(specials1[i]);
   1023 		assertTrue("specials sort incorrectly 1: " + Arrays.asList(print1),
   1024 				Arrays.equals(specials1, answer));
   1025 
   1026 		Arrays.sort(specials2);
   1027 		Object[] print2 = new Object[specials2.length];
   1028 		for (int i = 0; i < specials2.length; i++)
   1029 			print2[i] = new Float(specials2[i]);
   1030 		assertTrue("specials sort incorrectly 2: " + Arrays.asList(print2),
   1031 				Arrays.equals(specials2, answer));
   1032 	}
   1033 
   1034 	/**
   1035 	 * @tests java.util.Arrays#sort(float[], int, int)
   1036 	 */
   1037 	public void test_sort$FII() {
   1038 		// Test for method void java.util.Arrays.sort(float [], int, int)
   1039 		int startIndex = arraySize / 4;
   1040 		int endIndex = 3 * arraySize / 4;
   1041 		float[] reversedArray = new float[arraySize];
   1042 		float[] originalReversedArray = new float[arraySize];
   1043 		for (int counter = 0; counter < arraySize; counter++) {
   1044 			reversedArray[counter] = (float) (arraySize - counter - 1);
   1045 			originalReversedArray[counter] = reversedArray[counter];
   1046 		}
   1047 		Arrays.sort(reversedArray, startIndex, endIndex);
   1048 		for (int counter = 0; counter < startIndex; counter++)
   1049 			assertTrue("Array modified outside of bounds",
   1050 					reversedArray[counter] == originalReversedArray[counter]);
   1051 		for (int counter = startIndex; counter < endIndex - 1; counter++)
   1052 			assertTrue("Array not sorted within bounds",
   1053 					reversedArray[counter] <= reversedArray[counter + 1]);
   1054 		for (int counter = endIndex; counter < arraySize; counter++)
   1055 			assertTrue("Array modified outside of bounds",
   1056 					reversedArray[counter] == originalReversedArray[counter]);
   1057 
   1058 		//exception testing
   1059 		try {
   1060 			Arrays.sort(reversedArray, startIndex + 1, startIndex);
   1061             fail("IllegalArgumentException expected");
   1062 		} catch (IllegalArgumentException ignore) {
   1063 		}
   1064 
   1065         try {
   1066 			Arrays.sort(reversedArray, -1, startIndex);
   1067             fail("ArrayIndexOutOfBoundsException expected (1)");
   1068 		} catch (ArrayIndexOutOfBoundsException ignore) {
   1069 		}
   1070 
   1071 		try {
   1072 			Arrays.sort(reversedArray, startIndex, reversedArray.length + 1);
   1073             fail("ArrayIndexOutOfBoundsException expected (2)");
   1074 		} catch (ArrayIndexOutOfBoundsException ignore) {
   1075 		}
   1076 
   1077 		//exception order testing
   1078 		try {
   1079 			Arrays.sort(new float[1], startIndex + 1, startIndex);
   1080             fail("IllegalArgumentException expected");
   1081 		} catch (IllegalArgumentException ignore) {
   1082 		}
   1083 	}
   1084 
   1085 	/**
   1086 	 * @tests java.util.Arrays#sort(int[])
   1087 	 */
   1088 	public void test_sort$I() {
   1089 		// Test for method void java.util.Arrays.sort(int [])
   1090 		int[] reversedArray = new int[arraySize];
   1091 		for (int counter = 0; counter < arraySize; counter++)
   1092 			reversedArray[counter] = arraySize - counter - 1;
   1093 		Arrays.sort(reversedArray);
   1094 		for (int counter = 0; counter < arraySize; counter++)
   1095 			assertTrue("Resulting array not sorted",
   1096 					reversedArray[counter] == counter);
   1097 	}
   1098 
   1099 	/**
   1100 	 * @tests java.util.Arrays#sort(int[], int, int)
   1101 	 */
   1102 	public void test_sort$III() {
   1103 		// Test for method void java.util.Arrays.sort(int [], int, int)
   1104 		int startIndex = arraySize / 4;
   1105 		int endIndex = 3 * arraySize / 4;
   1106 		int[] reversedArray = new int[arraySize];
   1107 		int[] originalReversedArray = new int[arraySize];
   1108 		for (int counter = 0; counter < arraySize; counter++) {
   1109 			reversedArray[counter] = arraySize - counter - 1;
   1110 			originalReversedArray[counter] = reversedArray[counter];
   1111 		}
   1112 		Arrays.sort(reversedArray, startIndex, endIndex);
   1113 		for (int counter = 0; counter < startIndex; counter++)
   1114 			assertTrue("Array modified outside of bounds",
   1115 					reversedArray[counter] == originalReversedArray[counter]);
   1116 		for (int counter = startIndex; counter < endIndex - 1; counter++)
   1117 			assertTrue("Array not sorted within bounds",
   1118 					reversedArray[counter] <= reversedArray[counter + 1]);
   1119 		for (int counter = endIndex; counter < arraySize; counter++)
   1120 			assertTrue("Array modified outside of bounds",
   1121 					reversedArray[counter] == originalReversedArray[counter]);
   1122 
   1123 		//exception testing
   1124 		try {
   1125 			Arrays.sort(reversedArray, startIndex + 1, startIndex);
   1126             fail("IllegalArgumentException expected");
   1127 		} catch (IllegalArgumentException ignore) {
   1128 		}
   1129 
   1130         try {
   1131 			Arrays.sort(reversedArray, -1, startIndex);
   1132             fail("ArrayIndexOutOfBoundsException expected (1)");
   1133 		} catch (ArrayIndexOutOfBoundsException ignore) {
   1134 		}
   1135 
   1136 		try {
   1137 			Arrays.sort(reversedArray, startIndex, reversedArray.length + 1);
   1138             fail("ArrayIndexOutOfBoundsException expected (2)");
   1139 		} catch (ArrayIndexOutOfBoundsException ignore) {
   1140 		}
   1141 
   1142 		//exception order testing
   1143 		try {
   1144 			Arrays.sort(new int[1], startIndex + 1, startIndex);
   1145             fail("IllegalArgumentException expected");
   1146 		} catch (IllegalArgumentException ignore) {
   1147 		}
   1148 	}
   1149 
   1150 	/**
   1151 	 * @tests java.util.Arrays#sort(long[])
   1152 	 */
   1153 	public void test_sort$J() {
   1154 		// Test for method void java.util.Arrays.sort(long [])
   1155 		long[] reversedArray = new long[arraySize];
   1156 		for (int counter = 0; counter < arraySize; counter++)
   1157 			reversedArray[counter] = (long) (arraySize - counter - 1);
   1158 		Arrays.sort(reversedArray);
   1159 		for (int counter = 0; counter < arraySize; counter++)
   1160 			assertTrue("Resulting array not sorted",
   1161 					reversedArray[counter] == (long) counter);
   1162 
   1163 	}
   1164 
   1165 	/**
   1166 	 * @tests java.util.Arrays#sort(long[], int, int)
   1167 	 */
   1168 	public void test_sort$JII() {
   1169 		// Test for method void java.util.Arrays.sort(long [], int, int)
   1170 		int startIndex = arraySize / 4;
   1171 		int endIndex = 3 * arraySize / 4;
   1172 		long[] reversedArray = new long[arraySize];
   1173 		long[] originalReversedArray = new long[arraySize];
   1174 		for (int counter = 0; counter < arraySize; counter++) {
   1175 			reversedArray[counter] = (long) (arraySize - counter - 1);
   1176 			originalReversedArray[counter] = reversedArray[counter];
   1177 		}
   1178 		Arrays.sort(reversedArray, startIndex, endIndex);
   1179 		for (int counter = 0; counter < startIndex; counter++)
   1180 			assertTrue("Array modified outside of bounds",
   1181 					reversedArray[counter] == originalReversedArray[counter]);
   1182 		for (int counter = startIndex; counter < endIndex - 1; counter++)
   1183 			assertTrue("Array not sorted within bounds",
   1184 					reversedArray[counter] <= reversedArray[counter + 1]);
   1185 		for (int counter = endIndex; counter < arraySize; counter++)
   1186 			assertTrue("Array modified outside of bounds",
   1187 					reversedArray[counter] == originalReversedArray[counter]);
   1188 
   1189 		//exception testing
   1190 		try {
   1191 			Arrays.sort(reversedArray, startIndex + 1, startIndex);
   1192             fail("IllegalArgumentException expected");
   1193 		} catch (IllegalArgumentException ignore) {
   1194 		}
   1195 
   1196         try {
   1197 			Arrays.sort(reversedArray, -1, startIndex);
   1198             fail("ArrayIndexOutOfBoundsException expected (1)");
   1199 		} catch (ArrayIndexOutOfBoundsException ignore) {
   1200 		}
   1201 
   1202 		try {
   1203 			Arrays.sort(reversedArray, startIndex, reversedArray.length + 1);
   1204             fail("ArrayIndexOutOfBoundsException expected (2)");
   1205 		} catch (ArrayIndexOutOfBoundsException ignore) {
   1206 		}
   1207 
   1208 		//exception order testing
   1209 		try {
   1210 			Arrays.sort(new long[1], startIndex + 1, startIndex);
   1211             fail("IllegalArgumentException expected");
   1212 		} catch (IllegalArgumentException ignore) {
   1213 		}
   1214 	}
   1215 
   1216 	/**
   1217 	 * @tests java.util.Arrays#sort(java.lang.Object[])
   1218 	 */
   1219 	public void test_sort$Ljava_lang_Object() {
   1220 		// Test for method void java.util.Arrays.sort(java.lang.Object [])
   1221 		Object[] reversedArray = new Object[arraySize];
   1222 		for (int counter = 0; counter < arraySize; counter++)
   1223 			reversedArray[counter] = objectArray[arraySize - counter - 1];
   1224 		Arrays.sort(reversedArray);
   1225 		for (int counter = 0; counter < arraySize; counter++)
   1226 			assertTrue("Resulting array not sorted",
   1227 					reversedArray[counter] == objectArray[counter]);
   1228 	}
   1229 
   1230 	/**
   1231 	 * @tests java.util.Arrays#sort(java.lang.Object[], int, int)
   1232 	 */
   1233 	public void test_sort$Ljava_lang_ObjectII() {
   1234 		// Test for method void java.util.Arrays.sort(java.lang.Object [], int,
   1235 		// int)
   1236 		int startIndex = arraySize / 4;
   1237 		int endIndex = 3 * arraySize / 4;
   1238 		Object[] reversedArray = new Object[arraySize];
   1239 		Object[] originalReversedArray = new Object[arraySize];
   1240 		for (int counter = 0; counter < arraySize; counter++) {
   1241 			reversedArray[counter] = objectArray[arraySize - counter - 1];
   1242 			originalReversedArray[counter] = reversedArray[counter];
   1243 		}
   1244 		Arrays.sort(reversedArray, startIndex, endIndex);
   1245 		for (int counter = 0; counter < startIndex; counter++)
   1246 			assertTrue("Array modified outside of bounds",
   1247 					reversedArray[counter] == originalReversedArray[counter]);
   1248 		for (int counter = startIndex; counter < endIndex - 1; counter++)
   1249 			assertTrue("Array not sorted within bounds",
   1250 					((Comparable) reversedArray[counter])
   1251 							.compareTo(reversedArray[counter + 1]) <= 0);
   1252 		for (int counter = endIndex; counter < arraySize; counter++)
   1253 			assertTrue("Array modified outside of bounds",
   1254 					reversedArray[counter] == originalReversedArray[counter]);
   1255 
   1256 		//exception testing
   1257 		try {
   1258 			Arrays.sort(reversedArray, startIndex + 1, startIndex);
   1259             fail("IllegalArgumentException expected");
   1260 		} catch (IllegalArgumentException ignore) {
   1261 		}
   1262 
   1263 		try {
   1264 			Arrays.sort(reversedArray, -1, startIndex);
   1265             fail("ArrayIndexOutOfBoundsException expected (1)");
   1266 		} catch (ArrayIndexOutOfBoundsException ignore) {
   1267 		}
   1268 
   1269         try {
   1270 			Arrays.sort(reversedArray, startIndex, reversedArray.length + 1);
   1271             fail("ArrayIndexOutOfBoundsException expected (2)");
   1272 		} catch (ArrayIndexOutOfBoundsException ignore) {
   1273 		}
   1274 
   1275 		//exception order testing
   1276 		try {
   1277 			Arrays.sort(new Object[1], startIndex + 1, startIndex);
   1278             fail("IllegalArgumentException expected");
   1279 		} catch (IllegalArgumentException ignore) {
   1280 		}
   1281 	}
   1282 
   1283 	/**
   1284 	 * @tests java.util.Arrays#sort(java.lang.Object[], int, int,
   1285 	 *        java.util.Comparator)
   1286 	 */
   1287 	public void test_sort$Ljava_lang_ObjectIILjava_util_Comparator() {
   1288 		// Test for method void java.util.Arrays.sort(java.lang.Object [], int,
   1289 		// int, java.util.Comparator)
   1290 		int startIndex = arraySize / 4;
   1291 		int endIndex = 3 * arraySize / 4;
   1292 		ReversedIntegerComparator comp = new ReversedIntegerComparator();
   1293 		Object[] originalArray = new Object[arraySize];
   1294 		for (int counter = 0; counter < arraySize; counter++)
   1295 			originalArray[counter] = objectArray[counter];
   1296 		Arrays.sort(objectArray, startIndex, endIndex, comp);
   1297 		for (int counter = 0; counter < startIndex; counter++)
   1298 			assertTrue("Array modified outside of bounds",
   1299 					objectArray[counter] == originalArray[counter]);
   1300 		for (int counter = startIndex; counter < endIndex - 1; counter++)
   1301 			assertTrue("Array not sorted within bounds", comp.compare(
   1302 					objectArray[counter], objectArray[counter + 1]) <= 0);
   1303 		for (int counter = endIndex; counter < arraySize; counter++)
   1304 			assertTrue("Array modified outside of bounds",
   1305 					objectArray[counter] == originalArray[counter]);
   1306 	}
   1307 
   1308 	/**
   1309 	 * @tests java.util.Arrays#sort(java.lang.Object[], java.util.Comparator)
   1310 	 */
   1311 	public void test_sort$Ljava_lang_ObjectLjava_util_Comparator() {
   1312 		// Test for method void java.util.Arrays.sort(java.lang.Object [],
   1313 		// java.util.Comparator)
   1314 		ReversedIntegerComparator comp = new ReversedIntegerComparator();
   1315 		Arrays.sort(objectArray, comp);
   1316 		for (int counter = 0; counter < arraySize - 1; counter++)
   1317 			assertTrue("Array not sorted correctly with custom comparator",
   1318 					comp
   1319 							.compare(objectArray[counter],
   1320 									objectArray[counter + 1]) <= 0);
   1321 	}
   1322 
   1323     // Regression HARMONY-6076
   1324     public void test_sort$Ljava_lang_ObjectLjava_util_Comparator_stable() {
   1325         Element[] array = new Element[11];
   1326         array[0] = new Element(122);
   1327         array[1] = new Element(146);
   1328         array[2] = new Element(178);
   1329         array[3] = new Element(208);
   1330         array[4] = new Element(117);
   1331         array[5] = new Element(146);
   1332         array[6] = new Element(173);
   1333         array[7] = new Element(203);
   1334         array[8] = new Element(56);
   1335         array[9] = new Element(208);
   1336         array[10] = new Element(96);
   1337 
   1338         Comparator<Element> comparator = new Comparator<Element>() {
   1339             public int compare(Element object1, Element object2) {
   1340                 return object1.value - object2.value;
   1341             }
   1342         };
   1343 
   1344         Arrays.sort(array, comparator);
   1345 
   1346         for (int i = 1; i < array.length; i++) {
   1347             assertTrue(comparator.compare(array[i - 1], array[i]) <= 0);
   1348             if (comparator.compare(array[i - 1], array[i]) == 0) {
   1349                 assertTrue(array[i - 1].index < array[i].index);
   1350             }
   1351         }
   1352     }
   1353 
   1354     public static class Element {
   1355         public int value;
   1356 
   1357         public int index;
   1358 
   1359         private static int count = 0;
   1360 
   1361         public Element(int value) {
   1362             this.value = value;
   1363             index = count++;
   1364         }
   1365     }
   1366 
   1367 	/**
   1368 	 * @tests java.util.Arrays#sort(short[])
   1369 	 */
   1370 	public void test_sort$S() {
   1371 		// Test for method void java.util.Arrays.sort(short [])
   1372 		short[] reversedArray = new short[arraySize];
   1373 		for (int counter = 0; counter < arraySize; counter++)
   1374 			reversedArray[counter] = (short) (arraySize - counter - 1);
   1375 		Arrays.sort(reversedArray);
   1376 		for (int counter = 0; counter < arraySize; counter++)
   1377 			assertTrue("Resulting array not sorted",
   1378 					reversedArray[counter] == (short) counter);
   1379 	}
   1380 
   1381 	/**
   1382 	 * @tests java.util.Arrays#sort(short[], int, int)
   1383 	 */
   1384 	public void test_sort$SII() {
   1385 		// Test for method void java.util.Arrays.sort(short [], int, int)
   1386 		int startIndex = arraySize / 4;
   1387 		int endIndex = 3 * arraySize / 4;
   1388 		short[] reversedArray = new short[arraySize];
   1389 		short[] originalReversedArray = new short[arraySize];
   1390 		for (int counter = 0; counter < arraySize; counter++) {
   1391 			reversedArray[counter] = (short) (arraySize - counter - 1);
   1392 			originalReversedArray[counter] = reversedArray[counter];
   1393 		}
   1394 		Arrays.sort(reversedArray, startIndex, endIndex);
   1395 		for (int counter = 0; counter < startIndex; counter++)
   1396 			assertTrue("Array modified outside of bounds",
   1397 					reversedArray[counter] == originalReversedArray[counter]);
   1398 		for (int counter = startIndex; counter < endIndex - 1; counter++)
   1399 			assertTrue("Array not sorted within bounds",
   1400 					reversedArray[counter] <= reversedArray[counter + 1]);
   1401 		for (int counter = endIndex; counter < arraySize; counter++)
   1402 			assertTrue("Array modified outside of bounds",
   1403 					reversedArray[counter] == originalReversedArray[counter]);
   1404 
   1405 		//exception testing
   1406 		try {
   1407 			Arrays.sort(reversedArray, startIndex + 1, startIndex);
   1408             fail("IllegalArgumentException expected");
   1409 		} catch (IllegalArgumentException ignore) {
   1410 		}
   1411 
   1412 		try {
   1413 			Arrays.sort(reversedArray, -1, startIndex);
   1414             fail("ArrayIndexOutOfBoundsException expected (1)");
   1415 		} catch (ArrayIndexOutOfBoundsException ignore) {
   1416 		}
   1417 
   1418 		try {
   1419 			Arrays.sort(reversedArray, startIndex, reversedArray.length + 1);
   1420             fail("ArrayIndexOutOfBoundsException expected (2)");
   1421 		} catch (ArrayIndexOutOfBoundsException ignore) {
   1422 		}
   1423 
   1424 		//exception order testing
   1425 		try {
   1426 			Arrays.sort(new short[1], startIndex + 1, startIndex);
   1427             fail("IllegalArgumentException expected");
   1428 		} catch (IllegalArgumentException ignore) {
   1429 		}
   1430 	}
   1431 
   1432     /**
   1433      * @tests java.util.Arrays#sort(byte[], int, int)
   1434      */
   1435     public void test_java_util_Arrays_sort_byte_array_NPE() {
   1436         byte[] byte_array_null = null;
   1437         try {
   1438             java.util.Arrays.sort(byte_array_null);
   1439             fail("Should throw java.lang.NullPointerException");
   1440         } catch (NullPointerException e) {
   1441             // Expected
   1442         }
   1443         try {
   1444             // Regression for HARMONY-378
   1445             java.util.Arrays.sort(byte_array_null, (int) -1, (int) 1);
   1446             fail("Should throw java.lang.NullPointerException");
   1447         } catch (NullPointerException e) {
   1448             // Expected
   1449         }
   1450     }
   1451 
   1452     /**
   1453      * @tests java.util.Arrays#sort(char[], int, int)
   1454      */
   1455     public void test_java_util_Arrays_sort_char_array_NPE() {
   1456         char[] char_array_null = null;
   1457         try {
   1458             java.util.Arrays.sort(char_array_null);
   1459             fail("Should throw java.lang.NullPointerException");
   1460         } catch (NullPointerException e) {
   1461             // Expected
   1462         }
   1463         try {
   1464             // Regression for HARMONY-378
   1465             java.util.Arrays.sort(char_array_null, (int) -1, (int) 1);
   1466             fail("Should throw java.lang.NullPointerException");
   1467         } catch (NullPointerException e) {
   1468             // Expected
   1469         }
   1470     }
   1471 
   1472     /**
   1473      * @tests java.util.Arrays#sort(double[], int, int)
   1474      */
   1475     public void test_java_util_Arrays_sort_double_array_NPE() {
   1476         double[] double_array_null = null;
   1477         try {
   1478             java.util.Arrays.sort(double_array_null);
   1479             fail("Should throw java.lang.NullPointerException");
   1480         } catch (NullPointerException e) {
   1481             // Expected
   1482         }
   1483         try {
   1484             // Regression for HARMONY-378
   1485             java.util.Arrays.sort(double_array_null, (int) -1, (int) 1);
   1486             fail("Should throw java.lang.NullPointerException");
   1487         } catch (NullPointerException e) {
   1488             // Expected
   1489         }
   1490     }
   1491 
   1492     /**
   1493      * @tests java.util.Arrays#sort(float[], int, int)
   1494      */
   1495     public void test_java_util_Arrays_sort_float_array_NPE() {
   1496         float[] float_array_null = null;
   1497         try {
   1498             java.util.Arrays.sort(float_array_null);
   1499             fail("Should throw java.lang.NullPointerException");
   1500         } catch (NullPointerException e) {
   1501             // Expected
   1502         }
   1503         try {
   1504             // Regression for HARMONY-378
   1505             java.util.Arrays.sort(float_array_null, (int) -1, (int) 1);
   1506             fail("Should throw java.lang.NullPointerException");
   1507         } catch (NullPointerException e) {
   1508             // Expected
   1509         }
   1510     }
   1511 
   1512     /**
   1513      * @tests java.util.Arrays#sort(int[], int, int)
   1514      */
   1515     public void test_java_util_Arrays_sort_int_array_NPE() {
   1516         int[] int_array_null = null;
   1517         try {
   1518             java.util.Arrays.sort(int_array_null);
   1519             fail("Should throw java.lang.NullPointerException");
   1520         } catch (NullPointerException e) {
   1521             // Expected
   1522         }
   1523         try {
   1524             // Regression for HARMONY-378
   1525             java.util.Arrays.sort(int_array_null, (int) -1, (int) 1);
   1526             fail("Should throw java.lang.NullPointerException");
   1527         } catch (NullPointerException e) {
   1528             // Expected
   1529         }
   1530     }
   1531 
   1532     /**
   1533      * @tests java.util.Arrays#sort(Object[], int, int)
   1534      */
   1535     public void test_java_util_Arrays_sort_object_array_NPE() {
   1536         Object[] object_array_null = null;
   1537         try {
   1538             java.util.Arrays.sort(object_array_null);
   1539             fail("Should throw java.lang.NullPointerException");
   1540         } catch (NullPointerException e) {
   1541             // Expected
   1542         }
   1543         try {
   1544             // Regression for HARMONY-378
   1545             java.util.Arrays.sort(object_array_null, (int) -1, (int) 1);
   1546             fail("Should throw java.lang.NullPointerException");
   1547         } catch (NullPointerException e) {
   1548             // Expected
   1549         }
   1550         try {
   1551             // Regression for HARMONY-378
   1552             java.util.Arrays.sort(object_array_null, (int) -1, (int) 1, null);
   1553             fail("Should throw java.lang.NullPointerException");
   1554         } catch (NullPointerException e) {
   1555             // Expected
   1556         }
   1557     }
   1558 
   1559     /**
   1560      * @tests java.util.Arrays#sort(long[], int, int)
   1561      */
   1562     public void test_java_util_Arrays_sort_long_array_NPE() {
   1563         long[] long_array_null = null;
   1564         try {
   1565             java.util.Arrays.sort(long_array_null);
   1566             fail("Should throw java.lang.NullPointerException");
   1567         } catch (NullPointerException e) {
   1568             // Expected
   1569         }
   1570         try {
   1571             // Regression for HARMONY-378
   1572             java.util.Arrays.sort(long_array_null, (int) -1, (int) 1);
   1573             fail("Should throw java.lang.NullPointerException");
   1574         } catch (NullPointerException e) {
   1575             // Expected
   1576         }
   1577     }
   1578 
   1579     /**
   1580      * @tests java.util.Arrays#sort(short[], int, int)
   1581      */
   1582     public void test_java_util_Arrays_sort_short_array_NPE() {
   1583         short[] short_array_null = null;
   1584         try {
   1585             java.util.Arrays.sort(short_array_null);
   1586             fail("Should throw java.lang.NullPointerException");
   1587         } catch (NullPointerException e) {
   1588             // Expected
   1589         }
   1590         try {
   1591             // Regression for HARMONY-378
   1592             java.util.Arrays.sort(short_array_null, (int) -1, (int) 1);
   1593             fail("Should throw java.lang.NullPointerException");
   1594         } catch (NullPointerException e) {
   1595             // Expected
   1596         }
   1597     }
   1598 
   1599     /**
   1600      * @tests java.util.Arrays#deepEquals(Object[], Object[])
   1601      */
   1602     public void test_deepEquals$Ljava_lang_ObjectLjava_lang_Object() {
   1603        int [] a1 = {1, 2, 3};
   1604        short [] a2 = {0, 1};
   1605        Object [] a3 = {new Integer(1), a2};
   1606        int [] a4 = {6, 5, 4};
   1607 
   1608        int [] b1 = {1, 2, 3};
   1609        short [] b2 = {0, 1};
   1610        Object [] b3 = {new Integer(1), b2};
   1611 
   1612        Object a [] = {a1, a2, a3};
   1613        Object b [] = {b1, b2, b3};
   1614 
   1615        assertFalse(Arrays.equals(a, b));
   1616        assertTrue(Arrays.deepEquals(a,b));
   1617 
   1618        a[2] = a4;
   1619 
   1620        assertFalse(Arrays.deepEquals(a, b));
   1621     }
   1622 
   1623     /**
   1624      * @tests java.util.Arrays#deepHashCode(Object[])
   1625      */
   1626     public void test_deepHashCode$Ljava_lang_Object() {
   1627         int [] a1 = {1, 2, 3};
   1628         short [] a2 = {0, 1};
   1629         Object [] a3 = {new Integer(1), a2};
   1630 
   1631         int [] b1 = {1, 2, 3};
   1632         short [] b2 = {0, 1};
   1633         Object [] b3 = {new Integer(1), b2};
   1634 
   1635         Object a [] = {a1, a2, a3};
   1636         Object b [] = {b1, b2, b3};
   1637 
   1638         int deep_hash_a = Arrays.deepHashCode(a);
   1639         int deep_hash_b = Arrays.deepHashCode(b);
   1640 
   1641         assertEquals(deep_hash_a, deep_hash_b);
   1642      }
   1643 
   1644     /**
   1645      * @tests java.util.Arrays#hashCode(boolean[] a)
   1646      */
   1647     public void test_hashCode$LZ() {
   1648         int listHashCode;
   1649         int arrayHashCode;
   1650 
   1651         boolean [] boolArr = {true, false, false, true, false};
   1652         List listOfBoolean = new LinkedList();
   1653         for (int i = 0; i < boolArr.length; i++) {
   1654             listOfBoolean.add(new Boolean(boolArr[i]));
   1655         }
   1656         listHashCode = listOfBoolean.hashCode();
   1657         arrayHashCode = Arrays.hashCode(boolArr);
   1658         assertEquals(listHashCode, arrayHashCode);
   1659     }
   1660 
   1661     /**
   1662      * @tests java.util.Arrays#hashCode(int[] a)
   1663      */
   1664     public void test_hashCode$LI() {
   1665         int listHashCode;
   1666         int arrayHashCode;
   1667 
   1668         int [] intArr = {10, 5, 134, 7, 19};
   1669         List listOfInteger = new LinkedList();
   1670 
   1671         for (int i = 0; i < intArr.length; i++) {
   1672             listOfInteger.add(new Integer(intArr[i]));
   1673         }
   1674         listHashCode = listOfInteger.hashCode();
   1675         arrayHashCode = Arrays.hashCode(intArr);
   1676         assertEquals(listHashCode, arrayHashCode);
   1677 
   1678         int [] intArr2 = {10, 5, 134, 7, 19};
   1679         assertEquals(Arrays.hashCode(intArr2), Arrays.hashCode(intArr));
   1680     }
   1681 
   1682     /**
   1683      * @tests java.util.Arrays#hashCode(char[] a)
   1684      */
   1685     public void test_hashCode$LC() {
   1686         int listHashCode;
   1687         int arrayHashCode;
   1688 
   1689         char [] charArr = {'a', 'g', 'x', 'c', 'm'};
   1690         List listOfCharacter = new LinkedList();
   1691         for (int i = 0; i < charArr.length; i++) {
   1692             listOfCharacter.add(new Character(charArr[i]));
   1693         }
   1694         listHashCode = listOfCharacter.hashCode();
   1695         arrayHashCode = Arrays.hashCode(charArr);
   1696         assertEquals(listHashCode, arrayHashCode);
   1697     }
   1698 
   1699     /**
   1700      * @tests java.util.Arrays#hashCode(byte[] a)
   1701      */
   1702     public void test_hashCode$LB() {
   1703         int listHashCode;
   1704         int arrayHashCode;
   1705 
   1706         byte [] byteArr = {5, 9, 7, 6, 17};
   1707         List listOfByte = new LinkedList();
   1708         for (int i = 0; i < byteArr.length; i++) {
   1709             listOfByte.add(new Byte(byteArr[i]));
   1710         }
   1711         listHashCode = listOfByte.hashCode();
   1712         arrayHashCode = Arrays.hashCode(byteArr);
   1713         assertEquals(listHashCode, arrayHashCode);
   1714     }
   1715 
   1716     /**
   1717      * @tests java.util.Arrays#hashCode(long[] a)
   1718      */
   1719     public void test_hashCode$LJ() {
   1720         int listHashCode;
   1721         int arrayHashCode;
   1722 
   1723         long [] longArr = {67890234512l, 97587236923425l, 257421912912l,
   1724                 6754268100l, 5};
   1725         List listOfLong = new LinkedList();
   1726         for (int i = 0; i < longArr.length; i++) {
   1727             listOfLong.add(new Long(longArr[i]));
   1728         }
   1729         listHashCode = listOfLong.hashCode();
   1730         arrayHashCode = Arrays.hashCode(longArr);
   1731         assertEquals(listHashCode, arrayHashCode);
   1732     }
   1733 
   1734     /**
   1735      * @tests java.util.Arrays#hashCode(float[] a)
   1736      */
   1737     public void test_hashCode$LF() {
   1738         int listHashCode;
   1739         int arrayHashCode;
   1740 
   1741         float [] floatArr = {0.13497f, 0.268934f, 12e-5f, -3e+2f, 10e-4f};
   1742         List listOfFloat = new LinkedList();
   1743         for (int i = 0; i < floatArr.length; i++) {
   1744             listOfFloat.add(new Float(floatArr[i]));
   1745         }
   1746         listHashCode = listOfFloat.hashCode();
   1747         arrayHashCode = Arrays.hashCode(floatArr);
   1748         assertEquals(listHashCode, arrayHashCode);
   1749 
   1750         float [] floatArr2 = {0.13497f, 0.268934f, 12e-5f, -3e+2f, 10e-4f};
   1751         assertEquals(Arrays.hashCode(floatArr2), Arrays.hashCode(floatArr));
   1752     }
   1753 
   1754     /**
   1755      * @tests java.util.Arrays#hashCode(double[] a)
   1756      */
   1757     public void test_hashCode$LD() {
   1758         int listHashCode;
   1759         int arrayHashCode;
   1760 
   1761         double [] doubleArr = {0.134945657, 0.0038754, 11e-150, -30e-300, 10e-4};
   1762         List listOfDouble = new LinkedList();
   1763         for (int i = 0; i < doubleArr.length; i++) {
   1764             listOfDouble.add(new Double(doubleArr[i]));
   1765         }
   1766         listHashCode = listOfDouble.hashCode();
   1767         arrayHashCode = Arrays.hashCode(doubleArr);
   1768         assertEquals(listHashCode, arrayHashCode);
   1769     }
   1770 
   1771     /**
   1772      * @tests java.util.Arrays#hashCode(short[] a)
   1773      */
   1774     public void test_hashCode$LS() {
   1775         int listHashCode;
   1776         int arrayHashCode;
   1777 
   1778         short [] shortArr = {35, 13, 45, 2, 91};
   1779         List listOfShort = new LinkedList();
   1780         for (int i = 0; i < shortArr.length; i++) {
   1781             listOfShort.add(new Short(shortArr[i]));
   1782         }
   1783         listHashCode = listOfShort.hashCode();
   1784         arrayHashCode = Arrays.hashCode(shortArr);
   1785         assertEquals(listHashCode, arrayHashCode);
   1786     }
   1787 
   1788     /**
   1789      * @tests java.util.Arrays#hashCode(Object[] a)
   1790      */
   1791     public void test_hashCode$Ljava_lang_Object() {
   1792         int listHashCode;
   1793         int arrayHashCode;
   1794 
   1795         Object[] objectArr = {new Integer(1), new Float(10e-12f), null};
   1796         List listOfObject= new LinkedList();
   1797         for (int i = 0; i < objectArr.length; i++) {
   1798             listOfObject.add(objectArr[i]);
   1799         }
   1800         listHashCode = listOfObject.hashCode();
   1801         arrayHashCode = Arrays.hashCode(objectArr);
   1802         assertEquals(listHashCode, arrayHashCode);
   1803     }
   1804 
   1805 	/**
   1806 	 * Sets up the fixture, for example, open a network connection. This method
   1807 	 * is called before a test is executed.
   1808 	 */
   1809 	protected void setUp() {
   1810 		booleanArray = new boolean[arraySize];
   1811 		byteArray = new byte[arraySize];
   1812 		charArray = new char[arraySize];
   1813 		doubleArray = new double[arraySize];
   1814 		floatArray = new float[arraySize];
   1815 		intArray = new int[arraySize];
   1816 		longArray = new long[arraySize];
   1817 		objectArray = new Object[arraySize];
   1818 		shortArray = new short[arraySize];
   1819 
   1820 		for (int counter = 0; counter < arraySize; counter++) {
   1821 			byteArray[counter] = (byte) counter;
   1822 			charArray[counter] = (char) (counter + 1);
   1823 			doubleArray[counter] = counter;
   1824 			floatArray[counter] = counter;
   1825 			intArray[counter] = counter;
   1826 			longArray[counter] = counter;
   1827 			objectArray[counter] = objArray[counter];
   1828 			shortArray[counter] = (short) counter;
   1829 		}
   1830 		for (int counter = 0; counter < arraySize; counter += 2) {
   1831 			booleanArray[counter] = false;
   1832 			booleanArray[counter + 1] = true;
   1833 		}
   1834 	}
   1835 
   1836     /**
   1837      * @tests java.util.Arrays#binarySearch(byte[],int,int, byte)
   1838      */
   1839     public void test_binarySearch$BIIB() {
   1840         for (byte counter = 0; counter < arraySize; counter++) {
   1841             assertTrue(
   1842                     "Binary search on byte[] answered incorrect position",
   1843                     Arrays.binarySearch(byteArray, counter, arraySize, counter) == counter);
   1844         }
   1845         assertEquals(
   1846                 "Binary search succeeded for value not present in array 1", -1,
   1847                 Arrays.binarySearch(byteArray, 0, arraySize, (byte) -1));
   1848         assertTrue(
   1849                 "Binary search succeeded for value not present in array 2",
   1850                 Arrays.binarySearch(byteArray, (byte) arraySize) == -(arraySize + 1));
   1851         for (byte counter = 0; counter < arraySize; counter++) {
   1852             byteArray[counter] -= 50;
   1853         }
   1854         for (byte counter = 0; counter < arraySize; counter++) {
   1855             assertTrue(
   1856                     "Binary search on byte[] involving negative numbers answered incorrect position",
   1857                     Arrays.binarySearch(byteArray, counter, arraySize,
   1858                             (byte) (counter - 50)) == counter);
   1859         }
   1860         try {
   1861             Arrays.binarySearch((byte[])null, 2, 1, (byte) arraySize);
   1862             fail("should throw NullPointerException");
   1863         } catch (NullPointerException e) {
   1864             // expected
   1865         }
   1866         try {
   1867             Arrays.binarySearch((byte[])null, -1, 0, (byte) arraySize);
   1868             fail("should throw NullPointerException");
   1869         } catch (NullPointerException e) {
   1870             // expected
   1871         }
   1872         try {
   1873             Arrays.binarySearch((byte[])null, -1, -2, (byte) arraySize);
   1874             fail("should throw NullPointerException");
   1875         } catch (NullPointerException e) {
   1876             // expected
   1877         }
   1878         try {
   1879             Arrays.binarySearch(byteArray, 2, 1, (byte) arraySize);
   1880             fail("should throw IllegalArgumentException");
   1881         } catch (IllegalArgumentException e) {
   1882             // expected
   1883         }
   1884         assertEquals(-1, Arrays.binarySearch(byteArray, 0, 0, (byte) arraySize));
   1885         try {
   1886             Arrays.binarySearch(byteArray, -1, -2, (byte) arraySize);
   1887             fail("should throw IllegalArgumentException");
   1888         } catch (IllegalArgumentException e) {
   1889             // expected
   1890         }
   1891         try {
   1892             Arrays.binarySearch(byteArray, arraySize + 2, arraySize + 1,
   1893                     (byte) arraySize);
   1894             fail("should throw IllegalArgumentException");
   1895         } catch (IllegalArgumentException e) {
   1896             // expected
   1897         }
   1898         try {
   1899             Arrays.binarySearch(byteArray, -1, 0, (byte) arraySize);
   1900             fail("should throw ArrayIndexOutOfBoundsException");
   1901         } catch (ArrayIndexOutOfBoundsException e) {
   1902             // expected
   1903         }
   1904         try {
   1905             Arrays.binarySearch(byteArray, 0, arraySize + 1, (byte) arraySize);
   1906             fail("should throw ArrayIndexOutOfBoundsException");
   1907         } catch (ArrayIndexOutOfBoundsException e) {
   1908             // expected
   1909         }
   1910     }
   1911 
   1912     /**
   1913      * @tests java.util.Arrays#binarySearch(char[], char)
   1914      */
   1915     public void test_binarySearch$CIIC() {
   1916         for (char counter = 0; counter < arraySize; counter++) {
   1917             assertTrue("Binary search on char[] answered incorrect position",
   1918                     Arrays.binarySearch(charArray, counter, arraySize,
   1919                             (char) (counter + 1)) == counter);
   1920         }
   1921         assertEquals(
   1922                 "Binary search succeeded for value not present in array 1", -1,
   1923                 Arrays.binarySearch(charArray, 0, arraySize, '\u0000'));
   1924         assertTrue("Binary search succeeded for value not present in array 2",
   1925                 Arrays.binarySearch(charArray, 0, arraySize,
   1926                         (char) (arraySize + 1)) == -(arraySize + 1));
   1927         try {
   1928             Arrays.binarySearch(charArray, 2, 1, (char) arraySize);
   1929             fail("should throw IllegalArgumentException");
   1930         } catch (IllegalArgumentException e) {
   1931             // expected
   1932         }
   1933         try {
   1934             Arrays.binarySearch((char[])null, 2, 1, (char) arraySize);
   1935             fail("should throw NullPointerException");
   1936         } catch (NullPointerException e) {
   1937             // expected
   1938         }
   1939         try {
   1940             Arrays.binarySearch((char[])null, -1, 0, (char) arraySize);
   1941             fail("should throw NullPointerException");
   1942         } catch (NullPointerException e) {
   1943             // expected
   1944         }
   1945         try {
   1946             Arrays.binarySearch((char[])null, -1, -2, (char) arraySize);
   1947             fail("should throw NullPointerException");
   1948         } catch (NullPointerException e) {
   1949             // expected
   1950         }
   1951         assertEquals(-1, Arrays.binarySearch(charArray, 0, 0, (char) arraySize));
   1952         try {
   1953             Arrays.binarySearch(charArray, -1, -2, (char) arraySize);
   1954             fail("should throw IllegalArgumentException");
   1955         } catch (IllegalArgumentException e) {
   1956             // expected
   1957         }
   1958         try {
   1959             Arrays.binarySearch(charArray, arraySize + 2, arraySize + 1,
   1960                     (char) arraySize);
   1961             fail("should throw IllegalArgumentException");
   1962         } catch (IllegalArgumentException e) {
   1963             // expected
   1964         }
   1965         try {
   1966             Arrays.binarySearch(charArray, -1, 0, (char) arraySize);
   1967             fail("should throw ArrayIndexOutOfBoundsException");
   1968         } catch (ArrayIndexOutOfBoundsException e) {
   1969             // expected
   1970         }
   1971         try {
   1972             Arrays.binarySearch(charArray, 0, arraySize + 1, (char) arraySize);
   1973             fail("should throw ArrayIndexOutOfBoundsException");
   1974         } catch (ArrayIndexOutOfBoundsException e) {
   1975             // expected
   1976         }
   1977     }
   1978 
   1979     /**
   1980      * @tests java.util.Arrays#binarySearch(double[], double)
   1981      */
   1982     public void test_binarySearch$DIID() {
   1983         for (int counter = 0; counter < arraySize; counter++) {
   1984             assertTrue("Binary search on double[] answered incorrect position",
   1985                     Arrays.binarySearch(doubleArray, counter, arraySize,
   1986                             (double) counter) == (double) counter);
   1987         }
   1988         assertEquals(
   1989                 "Binary search succeeded for value not present in array 1", -1,
   1990                 Arrays.binarySearch(doubleArray, 0, arraySize, (double) -1));
   1991         assertTrue("Binary search succeeded for value not present in array 2",
   1992                 Arrays.binarySearch(doubleArray, 0, arraySize,
   1993                         (double) arraySize) == -(arraySize + 1));
   1994         for (int counter = 0; counter < arraySize; counter++) {
   1995             doubleArray[counter] -= (double) 50;
   1996         }
   1997         for (int counter = 0; counter < arraySize; counter++) {
   1998             assertTrue(
   1999                     "Binary search on double[] involving negative numbers answered incorrect position",
   2000                     Arrays.binarySearch(doubleArray, counter, arraySize,(double) (counter - 50)) == (double) counter);
   2001         }
   2002         double[] specials = new double[] { Double.NEGATIVE_INFINITY,
   2003                 -Double.MAX_VALUE, -2d, -Double.MIN_VALUE, -0d, 0d,
   2004                 Double.MIN_VALUE, 2d, Double.MAX_VALUE,
   2005                 Double.POSITIVE_INFINITY, Double.NaN };
   2006         for (int i = 0; i < specials.length; i++) {
   2007             int result = Arrays.binarySearch(specials, i, specials.length,specials[i]);
   2008             assertTrue(specials[i] + " invalid: " + result, result == i);
   2009         }
   2010         assertEquals("-1d", -4, Arrays.binarySearch(specials,0,specials.length, -1d));
   2011         assertEquals("1d", -8, Arrays.binarySearch(specials,0,specials.length, 1d));
   2012         try {
   2013             Arrays.binarySearch((double[])null, 2, 1, (double) arraySize);
   2014             fail("should throw NullPointerException");
   2015         } catch (NullPointerException e) {
   2016             // expected
   2017         }
   2018         try {
   2019             Arrays.binarySearch((double[])null, -1, 0, (double) arraySize);
   2020             fail("should throw NullPointerException");
   2021         } catch (NullPointerException e) {
   2022             // expected
   2023         }
   2024         try {
   2025             Arrays.binarySearch((double[])null, -1, -2, (double) arraySize);
   2026             fail("should throw NullPointerException");
   2027         } catch (NullPointerException e) {
   2028             // expected
   2029         }
   2030         try {
   2031             Arrays.binarySearch(doubleArray, 2, 1, (char) arraySize);
   2032             fail("should throw IllegalArgumentException");
   2033         } catch (IllegalArgumentException e) {
   2034             // expected
   2035         }
   2036         assertEquals(-1, Arrays.binarySearch(doubleArray, 0, 0, (char) arraySize));
   2037         try {
   2038             Arrays.binarySearch(doubleArray, -1, -2, (char) arraySize);
   2039             fail("should throw IllegalArgumentException");
   2040         } catch (IllegalArgumentException e) {
   2041             // expected
   2042         }
   2043         try {
   2044             Arrays.binarySearch(doubleArray, arraySize + 2, arraySize + 1,
   2045                     (char) arraySize);
   2046             fail("should throw IllegalArgumentException");
   2047         } catch (IllegalArgumentException e) {
   2048             // expected
   2049         }
   2050         try {
   2051             Arrays.binarySearch(doubleArray, -1, 0, (char) arraySize);
   2052             fail("should throw ArrayIndexOutOfBoundsException");
   2053         } catch (ArrayIndexOutOfBoundsException e) {
   2054             // expected
   2055         }
   2056         try {
   2057             Arrays.binarySearch(doubleArray, 0, arraySize + 1, (char) arraySize);
   2058             fail("should throw ArrayIndexOutOfBoundsException");
   2059         } catch (ArrayIndexOutOfBoundsException e) {
   2060             // expected
   2061         }
   2062     }
   2063 
   2064     /**
   2065      * @tests java.util.Arrays#binarySearch(float[], float)
   2066      */
   2067     public void test_binarySearch$FIIF() {
   2068         for (int counter = 0; counter < arraySize; counter++) {
   2069             assertTrue("Binary search on float[] answered incorrect position",
   2070                     Arrays.binarySearch(floatArray, counter, arraySize,
   2071                             (float) counter) == (float) counter);
   2072         }
   2073         assertEquals(
   2074                 "Binary search succeeded for value not present in array 1", -1,
   2075                 Arrays.binarySearch(floatArray, 0, arraySize, (float) -1));
   2076         assertTrue("Binary search succeeded for value not present in array 2",
   2077                 Arrays
   2078                         .binarySearch(floatArray, 0, arraySize,
   2079                                 (float) arraySize) == -(arraySize + 1));
   2080         for (int counter = 0; counter < arraySize; counter++) {
   2081             floatArray[counter] -= (float) 50;
   2082         }
   2083         for (int counter = 0; counter < arraySize; counter++) {
   2084             assertTrue(
   2085                     "Binary search on float[] involving negative numbers answered incorrect position",
   2086                     Arrays.binarySearch(floatArray, 0, arraySize,
   2087                             (float) counter - 50) == (float) counter);
   2088         }
   2089         float[] specials = new float[] { Float.NEGATIVE_INFINITY,
   2090                 -Float.MAX_VALUE, -2f, -Float.MIN_VALUE, -0f, 0f,
   2091                 Float.MIN_VALUE, 2f, Float.MAX_VALUE, Float.POSITIVE_INFINITY,
   2092                 Float.NaN };
   2093         for (int i = 0; i < specials.length; i++) {
   2094             int result = Arrays.binarySearch(specials,i,specials.length,specials[i]);
   2095             assertTrue(specials[i] + " invalid: " + result, result == i);
   2096         }
   2097         assertEquals("-1f", -4, Arrays.binarySearch(specials,0,specials.length, -1f));
   2098         assertEquals("1f", -8, Arrays.binarySearch(specials,0,specials.length, 1f));
   2099         try {
   2100             Arrays.binarySearch((float[])null, 2, 1, (float) arraySize);
   2101             fail("should throw NullPointerException");
   2102         } catch (NullPointerException e) {
   2103             // expected
   2104         }
   2105         try {
   2106             Arrays.binarySearch((float[])null, -1, 0, (float) arraySize);
   2107             fail("should throw NullPointerException");
   2108         } catch (NullPointerException e) {
   2109             // expected
   2110         }
   2111         try {
   2112             Arrays.binarySearch((float[])null, -1, -2, (float) arraySize);
   2113             fail("should throw NullPointerException");
   2114         } catch (NullPointerException e) {
   2115             // expected
   2116         }
   2117         try {
   2118             Arrays.binarySearch(floatArray, 2, 1, (char) arraySize);
   2119             fail("should throw IllegalArgumentException");
   2120         } catch (IllegalArgumentException e) {
   2121             // expected
   2122         }
   2123         assertEquals(-1, Arrays.binarySearch(floatArray, 0, 0,
   2124                 (char) arraySize));
   2125         try {
   2126             Arrays.binarySearch(floatArray, -1, -2, (char) arraySize);
   2127             fail("should throw IllegalArgumentException");
   2128         } catch (IllegalArgumentException e) {
   2129             // expected
   2130         }
   2131         try {
   2132             Arrays.binarySearch(floatArray, arraySize + 2, arraySize + 1,
   2133                     (char) arraySize);
   2134             fail("should throw IllegalArgumentException");
   2135         } catch (IllegalArgumentException e) {
   2136             // expected
   2137         }
   2138         try {
   2139             Arrays.binarySearch(floatArray, -1, 0, (char) arraySize);
   2140             fail("should throw ArrayIndexOutOfBoundsException");
   2141         } catch (ArrayIndexOutOfBoundsException e) {
   2142             // expected
   2143         }
   2144         try {
   2145             Arrays
   2146                     .binarySearch(floatArray, 0, arraySize + 1,
   2147                             (char) arraySize);
   2148             fail("should throw ArrayIndexOutOfBoundsException");
   2149         } catch (ArrayIndexOutOfBoundsException e) {
   2150             // expected
   2151         }
   2152     }
   2153 
   2154     /**
   2155      * @tests java.util.Arrays#binarySearch(int[], int)
   2156      */
   2157     public void test_binarySearch$IIII() {
   2158         for (int counter = 0; counter < arraySize; counter++) {
   2159             assertTrue(
   2160                     "Binary search on int[] answered incorrect position",
   2161                     Arrays.binarySearch(intArray, counter, arraySize, counter) == counter);
   2162         }
   2163         assertEquals(
   2164                 "Binary search succeeded for value not present in array 1", -1,
   2165                 Arrays.binarySearch(intArray,0, arraySize, -1));
   2166         assertTrue("Binary search succeeded for value not present in array 2",
   2167                 Arrays.binarySearch(intArray,0, arraySize, arraySize) == -(arraySize + 1));
   2168         for (int counter = 0; counter < arraySize; counter++) {
   2169             intArray[counter] -= 50;
   2170         }
   2171         for (int counter = 0; counter < arraySize; counter++) {
   2172             assertTrue(
   2173                     "Binary search on int[] involving negative numbers answered incorrect position",
   2174                     Arrays.binarySearch(intArray,0, arraySize, counter - 50) == counter);
   2175         }
   2176         try {
   2177             Arrays.binarySearch((int[])null, 2, 1, (int) arraySize);
   2178             fail("should throw NullPointerException");
   2179         } catch (NullPointerException e) {
   2180             // expected
   2181         }
   2182         try {
   2183             Arrays.binarySearch((int[])null, -1, 0, (int) arraySize);
   2184             fail("should throw NullPointerException");
   2185         } catch (NullPointerException e) {
   2186             // expected
   2187         }
   2188         try {
   2189             Arrays.binarySearch((int[])null, -1, -2, (int) arraySize);
   2190             fail("should throw NullPointerException");
   2191         } catch (NullPointerException e) {
   2192             // expected
   2193         }
   2194         try {
   2195             Arrays.binarySearch(intArray, 2, 1, (char) arraySize);
   2196             fail("should throw IllegalArgumentException");
   2197         } catch (IllegalArgumentException e) {
   2198             // expected
   2199         }
   2200         assertEquals(-1, Arrays
   2201                 .binarySearch(intArray, 0, 0, (char) arraySize));
   2202         try {
   2203             Arrays.binarySearch(intArray, -1, -2, (char) arraySize);
   2204             fail("should throw IllegalArgumentException");
   2205         } catch (IllegalArgumentException e) {
   2206             // expected
   2207         }
   2208         try {
   2209             Arrays.binarySearch(intArray, arraySize + 2, arraySize + 1,
   2210                     (char) arraySize);
   2211             fail("should throw IllegalArgumentException");
   2212         } catch (IllegalArgumentException e) {
   2213             // expected
   2214         }
   2215         try {
   2216             Arrays.binarySearch(intArray, -1, 0, (char) arraySize);
   2217             fail("should throw ArrayIndexOutOfBoundsException");
   2218         } catch (ArrayIndexOutOfBoundsException e) {
   2219             // expected
   2220         }
   2221         try {
   2222             Arrays.binarySearch(intArray, 0, arraySize + 1, (char) arraySize);
   2223             fail("should throw ArrayIndexOutOfBoundsException");
   2224         } catch (ArrayIndexOutOfBoundsException e) {
   2225             // expected
   2226         }
   2227     }
   2228 
   2229     /**
   2230      * @tests java.util.Arrays#binarySearch(long[], long)
   2231      */
   2232     public void test_binarySearch$JIIJ() {
   2233         for (long counter = 0; counter < arraySize; counter++){
   2234             assertTrue("Binary search on long[] answered incorrect position",
   2235                     Arrays.binarySearch(longArray,0,arraySize, counter) == counter);
   2236         }
   2237         assertEquals("Binary search succeeded for value not present in array 1",
   2238                 -1, Arrays.binarySearch(longArray,0,arraySize, (long) -1));
   2239         assertTrue(
   2240                 "Binary search succeeded for value not present in array 2",
   2241                 Arrays.binarySearch(longArray,0,arraySize, (long) arraySize) == -(arraySize + 1));
   2242         for (long counter = 0; counter < arraySize; counter++){
   2243             longArray[(int) counter] -= (long) 50;
   2244         }
   2245         for (long counter = 0; counter < arraySize; counter++){
   2246             assertTrue(
   2247                     "Binary search on long[] involving negative numbers answered incorrect position",
   2248                     Arrays.binarySearch(longArray,0,arraySize, counter - (long) 50) == counter);
   2249         }
   2250         try {
   2251             Arrays.binarySearch((long[])null, 2, 1, (long) arraySize);
   2252             fail("should throw NullPointerException");
   2253         } catch (NullPointerException e) {
   2254             // expected
   2255         }
   2256         try {
   2257             Arrays.binarySearch((long[])null, -1, 0, (long) arraySize);
   2258             fail("should throw NullPointerException");
   2259         } catch (NullPointerException e) {
   2260             // expected
   2261         }
   2262         try {
   2263             Arrays.binarySearch((long[])null, -1, -2, (long) arraySize);
   2264             fail("should throw NullPointerException");
   2265         } catch (NullPointerException e) {
   2266             // expected
   2267         }
   2268         try {
   2269             Arrays.binarySearch(longArray, 2, 1, (char) arraySize);
   2270             fail("should throw IllegalArgumentException");
   2271         } catch (IllegalArgumentException e) {
   2272             // expected
   2273         }
   2274         assertEquals(-1, Arrays
   2275                 .binarySearch(longArray, 0, 0, (char) arraySize));
   2276         try {
   2277             Arrays.binarySearch(longArray, -1, -2, (char) arraySize);
   2278             fail("should throw IllegalArgumentException");
   2279         } catch (IllegalArgumentException e) {
   2280             // expected
   2281         }
   2282         try {
   2283             Arrays.binarySearch(longArray, arraySize + 2, arraySize + 1,
   2284                     (char) arraySize);
   2285             fail("should throw IllegalArgumentException");
   2286         } catch (IllegalArgumentException e) {
   2287             // expected
   2288         }
   2289         try {
   2290             Arrays.binarySearch(longArray, -1, 0, (char) arraySize);
   2291             fail("should throw ArrayIndexOutOfBoundsException");
   2292         } catch (ArrayIndexOutOfBoundsException e) {
   2293             // expected
   2294         }
   2295         try {
   2296             Arrays.binarySearch(longArray, 0, arraySize + 1, (char) arraySize);
   2297             fail("should throw ArrayIndexOutOfBoundsException");
   2298         } catch (ArrayIndexOutOfBoundsException e) {
   2299             // expected
   2300         }
   2301     }
   2302 
   2303     /**
   2304      * @tests java.util.Arrays#binarySearch(java.lang.Object[],
   2305      *        java.lang.Object)
   2306      */
   2307     public void test_binarySearch$Ljava_lang_ObjectIILjava_lang_Object() {
   2308         assertEquals(
   2309                 "Binary search succeeded for non-comparable value in empty array",
   2310                 -1, Arrays.binarySearch(new Object[] {},0,0, new Object()));
   2311         assertEquals(
   2312                 "Binary search succeeded for comparable value in empty array",
   2313                 -1, Arrays.binarySearch(new Object[] {},0,0, new Integer(-1)));
   2314         for (int counter = 0; counter < arraySize; counter++){
   2315             assertTrue(
   2316                     "Binary search on Object[] answered incorrect position",
   2317                     Arrays.binarySearch(objectArray,counter,arraySize, objArray[counter]) == counter);
   2318         }
   2319         assertEquals("Binary search succeeded for value not present in array 1",
   2320                 -1, Arrays.binarySearch(objectArray,0,arraySize, new Integer(-1)));
   2321         assertTrue(
   2322                 "Binary search succeeded for value not present in array 2",
   2323                 Arrays.binarySearch(objectArray,0,arraySize, new Integer(arraySize)) == -(arraySize + 1));
   2324         try {
   2325             Arrays.binarySearch((Object[])null, 2, 1, (byte) arraySize);
   2326             fail("should throw NullPointerException");
   2327         } catch (NullPointerException e) {
   2328             // expected
   2329         }
   2330         try {
   2331             Arrays.binarySearch((Object[])null, -1, 0, (byte) arraySize);
   2332             fail("should throw NullPointerException");
   2333         } catch (NullPointerException e) {
   2334             // expected
   2335         }
   2336         try {
   2337             Arrays.binarySearch((Object[])null, -1, -2, (byte) arraySize);
   2338             fail("should throw NullPointerException");
   2339         } catch (NullPointerException e) {
   2340             // expected
   2341         }
   2342         try {
   2343             Arrays.binarySearch(objectArray, 2, 1, (char) arraySize);
   2344             fail("should throw IllegalArgumentException");
   2345         } catch (IllegalArgumentException e) {
   2346             // expected
   2347         }
   2348         assertEquals(-1, Arrays
   2349                 .binarySearch(objectArray, 0, 0, (char) arraySize));
   2350         try {
   2351             Arrays.binarySearch(objectArray, -1, -2, (char) arraySize);
   2352             fail("should throw IllegalArgumentException");
   2353         } catch (IllegalArgumentException e) {
   2354             // expected
   2355         }
   2356         try {
   2357             Arrays.binarySearch(objectArray, arraySize + 2, arraySize + 1,
   2358                     (char) arraySize);
   2359             fail("should throw IllegalArgumentException");
   2360         } catch (IllegalArgumentException e) {
   2361             // expected
   2362         }
   2363         try {
   2364             Arrays.binarySearch(objectArray, -1, 0, (char) arraySize);
   2365             fail("should throw ArrayIndexOutOfBoundsException");
   2366         } catch (ArrayIndexOutOfBoundsException e) {
   2367             // expected
   2368         }
   2369         try {
   2370             Arrays.binarySearch(objectArray, 0, arraySize + 1, (char) arraySize);
   2371             fail("should throw ArrayIndexOutOfBoundsException");
   2372         } catch (ArrayIndexOutOfBoundsException e) {
   2373             // expected
   2374         }
   2375     }
   2376 
   2377     /**
   2378      * @tests java.util.Arrays#binarySearch(java.lang.Object[],
   2379      *        java.lang.Object, java.util.Comparator)
   2380      */
   2381     public void test_binarySearch$Ljava_lang_ObjectIILjava_lang_ObjectLjava_util_Comparator() {
   2382         Comparator comp = new ReversedIntegerComparator();
   2383         for (int counter = 0; counter < arraySize; counter++) {
   2384             objectArray[counter] = objArray[arraySize - counter - 1];
   2385         }
   2386         assertTrue("Binary search succeeded for value not present in array 1",
   2387                 Arrays.binarySearch(objectArray, 0, arraySize, new Integer(-1),
   2388                         comp) == -(arraySize + 1));
   2389         assertEquals(
   2390                 "Binary search succeeded for value not present in array 2", -1,
   2391                 Arrays.binarySearch(objectArray, 0, arraySize, new Integer(
   2392                         arraySize), comp));
   2393         for (int counter = 0; counter < arraySize; counter++) {
   2394             assertTrue(
   2395                     "Binary search on Object[] with custom comparator answered incorrect position",
   2396                     Arrays.binarySearch(objectArray, objArray[counter], comp) == arraySize
   2397                             - counter - 1);
   2398         }
   2399         try {
   2400             Arrays.binarySearch((Object[])null, 2, 1, (byte) arraySize);
   2401             fail("should throw NullPointerException");
   2402         } catch (NullPointerException e) {
   2403             // expected
   2404         }
   2405         try {
   2406             Arrays.binarySearch((Object[])null, -1, 0, (byte) arraySize);
   2407             fail("should throw NullPointerException");
   2408         } catch (NullPointerException e) {
   2409             // expected
   2410         }
   2411         try {
   2412             Arrays.binarySearch((Object[])null, -1, -2, (byte) arraySize);
   2413             fail("should throw NullPointerException");
   2414         } catch (NullPointerException e) {
   2415             // expected
   2416         }
   2417         try {
   2418             Arrays.binarySearch(objectArray, 2, 1, (char) arraySize, comp);
   2419             fail("should throw IllegalArgumentException");
   2420         } catch (IllegalArgumentException e) {
   2421             // expected
   2422         }
   2423         assertEquals(-1, Arrays.binarySearch(objectArray, 0, 0,
   2424                 (char) arraySize, comp));
   2425         try {
   2426             Arrays.binarySearch(objectArray, -1, -2, (char) arraySize, comp);
   2427             fail("should throw IllegalArgumentException");
   2428         } catch (IllegalArgumentException e) {
   2429             // expected
   2430         }
   2431         try {
   2432             Arrays.binarySearch(objectArray, arraySize + 2, arraySize + 1,
   2433                     (char) arraySize, comp);
   2434             fail("should throw IllegalArgumentException");
   2435         } catch (IllegalArgumentException e) {
   2436             // expected
   2437         }
   2438         try {
   2439             Arrays.binarySearch(objectArray, -1, 0, (char) arraySize, comp);
   2440             fail("should throw ArrayIndexOutOfBoundsException");
   2441         } catch (ArrayIndexOutOfBoundsException e) {
   2442             // expected
   2443         }
   2444         try {
   2445             Arrays.binarySearch(objectArray, 0, arraySize + 1,
   2446                     (char) arraySize, comp);
   2447             fail("should throw ArrayIndexOutOfBoundsException");
   2448         } catch (ArrayIndexOutOfBoundsException e) {
   2449             // expected
   2450         }
   2451         try {
   2452             Arrays.binarySearch(objectArray, 0, arraySize ,
   2453                     new LinkedList(), comp);
   2454             fail("should throw ClassCastException");
   2455         } catch (ClassCastException e) {
   2456             // expected
   2457         }
   2458     }
   2459 
   2460     /**
   2461      * @tests java.util.Arrays#binarySearch(short[], short)
   2462      */
   2463     public void test_binarySearch$SIIS() {
   2464         for (short counter = 0; counter < arraySize; counter++){
   2465             assertTrue("Binary search on short[] answered incorrect position",
   2466                     Arrays.binarySearch(shortArray,counter,arraySize, counter) == counter);
   2467         }
   2468         assertEquals("Binary search succeeded for value not present in array 1",
   2469                 -1, Arrays.binarySearch(shortArray,0,arraySize, (short) -1));
   2470         assertTrue(
   2471                 "Binary search succeeded for value not present in array 2",
   2472                 Arrays.binarySearch(shortArray,0,arraySize, (short) arraySize) == -(arraySize + 1));
   2473         for (short counter = 0; counter < arraySize; counter++){
   2474             shortArray[counter] -= 50;
   2475         }
   2476         for (short counter = 0; counter < arraySize; counter++){
   2477             assertTrue(
   2478                     "Binary search on short[] involving negative numbers answered incorrect position",
   2479                     Arrays.binarySearch(shortArray,counter,arraySize, (short) (counter - 50)) == counter);
   2480         }
   2481         try {
   2482             Arrays.binarySearch((String[])null, 2, 1, (byte) arraySize);
   2483             fail("should throw NullPointerException");
   2484         } catch (NullPointerException e) {
   2485             // expected
   2486         }
   2487         try {
   2488             Arrays.binarySearch((String[])null, -1, 0, (byte) arraySize);
   2489             fail("should throw NullPointerException");
   2490         } catch (NullPointerException e) {
   2491             // expected
   2492         }
   2493         try {
   2494             Arrays.binarySearch((String[])null, -1, -2, (byte) arraySize);
   2495             fail("should throw NullPointerException");
   2496         } catch (NullPointerException e) {
   2497             // expected
   2498         }
   2499         try {
   2500             Arrays.binarySearch(shortArray, 2, 1, (short) arraySize);
   2501             fail("should throw IllegalArgumentException");
   2502         } catch (IllegalArgumentException e) {
   2503             // expected
   2504         }
   2505         assertEquals(-1, Arrays
   2506                 .binarySearch(shortArray, 0, 0, (short) arraySize));
   2507         try {
   2508             Arrays.binarySearch(shortArray, -1, -2, (short) arraySize);
   2509             fail("should throw IllegalArgumentException");
   2510         } catch (IllegalArgumentException e) {
   2511             // expected
   2512         }
   2513         try {
   2514             Arrays.binarySearch(shortArray, arraySize + 2, arraySize + 1,
   2515                     (short) arraySize);
   2516             fail("should throw IllegalArgumentException");
   2517         } catch (IllegalArgumentException e) {
   2518             // expected
   2519         }
   2520         try {
   2521             Arrays.binarySearch(shortArray, -1, 0, (short) arraySize);
   2522             fail("should throw ArrayIndexOutOfBoundsException");
   2523         } catch (ArrayIndexOutOfBoundsException e) {
   2524             // expected
   2525         }
   2526         try {
   2527             Arrays.binarySearch(shortArray, 0, arraySize + 1, (short) arraySize);
   2528             fail("should throw ArrayIndexOutOfBoundsException");
   2529         } catch (ArrayIndexOutOfBoundsException e) {
   2530             // expected
   2531         }
   2532         String[] array = {"a" , "b" , "c"};
   2533         assertEquals(-2,Arrays.binarySearch(array, 1, 2, "a", null));
   2534     }
   2535 
   2536     /**
   2537      * @tests {@link java.util.Arrays#copyOf(byte[],int)
   2538      */
   2539     public void test_copyOf_$BI() throws Exception {
   2540         byte[] result = Arrays.copyOf(byteArray, arraySize*2);
   2541         int i = 0;
   2542         for (; i < arraySize; i++) {
   2543             assertEquals(i, result[i]);
   2544         }
   2545         for (; i < result.length; i++) {
   2546             assertEquals(0, result[i]);
   2547         }
   2548         result = Arrays.copyOf(byteArray, arraySize/2);
   2549         i = 0;
   2550         for (; i < result.length; i++) {
   2551             assertEquals(i, result[i]);
   2552         }
   2553         try {
   2554             Arrays.copyOf((byte[])null, arraySize);
   2555             fail("should throw NullPointerException");
   2556         } catch (NullPointerException e) {
   2557             // expected
   2558         }
   2559         try {
   2560             Arrays.copyOf(byteArray, -1);
   2561             fail("should throw NegativeArraySizeException");
   2562         } catch (NegativeArraySizeException e) {
   2563             // expected
   2564         }
   2565         try {
   2566             Arrays.copyOf((byte[])null, -1);
   2567             fail("should throw NegativeArraySizeException");
   2568         } catch (NegativeArraySizeException e) {
   2569             // expected
   2570         }
   2571     }
   2572 
   2573     /**
   2574      * @tests {@link java.util.Arrays#copyOf(short[],int)
   2575      */
   2576     public void test_copyOf_$SI() throws Exception {
   2577         short[] result = Arrays.copyOf(shortArray, arraySize*2);
   2578         int i = 0;
   2579         for (; i < arraySize; i++) {
   2580             assertEquals(i, result[i]);
   2581         }
   2582         for (; i < result.length; i++) {
   2583             assertEquals(0, result[i]);
   2584         }
   2585         result = Arrays.copyOf(shortArray, arraySize/2);
   2586         i = 0;
   2587         for (; i < result.length; i++) {
   2588             assertEquals(i, result[i]);
   2589         }
   2590         try {
   2591             Arrays.copyOf((short[])null, arraySize);
   2592             fail("should throw NullPointerException");
   2593         } catch (NullPointerException e) {
   2594             // expected
   2595         }
   2596         try {
   2597             Arrays.copyOf(shortArray, -1);
   2598             fail("should throw NegativeArraySizeException");
   2599         } catch (NegativeArraySizeException e) {
   2600             // expected
   2601         }
   2602         try {
   2603             Arrays.copyOf((short[])null, -1);
   2604             fail("should throw NegativeArraySizeException");
   2605         } catch (NegativeArraySizeException e) {
   2606             // expected
   2607         }
   2608     }
   2609 
   2610     /**
   2611      * @tests {@link java.util.Arrays#copyOf(int[],int)
   2612      */
   2613     public void test_copyOf_$II() throws Exception {
   2614         int[] result = Arrays.copyOf(intArray, arraySize*2);
   2615         int i = 0;
   2616         for (; i < arraySize; i++) {
   2617             assertEquals(i, result[i]);
   2618         }
   2619         for (; i < result.length; i++) {
   2620             assertEquals(0, result[i]);
   2621         }
   2622         result = Arrays.copyOf(intArray, arraySize/2);
   2623         i = 0;
   2624         for (; i < result.length; i++) {
   2625             assertEquals(i, result[i]);
   2626         }
   2627         try {
   2628             Arrays.copyOf((int[])null, arraySize);
   2629             fail("should throw NullPointerException");
   2630         } catch (NullPointerException e) {
   2631             // expected
   2632         }
   2633         try {
   2634             Arrays.copyOf(intArray, -1);
   2635             fail("should throw NegativeArraySizeException");
   2636         } catch (NegativeArraySizeException e) {
   2637             // expected
   2638         }
   2639         try {
   2640             Arrays.copyOf((int[])null, -1);
   2641             fail("should throw NegativeArraySizeException");
   2642         } catch (NegativeArraySizeException e) {
   2643             // expected
   2644         }
   2645     }
   2646 
   2647     /**
   2648      * @tests {@link java.util.Arrays#copyOf(boolean[],int)
   2649      */
   2650     public void test_copyOf_$ZI() throws Exception {
   2651         boolean[] result = Arrays.copyOf(booleanArray, arraySize*2);
   2652         int i = 0;
   2653         for (; i < arraySize; i++) {
   2654             assertEquals(booleanArray[i], result[i]);
   2655         }
   2656         for (; i < result.length; i++) {
   2657             assertEquals(false, result[i]);
   2658         }
   2659         result = Arrays.copyOf(booleanArray, arraySize/2);
   2660         i = 0;
   2661         for (; i < result.length; i++) {
   2662             assertEquals(booleanArray[i], result[i]);
   2663         }
   2664         try {
   2665             Arrays.copyOf((boolean[])null, arraySize);
   2666             fail("should throw NullPointerException");
   2667         } catch (NullPointerException e) {
   2668             // expected
   2669         }
   2670         try {
   2671             Arrays.copyOf(booleanArray, -1);
   2672             fail("should throw NegativeArraySizeException");
   2673         } catch (NegativeArraySizeException e) {
   2674             // expected
   2675         }
   2676         try {
   2677             Arrays.copyOf((boolean[])null, -1);
   2678             fail("should throw NegativeArraySizeException");
   2679         } catch (NegativeArraySizeException e) {
   2680             // expected
   2681         }
   2682     }
   2683 
   2684     /**
   2685      * @tests {@link java.util.Arrays#copyOf(char[],int)
   2686      */
   2687     public void test_copyOf_$CI() throws Exception {
   2688         char[] result = Arrays.copyOf(charArray, arraySize*2);
   2689         int i = 0;
   2690         for (; i < arraySize; i++) {
   2691             assertEquals(i+1, result[i]);
   2692         }
   2693         for (; i < result.length; i++) {
   2694             assertEquals(0, result[i]);
   2695         }
   2696         result = Arrays.copyOf(charArray, arraySize/2);
   2697         i = 0;
   2698         for (; i < result.length; i++) {
   2699             assertEquals(i+1, result[i]);
   2700         }
   2701         try {
   2702             Arrays.copyOf((char[])null, arraySize);
   2703             fail("should throw NullPointerException");
   2704         } catch (NullPointerException e) {
   2705             // expected
   2706         }
   2707         try {
   2708             Arrays.copyOf(charArray, -1);
   2709             fail("should throw NegativeArraySizeException");
   2710         } catch (NegativeArraySizeException e) {
   2711             // expected
   2712         }
   2713         try {
   2714             Arrays.copyOf((char[])null, -1);
   2715             fail("should throw NegativeArraySizeException");
   2716         } catch (NegativeArraySizeException e) {
   2717             // expected
   2718         }
   2719     }
   2720 
   2721     /**
   2722      * @tests {@link java.util.Arrays#copyOf(float[],int)
   2723      */
   2724     public void test_copyOf_$FI() throws Exception {
   2725         float[] result = Arrays.copyOf(floatArray, arraySize*2);
   2726         int i = 0;
   2727         for (; i < arraySize; i++) {
   2728             assertEquals(floatArray[i], result[i]);
   2729         }
   2730         for (; i < result.length; i++) {
   2731             assertEquals(0.0f, result[i]);
   2732         }
   2733         result = Arrays.copyOf(floatArray, arraySize/2);
   2734         i = 0;
   2735         for (; i < result.length; i++) {
   2736             assertEquals(floatArray[i], result[i]);
   2737         }
   2738         try {
   2739             Arrays.copyOf((float[])null, arraySize);
   2740             fail("should throw NullPointerException");
   2741         } catch (NullPointerException e) {
   2742             // expected
   2743         }
   2744         try {
   2745             Arrays.copyOf(floatArray, -1);
   2746             fail("should throw NegativeArraySizeException");
   2747         } catch (NegativeArraySizeException e) {
   2748             // expected
   2749         }
   2750         try {
   2751             Arrays.copyOf((float[])null, -1);
   2752             fail("should throw NegativeArraySizeException");
   2753         } catch (NegativeArraySizeException e) {
   2754             // expected
   2755         }
   2756     }
   2757 
   2758     /**
   2759      * @tests {@link java.util.Arrays#copyOf(double[],int)
   2760      */
   2761     public void test_copyOf_$DI() throws Exception {
   2762         double[] result = Arrays.copyOf(doubleArray, arraySize*2);
   2763         int i = 0;
   2764         for (; i < arraySize; i++) {
   2765             assertEquals(doubleArray[i], result[i]);
   2766         }
   2767         for (; i < result.length; i++) {
   2768             assertEquals(0.0, result[i]);
   2769         }
   2770         result = Arrays.copyOf(doubleArray, arraySize/2);
   2771         i = 0;
   2772         for (; i < result.length; i++) {
   2773             assertEquals(doubleArray[i], result[i]);
   2774         }
   2775         try {
   2776             Arrays.copyOf((double[])null, arraySize);
   2777             fail("should throw NullPointerException");
   2778         } catch (NullPointerException e) {
   2779             // expected
   2780         }
   2781         try {
   2782             Arrays.copyOf(doubleArray, -1);
   2783             fail("should throw NegativeArraySizeException");
   2784         } catch (NegativeArraySizeException e) {
   2785             // expected
   2786         }
   2787         try {
   2788             Arrays.copyOf((double[])null, -1);
   2789             fail("should throw NegativeArraySizeException");
   2790         } catch (NegativeArraySizeException e) {
   2791             // expected
   2792         }
   2793     }
   2794 
   2795     /**
   2796      * @tests {@link java.util.Arrays#copyOf(long[],int)
   2797      */
   2798     public void test_copyOf_$JI() throws Exception {
   2799         long[] result = Arrays.copyOf(longArray, arraySize*2);
   2800         int i = 0;
   2801         for (; i < arraySize; i++) {
   2802             assertEquals(longArray[i], result[i]);
   2803         }
   2804         for (; i < result.length; i++) {
   2805             assertEquals(0, result[i]);
   2806         }
   2807         result = Arrays.copyOf(longArray, arraySize/2);
   2808         i = 0;
   2809         for (; i < result.length; i++) {
   2810             assertEquals(longArray[i], result[i]);
   2811         }
   2812         try {
   2813             Arrays.copyOf((long[])null, arraySize);
   2814             fail("should throw NullPointerException");
   2815         } catch (NullPointerException e) {
   2816             // expected
   2817         }
   2818         try {
   2819             Arrays.copyOf(longArray, -1);
   2820             fail("should throw NegativeArraySizeException");
   2821         } catch (NegativeArraySizeException e) {
   2822             // expected
   2823         }
   2824         try {
   2825             Arrays.copyOf((long[])null, -1);
   2826             fail("should throw NegativeArraySizeException");
   2827         } catch (NegativeArraySizeException e) {
   2828             // expected
   2829         }
   2830     }
   2831 
   2832     /**
   2833      * @tests {@link java.util.Arrays#copyOf(T[],int)
   2834      */
   2835     public void test_copyOf_$TI() throws Exception {
   2836         Object[] result = Arrays.copyOf(objArray, arraySize*2);
   2837         int i = 0;
   2838         for (; i < arraySize; i++) {
   2839             assertEquals(objArray[i], result[i]);
   2840         }
   2841         for (; i < result.length; i++) {
   2842             assertNull(result[i]);
   2843         }
   2844         result = Arrays.copyOf(objArray, arraySize/2);
   2845         i = 0;
   2846         for (; i < result.length; i++) {
   2847             assertEquals(objArray[i], result[i]);
   2848         }
   2849         try {
   2850             Arrays.copyOf((String[])null, arraySize);
   2851             fail("should throw NullPointerException");
   2852         } catch (NullPointerException e) {
   2853             // expected
   2854         }
   2855         try {
   2856             Arrays.copyOf(objArray, -1);
   2857             fail("should throw NegativeArraySizeException");
   2858         } catch (NegativeArraySizeException e) {
   2859             // expected
   2860         }
   2861         try {
   2862             Arrays.copyOf((String[])null, -1);
   2863             fail("should throw NullPointerException");
   2864         } catch (NullPointerException e) {
   2865             // expected
   2866         }
   2867 
   2868         Date[] component = new Date[0];
   2869         Object object[] = new Date[0];
   2870 
   2871         object = Arrays.copyOf(component,2);
   2872         assertNotNull(object);
   2873         component = Arrays.copyOf(component,2);
   2874         assertNotNull(component);
   2875         assertEquals(2, component.length);
   2876     }
   2877 
   2878     /**
   2879      * @tests {@link java.util.Arrays#copyOf(T[],int,Class<? extends Object[]>))
   2880      */
   2881     public void test_copyOf_$TILClass() throws Exception {
   2882         Object[] result = Arrays.copyOf(objArray, arraySize*2,Object[].class);
   2883         int i = 0;
   2884         for (; i < arraySize; i++) {
   2885             assertEquals(objArray[i], result[i]);
   2886         }
   2887         for (; i < result.length; i++) {
   2888             assertNull(result[i]);
   2889         }
   2890         result = Arrays.copyOf(objArray, arraySize/2,Object[].class);
   2891         i = 0;
   2892         for (; i < result.length; i++) {
   2893             assertEquals(objArray[i], result[i]);
   2894         }
   2895         result = Arrays.copyOf(objArray, arraySize/2,Integer[].class);
   2896         i = 0;
   2897         for (; i < result.length; i++) {
   2898             assertEquals(objArray[i], result[i]);
   2899         }
   2900         try {
   2901             Arrays.copyOf((Object[])null, arraySize,LinkedList[].class);
   2902             fail("should throw NullPointerException");
   2903         } catch (NullPointerException e) {
   2904             // expected
   2905         }
   2906         try {
   2907             Arrays.copyOf(objArray, arraySize,LinkedList[].class);
   2908             fail("should throw ArrayStoreException ");
   2909         } catch (ArrayStoreException  e) {
   2910             // expected
   2911         }
   2912         try {
   2913             Arrays.copyOf((Object[])null, arraySize,Object[].class);
   2914             fail("should throw NullPointerException");
   2915         } catch (NullPointerException e) {
   2916             // expected
   2917         }
   2918         try {
   2919             Arrays.copyOf(objArray, -1,Object[].class);
   2920             fail("should throw NegativeArraySizeException");
   2921         } catch (NegativeArraySizeException e) {
   2922             // expected
   2923         }
   2924         try {
   2925             Arrays.copyOf((Object[])null, -1,Object[].class);
   2926             fail("should throw NegativeArraySizeException");
   2927         } catch (NegativeArraySizeException e) {
   2928             // expected
   2929         }
   2930         try {
   2931             Arrays.copyOf((Object[])null, -1,LinkedList[].class);
   2932             fail("should throw NegativeArraySizeException");
   2933         } catch (NegativeArraySizeException e) {
   2934             // expected
   2935         }
   2936         try {
   2937             Arrays.copyOf((Object[])null, 0,LinkedList[].class);
   2938             fail("should throw NullPointerException");
   2939         } catch (NullPointerException e) {
   2940             // expected
   2941         }
   2942         assertEquals(0,Arrays.copyOf(objArray, 0,LinkedList[].class).length);
   2943     }
   2944 
   2945     /**
   2946      * @tests {@link java.util.Arrays#copyOfRange(byte[],int,int)
   2947      */
   2948     public void test_copyOfRange_$BII() throws Exception {
   2949         byte[] result = Arrays.copyOfRange(byteArray, 0,arraySize*2);
   2950         int i = 0;
   2951         for (; i < arraySize; i++) {
   2952             assertEquals(i, result[i]);
   2953         }
   2954         for (; i < result.length; i++) {
   2955             assertEquals(0, result[i]);
   2956         }
   2957         result = Arrays.copyOfRange(byteArray,0, arraySize/2);
   2958         i = 0;
   2959         for (; i < result.length; i++) {
   2960             assertEquals(i, result[i]);
   2961         }
   2962         result = Arrays.copyOfRange(byteArray,0, 0);
   2963         assertEquals(0, result.length);
   2964         try {
   2965             Arrays.copyOfRange((byte[])null, 0,arraySize);
   2966             fail("should throw NullPointerException");
   2967         } catch (NullPointerException e) {
   2968             // expected
   2969         }
   2970         try {
   2971             Arrays.copyOfRange((byte[])null, -1,arraySize);
   2972             fail("should throw NullPointerException");
   2973         } catch (NullPointerException e) {
   2974             // expected
   2975         }
   2976         try {
   2977             Arrays.copyOfRange((byte[])null, 0,-1);
   2978             fail("should throw IllegalArgumentException");
   2979         } catch (IllegalArgumentException e) {
   2980             // expected
   2981         }
   2982         try {
   2983             Arrays.copyOfRange(byteArray, -1,arraySize);
   2984             fail("should throw ArrayIndexOutOfBoundsException");
   2985         } catch (ArrayIndexOutOfBoundsException e) {
   2986             // expected
   2987         }
   2988         try {
   2989             Arrays.copyOfRange(byteArray, 0, -1);
   2990             fail("should throw IllegalArgumentException");
   2991         } catch (IllegalArgumentException e) {
   2992             // expected
   2993         }
   2994         assertEquals(byteArray.length + 1, Arrays.copyOfRange(byteArray, 0,
   2995                 byteArray.length + 1).length);
   2996     }
   2997 
   2998     /**
   2999      * @tests {@link java.util.Arrays#copyOfRange(short[],int,int)
   3000      */
   3001     public void test_copyOfRange_$SII() throws Exception {
   3002         short[] result = Arrays.copyOfRange(shortArray, 0,arraySize*2);
   3003         int i = 0;
   3004         for (; i < arraySize; i++) {
   3005             assertEquals(i, result[i]);
   3006         }
   3007         for (; i < result.length; i++) {
   3008             assertEquals(0, result[i]);
   3009         }
   3010         result = Arrays.copyOfRange(shortArray,0, arraySize/2);
   3011         i = 0;
   3012         for (; i < result.length; i++) {
   3013             assertEquals(i, result[i]);
   3014         }
   3015         result = Arrays.copyOfRange(shortArray,0, 0);
   3016         assertEquals(0, result.length);
   3017         try {
   3018             Arrays.copyOfRange((short[])null, 0,arraySize);
   3019             fail("should throw NullPointerException");
   3020         } catch (NullPointerException e) {
   3021             // expected
   3022         }
   3023         try {
   3024             Arrays.copyOfRange((short[])null, -1,arraySize);
   3025             fail("should throw NullPointerException");
   3026         } catch (NullPointerException e) {
   3027             // expected
   3028         }
   3029         try {
   3030             Arrays.copyOfRange((short[])null, 0,-1);
   3031             fail("should throw IllegalArgumentException");
   3032         } catch (IllegalArgumentException e) {
   3033             // expected
   3034         }
   3035         try {
   3036             Arrays.copyOfRange(shortArray, -1,arraySize);
   3037             fail("should throw ArrayIndexOutOfBoundsException");
   3038         } catch (ArrayIndexOutOfBoundsException e) {
   3039             // expected
   3040         }
   3041         try {
   3042             Arrays.copyOfRange(shortArray, 0,-1);
   3043             fail("should throw IllegalArgumentException");
   3044         } catch (IllegalArgumentException e) {
   3045             // expected
   3046         }
   3047         assertEquals(shortArray.length + 1, Arrays.copyOfRange(shortArray, 0,
   3048                 shortArray.length + 1).length);
   3049     }
   3050 
   3051     /**
   3052      * @tests {@link java.util.Arrays#copyOfRange(int[],int,int)
   3053      */
   3054     public void test_copyOfRange_$III() throws Exception {
   3055         int[] result = Arrays.copyOfRange(intArray, 0,arraySize*2);
   3056         int i = 0;
   3057         for (; i < arraySize; i++) {
   3058             assertEquals(i, result[i]);
   3059         }
   3060         for (; i < result.length; i++) {
   3061             assertEquals(0, result[i]);
   3062         }
   3063         result = Arrays.copyOfRange(intArray,0, arraySize/2);
   3064         i = 0;
   3065         for (; i < result.length; i++) {
   3066             assertEquals(i, result[i]);
   3067         }
   3068         result = Arrays.copyOfRange(intArray,0, 0);
   3069         assertEquals(0, result.length);
   3070         try {
   3071             Arrays.copyOfRange((int[])null, 0,arraySize);
   3072             fail("should throw NullPointerException");
   3073         } catch (NullPointerException e) {
   3074             // expected
   3075         }
   3076         try {
   3077             Arrays.copyOfRange((int[])null, -1,arraySize);
   3078             fail("should throw NullPointerException");
   3079         } catch (NullPointerException e) {
   3080             // expected
   3081         }
   3082         try {
   3083             Arrays.copyOfRange((int[])null, 0,-1);
   3084             fail("should throw IllegalArgumentException");
   3085         } catch (IllegalArgumentException e) {
   3086             // expected
   3087         }
   3088         try {
   3089             Arrays.copyOfRange(intArray, -1,arraySize);
   3090             fail("should throw ArrayIndexOutOfBoundsException");
   3091         } catch (ArrayIndexOutOfBoundsException e) {
   3092             // expected
   3093         }
   3094         try {
   3095             Arrays.copyOfRange(intArray, 0,-1);
   3096             fail("should throw IllegalArgumentException");
   3097         } catch (IllegalArgumentException e) {
   3098             // expected
   3099         }
   3100         assertEquals(intArray.length + 1, Arrays.copyOfRange(intArray, 0,
   3101                 intArray.length + 1).length);
   3102     }
   3103 
   3104     /**
   3105      * @tests {@link java.util.Arrays#copyOfRange(long[],int,int)
   3106      */
   3107     public void test_copyOfRange_$JII() throws Exception {
   3108         long[] result = Arrays.copyOfRange(longArray, 0,arraySize*2);
   3109         int i = 0;
   3110         for (; i < arraySize; i++) {
   3111             assertEquals(i, result[i]);
   3112         }
   3113         for (; i < result.length; i++) {
   3114             assertEquals(0, result[i]);
   3115         }
   3116         result = Arrays.copyOfRange(longArray,0, arraySize/2);
   3117         i = 0;
   3118         for (; i < result.length; i++) {
   3119             assertEquals(i, result[i]);
   3120         }
   3121         result = Arrays.copyOfRange(longArray,0, 0);
   3122         assertEquals(0, result.length);
   3123         try {
   3124             Arrays.copyOfRange((long[])null, 0,arraySize);
   3125             fail("should throw NullPointerException");
   3126         } catch (NullPointerException e) {
   3127             // expected
   3128         }
   3129         try {
   3130             Arrays.copyOfRange((long[])null, -1,arraySize);
   3131             fail("should throw NullPointerException");
   3132         } catch (NullPointerException e) {
   3133             // expected
   3134         }
   3135         try {
   3136             Arrays.copyOfRange((long[])null, 0,-1);
   3137             fail("should throw IllegalArgumentException");
   3138         } catch (IllegalArgumentException e) {
   3139             // expected
   3140         }
   3141         try {
   3142             Arrays.copyOfRange(longArray, -1,arraySize);
   3143             fail("should throw ArrayIndexOutOfBoundsException");
   3144         } catch (ArrayIndexOutOfBoundsException e) {
   3145             // expected
   3146         }
   3147         try {
   3148             Arrays.copyOfRange(longArray, 0,-1);
   3149             fail("should throw IllegalArgumentException");
   3150         } catch (IllegalArgumentException e) {
   3151             // expected
   3152         }
   3153         assertEquals(longArray.length + 1, Arrays.copyOfRange(longArray, 0,
   3154                 longArray.length + 1).length);
   3155     }
   3156 
   3157     /**
   3158      * @tests {@link java.util.Arrays#copyOfRange(char[],int,int)
   3159      */
   3160     public void test_copyOfRange_$CII() throws Exception {
   3161         char[] result = Arrays.copyOfRange(charArray, 0,arraySize*2);
   3162         int i = 0;
   3163         for (; i < arraySize; i++) {
   3164             assertEquals(i+1, result[i]);
   3165         }
   3166         for (; i < result.length; i++) {
   3167             assertEquals(0, result[i]);
   3168         }
   3169         result = Arrays.copyOfRange(charArray,0, arraySize/2);
   3170         i = 0;
   3171         for (; i < result.length; i++) {
   3172             assertEquals(i+1, result[i]);
   3173         }
   3174         result = Arrays.copyOfRange(charArray,0, 0);
   3175         assertEquals(0, result.length);
   3176         try {
   3177             Arrays.copyOfRange((char[])null, 0,arraySize);
   3178             fail("should throw NullPointerException");
   3179         } catch (NullPointerException e) {
   3180             // expected
   3181         }
   3182         try {
   3183             Arrays.copyOfRange((char[])null, -1,arraySize);
   3184             fail("should throw NullPointerException");
   3185         } catch (NullPointerException e) {
   3186             // expected
   3187         }
   3188         try {
   3189             Arrays.copyOfRange((char[])null, 0,-1);
   3190             fail("should throw IllegalArgumentException");
   3191         } catch (IllegalArgumentException e) {
   3192             // expected
   3193         }
   3194         try {
   3195             Arrays.copyOfRange(charArray, -1,arraySize);
   3196             fail("should throw ArrayIndexOutOfBoundsException");
   3197         } catch (ArrayIndexOutOfBoundsException e) {
   3198             // expected
   3199         }
   3200         try {
   3201             Arrays.copyOfRange(charArray, 0,-1);
   3202             fail("should throw IllegalArgumentException");
   3203         } catch (IllegalArgumentException e) {
   3204             // expected
   3205         }
   3206         assertEquals(charArray.length + 1, Arrays.copyOfRange(charArray, 0,
   3207                 charArray.length + 1).length);
   3208     }
   3209 
   3210     /**
   3211      * @tests {@link java.util.Arrays#copyOfRange(float[],int,int)
   3212      */
   3213     public void test_copyOfRange_$FII() throws Exception {
   3214         float[] result = Arrays.copyOfRange(floatArray, 0,arraySize*2);
   3215         int i = 0;
   3216         for (; i < arraySize; i++) {
   3217             assertEquals((float)i, result[i]);
   3218         }
   3219         for (; i < result.length; i++) {
   3220             assertEquals(0.0f, result[i]);
   3221         }
   3222         result = Arrays.copyOfRange(floatArray,0, arraySize/2);
   3223         i = 0;
   3224         for (; i < result.length; i++) {
   3225             assertEquals((float)i, result[i]);
   3226         }
   3227         result = Arrays.copyOfRange(floatArray,0, 0);
   3228         assertEquals(0, result.length);
   3229         try {
   3230             Arrays.copyOfRange((float[])null, 0,arraySize);
   3231             fail("should throw NullPointerException");
   3232         } catch (NullPointerException e) {
   3233             // expected
   3234         }
   3235         try {
   3236             Arrays.copyOfRange((float[])null, -1,arraySize);
   3237             fail("should throw NullPointerException");
   3238         } catch (NullPointerException e) {
   3239             // expected
   3240         }
   3241         try {
   3242             Arrays.copyOfRange((float[])null, 0,-1);
   3243             fail("should throw IllegalArgumentException");
   3244         } catch (IllegalArgumentException e) {
   3245             // expected
   3246         }
   3247         try {
   3248             Arrays.copyOfRange(floatArray, -1,arraySize);
   3249             fail("should throw ArrayIndexOutOfBoundsException");
   3250         } catch (ArrayIndexOutOfBoundsException e) {
   3251             // expected
   3252         }
   3253         try {
   3254             Arrays.copyOfRange(floatArray, 0,-1);
   3255             fail("should throw IllegalArgumentException");
   3256         } catch (IllegalArgumentException e) {
   3257             // expected
   3258         }
   3259         assertEquals(floatArray.length + 1, Arrays.copyOfRange(floatArray, 0,
   3260                 floatArray.length + 1).length);
   3261     }
   3262 
   3263     /**
   3264      * @tests {@link java.util.Arrays#copyOfRange(double[],int,int)
   3265      */
   3266     public void test_copyOfRange_$DII() throws Exception {
   3267         double[] result = Arrays.copyOfRange(doubleArray, 0,arraySize*2);
   3268         int i = 0;
   3269         for (; i < arraySize; i++) {
   3270             assertEquals((double)i, result[i]);
   3271         }
   3272         for (; i < result.length; i++) {
   3273             assertEquals(0.0, result[i]);
   3274         }
   3275         result = Arrays.copyOfRange(doubleArray,0, arraySize/2);
   3276         i = 0;
   3277         for (; i < result.length; i++) {
   3278             assertEquals((double)i, result[i]);
   3279         }
   3280         result = Arrays.copyOfRange(doubleArray,0, 0);
   3281         assertEquals(0, result.length);
   3282         try {
   3283             Arrays.copyOfRange((double[])null, 0,arraySize);
   3284             fail("should throw NullPointerException");
   3285         } catch (NullPointerException e) {
   3286             // expected
   3287         }
   3288         try {
   3289             Arrays.copyOfRange((double[])null, -1,arraySize);
   3290             fail("should throw NullPointerException");
   3291         } catch (NullPointerException e) {
   3292             // expected
   3293         }
   3294         try {
   3295             Arrays.copyOfRange((double[])null, 0,-1);
   3296             fail("should throw IllegalArgumentException");
   3297         } catch (IllegalArgumentException e) {
   3298             // expected
   3299         }
   3300         try {
   3301             Arrays.copyOfRange(doubleArray, -1,arraySize);
   3302             fail("should throw ArrayIndexOutOfBoundsException");
   3303         } catch (ArrayIndexOutOfBoundsException e) {
   3304             // expected
   3305         }
   3306         try {
   3307             Arrays.copyOfRange(doubleArray, 0,-1);
   3308             fail("should throw IllegalArgumentException");
   3309         } catch (IllegalArgumentException e) {
   3310             // expected
   3311         }
   3312         assertEquals(doubleArray.length + 1, Arrays.copyOfRange(doubleArray, 0,
   3313                 doubleArray.length + 1).length);
   3314     }
   3315 
   3316     /**
   3317      * @tests {@link java.util.Arrays#copyOfRange(boolean[],int,int)
   3318      */
   3319     public void test_copyOfRange_$ZII() throws Exception {
   3320         boolean[] result = Arrays.copyOfRange(booleanArray, 0,arraySize*2);
   3321         int i = 0;
   3322         for (; i < arraySize; i++) {
   3323             assertEquals(booleanArray[i], result[i]);
   3324         }
   3325         for (; i < result.length; i++) {
   3326             assertEquals(false, result[i]);
   3327         }
   3328         result = Arrays.copyOfRange(booleanArray,0, arraySize/2);
   3329         i = 0;
   3330         for (; i < result.length; i++) {
   3331             assertEquals(booleanArray[i], result[i]);
   3332         }
   3333         result = Arrays.copyOfRange(booleanArray,0, 0);
   3334         assertEquals(0, result.length);
   3335         try {
   3336             Arrays.copyOfRange((boolean[])null, 0,arraySize);
   3337             fail("should throw NullPointerException");
   3338         } catch (NullPointerException e) {
   3339             // expected
   3340         }
   3341         try {
   3342             Arrays.copyOfRange((boolean[])null, -1,arraySize);
   3343             fail("should throw NullPointerException");
   3344         } catch (NullPointerException e) {
   3345             // expected
   3346         }
   3347         try {
   3348             Arrays.copyOfRange((boolean[])null, 0,-1);
   3349             fail("should throw IllegalArgumentException");
   3350         } catch (IllegalArgumentException e) {
   3351             // expected
   3352         }
   3353         try {
   3354             Arrays.copyOfRange(booleanArray, -1,arraySize);
   3355             fail("should throw ArrayIndexOutOfBoundsException");
   3356         } catch (ArrayIndexOutOfBoundsException e) {
   3357             // expected
   3358         }
   3359         try {
   3360             Arrays.copyOfRange(booleanArray, 0,-1);
   3361             fail("should throw IllegalArgumentException");
   3362         } catch (IllegalArgumentException e) {
   3363             // expected
   3364         }
   3365         assertEquals(booleanArray.length + 1, Arrays.copyOfRange(booleanArray, 0,
   3366                 booleanArray.length + 1).length);
   3367     }
   3368 
   3369     /**
   3370      * @tests {@link java.util.Arrays#copyOfRange(Object[],int,int)
   3371      */
   3372     public void test_copyOfRange_$TII() throws Exception {
   3373         Object[] result = Arrays.copyOfRange(objArray, 0,arraySize*2);
   3374         int i = 0;
   3375         for (; i < arraySize; i++) {
   3376             assertEquals(objArray[i], result[i]);
   3377         }
   3378         for (; i < result.length; i++) {
   3379             assertEquals(null, result[i]);
   3380         }
   3381         result = Arrays.copyOfRange(objArray,0, arraySize/2);
   3382         i = 0;
   3383         for (; i < result.length; i++) {
   3384             assertEquals(objArray[i], result[i]);
   3385         }
   3386         result = Arrays.copyOfRange(objArray,0, 0);
   3387         assertEquals(0, result.length);
   3388         try {
   3389             Arrays.copyOfRange((Object[])null, 0,arraySize);
   3390             fail("should throw NullPointerException");
   3391         } catch (NullPointerException e) {
   3392             // expected
   3393         }
   3394         try {
   3395             Arrays.copyOfRange((Object[])null, -1,arraySize);
   3396             fail("should throw NullPointerException");
   3397         } catch (NullPointerException e) {
   3398             // expected
   3399         }
   3400         try {
   3401             Arrays.copyOfRange((Object[])null, 0,-1);
   3402             fail("should throw NullPointerException");
   3403         } catch (NullPointerException e) {
   3404             // expected
   3405         }
   3406         try {
   3407             Arrays.copyOfRange((Object[])objArray, -1,arraySize);
   3408             fail("should throw ArrayIndexOutOfBoundsException");
   3409         } catch (ArrayIndexOutOfBoundsException e) {
   3410             // expected
   3411         }
   3412         try {
   3413             Arrays.copyOfRange((Object[])objArray, 0,-1);
   3414             fail("should throw IllegalArgumentException");
   3415         } catch (IllegalArgumentException e) {
   3416             // expected
   3417         }
   3418         assertEquals(objArray.length + 1, Arrays.copyOfRange(objArray, 0,
   3419                 objArray.length + 1).length);
   3420     }
   3421 
   3422     /**
   3423      * @tests {@link java.util.Arrays#copyOfRange(Object[], int, int, Class)
   3424      */
   3425     public void test_copyOfRange_$TIILClass() throws Exception {
   3426         Object[] result = Arrays.copyOfRange(objArray, 0,arraySize*2,Integer[].class);
   3427         int i = 0;
   3428         for (; i < arraySize; i++) {
   3429             assertEquals(objArray[i], result[i]);
   3430         }
   3431         for (; i < result.length; i++) {
   3432             assertEquals(null, result[i]);
   3433         }
   3434         result = Arrays.copyOfRange(objArray,0, arraySize/2,Integer[].class);
   3435         i = 0;
   3436         for (; i < result.length; i++) {
   3437             assertEquals(objArray[i], result[i]);
   3438         }
   3439         result = Arrays.copyOfRange(objArray,0, 0,Integer[].class);
   3440         assertEquals(0, result.length);
   3441         try {
   3442             Arrays.copyOfRange(null, 0,arraySize,Integer[].class);
   3443             fail("should throw NullPointerException");
   3444         } catch (NullPointerException e) {
   3445             // expected
   3446         }
   3447         try {
   3448             Arrays.copyOfRange(null, -1,arraySize,Integer[].class);
   3449             fail("should throw NullPointerException");
   3450         } catch (NullPointerException e) {
   3451             // expected
   3452         }
   3453         try {
   3454             Arrays.copyOfRange(null, 0,-1,Integer[].class);
   3455             fail("should throw IllegalArgumentException");
   3456         } catch (IllegalArgumentException e) {
   3457             // expected
   3458         }
   3459         try {
   3460             Arrays.copyOfRange(objArray, -1,arraySize,Integer[].class);
   3461             fail("should throw ArrayIndexOutOfBoundsException");
   3462         } catch (ArrayIndexOutOfBoundsException e) {
   3463             // expected
   3464         }
   3465         try {
   3466             Arrays.copyOfRange(objArray, 0,-1,Integer[].class);
   3467             fail("should throw IllegalArgumentException");
   3468         } catch (IllegalArgumentException e) {
   3469             // expected
   3470         }
   3471         try {
   3472             Arrays.copyOfRange(objArray, 0,-1,LinkedList[].class);
   3473             fail("should throw IllegalArgumentException");
   3474         } catch (IllegalArgumentException e) {
   3475             // expected
   3476         }
   3477         try {
   3478             Arrays.copyOfRange(objArray, 0,1,LinkedList[].class);
   3479             fail("should throw ArrayStoreException");
   3480         } catch (ArrayStoreException e) {
   3481             // expected
   3482         }
   3483         try {
   3484             Arrays.copyOfRange(null, 0,1,LinkedList[].class);
   3485             fail("should throw NullPointerException");
   3486         } catch (NullPointerException e) {
   3487             // expected
   3488         }
   3489         try {
   3490             assertEquals(objArray.length + 1, Arrays.copyOfRange(objArray, 0,
   3491                     objArray.length + 1, LinkedList[].class).length);
   3492             fail("should throw ArrayStoreException");
   3493         } catch (ArrayStoreException e) {
   3494             // expected
   3495         }
   3496         assertEquals(0,
   3497                 Arrays.copyOfRange(objArray, 0, 0, LinkedList[].class).length);
   3498     }
   3499 
   3500     /**
   3501      * @tests java.util.Arrays#swap(int, int, Object[])
   3502      */
   3503     /* BEGIN android-removed: tests private implementation detail we don't share.
   3504     public void test_swap_I_I_$Ljava_lang_Object() throws Exception {
   3505     	Method m = Arrays.class.getDeclaredMethod("swap", int.class, int.class, Object[].class);
   3506     	m.setAccessible(true);
   3507     	Integer[] arr = {new Integer(0), new Integer(1), new Integer(2)};
   3508     	m.invoke(null,0, 1, arr);
   3509     	assertEquals("should be equal to 1",1, arr[0].intValue());
   3510     	assertEquals("should be equal to 0",0, arr[1].intValue());
   3511     }
   3512     */
   3513 
   3514 	/**
   3515 	 * Tears down the fixture, for example, close a network connection. This
   3516 	 * method is called after a test is executed.
   3517 	 */
   3518 	protected void tearDown() {
   3519 	}
   3520 }
   3521