harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r386058 [34/49] - in /incubator/harmony/enhanced/classlib/trunk: make/ modules/archive/make/common/ modules/archive/src/test/java/tests/ modules/archive/src/test/java/tests/api/ modules/archive/src/test/java/tests/api/java/ modules/archive/...
Date Wed, 15 Mar 2006 11:47:39 GMT
Added: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/ArraysTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/ArraysTest.java?rev=386058&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/ArraysTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/ArraysTest.java Wed Mar 15 03:46:17 2006
@@ -0,0 +1,1182 @@
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package tests.api.java.util;
+
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.List;
+
+import tests.support.Support_UnmodifiableCollectionTest;
+
+public class ArraysTest extends junit.framework.TestCase {
+
+	public static class ReversedIntegerComparator implements Comparator {
+		public int compare(Object o1, Object o2) {
+			return -(((Integer) o1).compareTo((Integer) o2));
+		}
+
+		public boolean equals(Object o1, Object o2) {
+			return ((Integer) o1).compareTo((Integer) o2) == 0;
+		}
+	}
+
+	final static int arraySize = 100;
+
+	static Object[] objArray;
+
+	static boolean[] booleanArray;
+
+	static byte[] byteArray;
+
+	static char[] charArray;
+
+	static double[] doubleArray;
+
+	static float[] floatArray;
+
+	static int[] intArray;
+
+	static long[] longArray;
+
+	static Object[] objectArray;
+
+	static short[] shortArray;
+	{
+		objArray = new Object[arraySize];
+		for (int i = 0; i < objArray.length; i++)
+			objArray[i] = new Integer(i);
+	}
+
+	/**
+	 * @tests java.util.Arrays#asList(java.lang.Object[])
+	 */
+	public void test_asList$Ljava_lang_Object() {
+		// Test for method java.util.List
+		// java.util.Arrays.asList(java.lang.Object [])
+		List convertedList = Arrays.asList(objectArray);
+		for (int counter = 0; counter < arraySize; counter++) {
+			assertTrue(
+					"Array and List converted from array do not contain identical elements",
+					convertedList.get(counter) == objectArray[counter]);
+		}
+		convertedList.set(50, new Integer(1000));
+		assertTrue("set/get did not work on coverted list", convertedList.get(
+				50).equals(new Integer(1000)));
+		convertedList.set(50, new Integer(50));
+		new Support_UnmodifiableCollectionTest("", convertedList).runTest();
+
+		Object[] myArray = (Object[]) (objectArray.clone());
+		myArray[30] = null;
+		myArray[60] = null;
+		convertedList = Arrays.asList(myArray);
+		for (int counter = 0; counter < arraySize; counter++) {
+			assertTrue(
+					"Array and List converted from array do not contain identical elements",
+					convertedList.get(counter) == myArray[counter]);
+		}
+
+		try {
+			Arrays.asList(null);
+		} catch (NullPointerException e) {
+			return;
+		}
+		fail("asList with null arg didn't throw NPE");
+	}
+
+	/**
+	 * @tests java.util.Arrays#binarySearch(byte[], byte)
+	 */
+	public void test_binarySearch$BB() {
+		// Test for method int java.util.Arrays.binarySearch(byte [], byte)
+		for (byte counter = 0; counter < arraySize; counter++)
+			assertTrue("Binary search on byte[] answered incorrect position",
+					Arrays.binarySearch(byteArray, counter) == counter);
+		assertTrue("Binary search suceeded for value not present in array 1",
+				Arrays.binarySearch(intArray, (byte) -1) == -1);
+		assertTrue(
+				"Binary search suceeded for value not present in array 2",
+				Arrays.binarySearch(intArray, (byte) arraySize) == -(arraySize + 1));
+		for (byte counter = 0; counter < arraySize; counter++)
+			byteArray[counter] -= 50;
+		for (byte counter = 0; counter < arraySize; counter++)
+			assertTrue(
+					"Binary search on byte[] involving negative numbers answered incorrect position",
+					Arrays.binarySearch(byteArray, (byte) (counter - 50)) == counter);
+	}
+
+	/**
+	 * @tests java.util.Arrays#binarySearch(char[], char)
+	 */
+	public void test_binarySearch$CC() {
+		// Test for method int java.util.Arrays.binarySearch(char [], char)
+		for (char counter = 0; counter < arraySize; counter++)
+			assertTrue(
+					"Binary search on char[] answered incorrect position",
+					Arrays.binarySearch(charArray, (char) (counter + 1)) == counter);
+		assertTrue("Binary search suceeded for value not present in array 1",
+				Arrays.binarySearch(charArray, '\u0000') == -1);
+		assertTrue(
+				"Binary search suceeded for value not present in array 2",
+				Arrays.binarySearch(charArray, (char) (arraySize + 1)) == -(arraySize + 1));
+	}
+
+	/**
+	 * @tests java.util.Arrays#binarySearch(double[], double)
+	 */
+	public void test_binarySearch$DD() {
+		// Test for method int java.util.Arrays.binarySearch(double [], double)
+		for (int counter = 0; counter < arraySize; counter++)
+			assertTrue(
+					"Binary search on double[] answered incorrect position",
+					Arrays.binarySearch(doubleArray, (double) counter) == (double) counter);
+		assertTrue("Binary search suceeded for value not present in array 1",
+				Arrays.binarySearch(doubleArray, (double) -1) == -1);
+		assertTrue(
+				"Binary search suceeded for value not present in array 2",
+				Arrays.binarySearch(doubleArray, (double) arraySize) == -(arraySize + 1));
+		for (int counter = 0; counter < arraySize; counter++)
+			doubleArray[counter] -= (double) 50;
+		for (int counter = 0; counter < arraySize; counter++)
+			assertTrue(
+					"Binary search on double[] involving negative numbers answered incorrect position",
+					Arrays.binarySearch(doubleArray, (double) (counter - 50)) == (double) counter);
+
+		double[] specials = new double[] { Double.NEGATIVE_INFINITY,
+				-Double.MAX_VALUE, -2d, -Double.MIN_VALUE, -0d, 0d,
+				Double.MIN_VALUE, 2d, Double.MAX_VALUE,
+				Double.POSITIVE_INFINITY, Double.NaN };
+		for (int i = 0; i < specials.length; i++) {
+			int result = Arrays.binarySearch(specials, specials[i]);
+			assertTrue(specials[i] + " invalid: " + result, result == i);
+		}
+		assertTrue("-1d", Arrays.binarySearch(specials, -1d) == -4);
+		assertTrue("1d", Arrays.binarySearch(specials, 1d) == -8);
+
+	}
+
+	/**
+	 * @tests java.util.Arrays#binarySearch(float[], float)
+	 */
+	public void test_binarySearch$FF() {
+		// Test for method int java.util.Arrays.binarySearch(float [], float)
+		for (int counter = 0; counter < arraySize; counter++)
+			assertTrue(
+					"Binary search on float[] answered incorrect position",
+					Arrays.binarySearch(floatArray, (float) counter) == (float) counter);
+		assertTrue("Binary search suceeded for value not present in array 1",
+				Arrays.binarySearch(floatArray, (float) -1) == -1);
+		assertTrue(
+				"Binary search suceeded for value not present in array 2",
+				Arrays.binarySearch(floatArray, (float) arraySize) == -(arraySize + 1));
+		for (int counter = 0; counter < arraySize; counter++)
+			floatArray[counter] -= (float) 50;
+		for (int counter = 0; counter < arraySize; counter++)
+			assertTrue(
+					"Binary search on float[] involving negative numbers answered incorrect position",
+					Arrays.binarySearch(floatArray, (float) counter - 50) == (float) counter);
+
+		float[] specials = new float[] { Float.NEGATIVE_INFINITY,
+				-Float.MAX_VALUE, -2f, -Float.MIN_VALUE, -0f, 0f,
+				Float.MIN_VALUE, 2f, Float.MAX_VALUE, Float.POSITIVE_INFINITY,
+				Float.NaN };
+		for (int i = 0; i < specials.length; i++) {
+			int result = Arrays.binarySearch(specials, specials[i]);
+			assertTrue(specials[i] + " invalid: " + result, result == i);
+		}
+		assertTrue("-1f", Arrays.binarySearch(specials, -1f) == -4);
+		assertTrue("1f", Arrays.binarySearch(specials, 1f) == -8);
+	}
+
+	/**
+	 * @tests java.util.Arrays#binarySearch(int[], int)
+	 */
+	public void test_binarySearch$II() {
+		// Test for method int java.util.Arrays.binarySearch(int [], int)
+		for (int counter = 0; counter < arraySize; counter++)
+			assertTrue("Binary search on int[] answered incorrect position",
+					Arrays.binarySearch(intArray, counter) == counter);
+		assertTrue("Binary search suceeded for value not present in array 1",
+				Arrays.binarySearch(intArray, -1) == -1);
+		assertTrue("Binary search suceeded for value not present in array 2",
+				Arrays.binarySearch(intArray, arraySize) == -(arraySize + 1));
+		for (int counter = 0; counter < arraySize; counter++)
+			intArray[counter] -= 50;
+		for (int counter = 0; counter < arraySize; counter++)
+			assertTrue(
+					"Binary search on int[] involving negative numbers answered incorrect position",
+					Arrays.binarySearch(intArray, counter - 50) == counter);
+	}
+
+	/**
+	 * @tests java.util.Arrays#binarySearch(long[], long)
+	 */
+	public void test_binarySearch$JJ() {
+		// Test for method int java.util.Arrays.binarySearch(long [], long)
+		for (long counter = 0; counter < arraySize; counter++)
+			assertTrue("Binary search on long[] answered incorrect position",
+					Arrays.binarySearch(longArray, counter) == counter);
+		assertTrue("Binary search suceeded for value not present in array 1",
+				Arrays.binarySearch(longArray, (long) -1) == -1);
+		assertTrue(
+				"Binary search suceeded for value not present in array 2",
+				Arrays.binarySearch(longArray, (long) arraySize) == -(arraySize + 1));
+		for (long counter = 0; counter < arraySize; counter++)
+			longArray[(int) counter] -= (long) 50;
+		for (long counter = 0; counter < arraySize; counter++)
+			assertTrue(
+					"Binary search on long[] involving negative numbers answered incorrect position",
+					Arrays.binarySearch(longArray, counter - (long) 50) == counter);
+	}
+
+	/**
+	 * @tests java.util.Arrays#binarySearch(java.lang.Object[],
+	 *        java.lang.Object)
+	 */
+	public void test_binarySearch$Ljava_lang_ObjectLjava_lang_Object() {
+		// Test for method int java.util.Arrays.binarySearch(java.lang.Object
+		// [], java.lang.Object)
+		for (int counter = 0; counter < arraySize; counter++)
+			assertTrue(
+					"Binary search on Object[] answered incorrect position",
+					Arrays.binarySearch(objectArray, objArray[counter]) == counter);
+		assertTrue("Binary search suceeded for value not present in array 1",
+				Arrays.binarySearch(objectArray, new Integer(-1)) == -1);
+		assertTrue(
+				"Binary search suceeded for value not present in array 2",
+				Arrays.binarySearch(objectArray, new Integer(arraySize)) == -(arraySize + 1));
+	}
+
+	/**
+	 * @tests java.util.Arrays#binarySearch(java.lang.Object[],
+	 *        java.lang.Object, java.util.Comparator)
+	 */
+	public void test_binarySearch$Ljava_lang_ObjectLjava_lang_ObjectLjava_util_Comparator() {
+		// Test for method int java.util.Arrays.binarySearch(java.lang.Object
+		// [], java.lang.Object, java.util.Comparator)
+		Comparator comp = new ReversedIntegerComparator();
+		for (int counter = 0; counter < arraySize; counter++)
+			objectArray[counter] = objArray[arraySize - counter - 1];
+		assertTrue(
+				"Binary search suceeded for value not present in array 1",
+				Arrays.binarySearch(objectArray, new Integer(-1), comp) == -(arraySize + 1));
+		assertTrue(
+				"Binary search suceeded for value not present in array 2",
+				Arrays.binarySearch(objectArray, new Integer(arraySize), comp) == -1);
+		for (int counter = 0; counter < arraySize; counter++)
+			assertTrue(
+					"Binary search on Object[] with custom comparator answered incorrect position",
+					Arrays.binarySearch(objectArray, objArray[counter], comp) == arraySize
+							- counter - 1);
+	}
+
+	/**
+	 * @tests java.util.Arrays#binarySearch(short[], short)
+	 */
+	public void test_binarySearch$SS() {
+		// Test for method int java.util.Arrays.binarySearch(short [], short)
+		for (short counter = 0; counter < arraySize; counter++)
+			assertTrue("Binary search on short[] answered incorrect position",
+					Arrays.binarySearch(shortArray, counter) == counter);
+		assertTrue("Binary search suceeded for value not present in array 1",
+				Arrays.binarySearch(intArray, (short) -1) == -1);
+		assertTrue(
+				"Binary search suceeded for value not present in array 2",
+				Arrays.binarySearch(intArray, (short) arraySize) == -(arraySize + 1));
+		for (short counter = 0; counter < arraySize; counter++)
+			shortArray[counter] -= 50;
+		for (short counter = 0; counter < arraySize; counter++)
+			assertTrue(
+					"Binary search on short[] involving negative numbers answered incorrect position",
+					Arrays.binarySearch(shortArray, (short) (counter - 50)) == counter);
+	}
+
+	/**
+	 * @tests java.util.Arrays#fill(byte[], byte)
+	 */
+	public void test_fill$BB() {
+		// Test for method void java.util.Arrays.fill(byte [], byte)
+
+		byte d[] = new byte[1000];
+		Arrays.fill(d, Byte.MAX_VALUE);
+		for (int i = 0; i < d.length; i++)
+			assertTrue("Failed to fill byte array correctly",
+					d[i] == Byte.MAX_VALUE);
+	}
+
+	/**
+	 * @tests java.util.Arrays#fill(byte[], int, int, byte)
+	 */
+	public void test_fill$BIIB() {
+		// Test for method void java.util.Arrays.fill(byte [], int, int, byte)
+		byte val = Byte.MAX_VALUE;
+		byte d[] = new byte[1000];
+		Arrays.fill(d, 400, d.length, val);
+		for (int i = 0; i < 400; i++)
+			assertTrue("Filled elements not in range", !(d[i] == val));
+		for (int i = 400; i < d.length; i++)
+			assertTrue("Failed to fill byte array correctly", d[i] == val);
+
+		int result;
+		try {
+			Arrays.fill(new byte[2], 2, 1, (byte) 27);
+			result = 0;
+		} catch (ArrayIndexOutOfBoundsException e) {
+			result = 1;
+		} catch (IllegalArgumentException e) {
+			result = 2;
+		}
+		assertTrue("Wrong exception1", result == 2);
+		try {
+			Arrays.fill(new byte[2], -1, 1, (byte) 27);
+			result = 0;
+		} catch (ArrayIndexOutOfBoundsException e) {
+			result = 1;
+		} catch (IllegalArgumentException e) {
+			result = 2;
+		}
+		assertTrue("Wrong exception2", result == 1);
+		try {
+			Arrays.fill(new byte[2], 1, 4, (byte) 27);
+			result = 0;
+		} catch (ArrayIndexOutOfBoundsException e) {
+			result = 1;
+		} catch (IllegalArgumentException e) {
+			result = 2;
+		}
+		assertTrue("Wrong exception", result == 1);
+	}
+
+	/**
+	 * @tests java.util.Arrays#fill(short[], short)
+	 */
+	public void test_fill$SS() {
+		// Test for method void java.util.Arrays.fill(short [], short)
+
+		short d[] = new short[1000];
+		Arrays.fill(d, Short.MAX_VALUE);
+		for (int i = 0; i < d.length; i++)
+			assertTrue("Failed to fill short array correctly",
+					d[i] == Short.MAX_VALUE);
+	}
+
+	/**
+	 * @tests java.util.Arrays#fill(short[], int, int, short)
+	 */
+	public void test_fill$SIIS() {
+		// Test for method void java.util.Arrays.fill(short [], int, int, short)
+		short val = Short.MAX_VALUE;
+		short d[] = new short[1000];
+		Arrays.fill(d, 400, d.length, val);
+		for (int i = 0; i < 400; i++)
+			assertTrue("Filled elements not in range", !(d[i] == val));
+		for (int i = 400; i < d.length; i++)
+			assertTrue("Failed to fill short array correctly", d[i] == val);
+	}
+
+	/**
+	 * @tests java.util.Arrays#fill(char[], char)
+	 */
+	public void test_fill$CC() {
+		// Test for method void java.util.Arrays.fill(char [], char)
+
+		char d[] = new char[1000];
+		Arrays.fill(d, 'V');
+		for (int i = 0; i < d.length; i++)
+			assertTrue("Failed to fill char array correctly", d[i] == 'V');
+	}
+
+	/**
+	 * @tests java.util.Arrays#fill(char[], int, int, char)
+	 */
+	public void test_fill$CIIC() {
+		// Test for method void java.util.Arrays.fill(char [], int, int, char)
+		char val = 'T';
+		char d[] = new char[1000];
+		Arrays.fill(d, 400, d.length, val);
+		for (int i = 0; i < 400; i++)
+			assertTrue("Filled elements not in range", !(d[i] == val));
+		for (int i = 400; i < d.length; i++)
+			assertTrue("Failed to fill char array correctly", d[i] == val);
+	}
+
+	/**
+	 * @tests java.util.Arrays#fill(int[], int)
+	 */
+	public void test_fill$II() {
+		// Test for method void java.util.Arrays.fill(int [], int)
+
+		int d[] = new int[1000];
+		Arrays.fill(d, Integer.MAX_VALUE);
+		for (int i = 0; i < d.length; i++)
+			assertTrue("Failed to fill int array correctly",
+					d[i] == Integer.MAX_VALUE);
+	}
+
+	/**
+	 * @tests java.util.Arrays#fill(int[], int, int, int)
+	 */
+	public void test_fill$IIII() {
+		// Test for method void java.util.Arrays.fill(int [], int, int, int)
+		int val = Integer.MAX_VALUE;
+		int d[] = new int[1000];
+		Arrays.fill(d, 400, d.length, val);
+		for (int i = 0; i < 400; i++)
+			assertTrue("Filled elements not in range", !(d[i] == val));
+		for (int i = 400; i < d.length; i++)
+			assertTrue("Failed to fill int array correctly", d[i] == val);
+	}
+
+	/**
+	 * @tests java.util.Arrays#fill(long[], long)
+	 */
+	public void test_fill$JJ() {
+		// Test for method void java.util.Arrays.fill(long [], long)
+
+		long d[] = new long[1000];
+		Arrays.fill(d, Long.MAX_VALUE);
+		for (int i = 0; i < d.length; i++)
+			assertTrue("Failed to fill long array correctly",
+					d[i] == Long.MAX_VALUE);
+	}
+
+	/**
+	 * @tests java.util.Arrays#fill(long[], int, int, long)
+	 */
+	public void test_fill$JIIJ() {
+		// Test for method void java.util.Arrays.fill(long [], int, int, long)
+		long d[] = new long[1000];
+		Arrays.fill(d, 400, d.length, Long.MAX_VALUE);
+		for (int i = 0; i < 400; i++)
+			assertTrue("Filled elements not in range", !(d[i] == Long.MAX_VALUE));
+		for (int i = 400; i < d.length; i++)
+			assertTrue("Failed to fill long array correctly",
+					d[i] == Long.MAX_VALUE);
+	}
+
+	/**
+	 * @tests java.util.Arrays#fill(float[], float)
+	 */
+	public void test_fill$FF() {
+		// Test for method void java.util.Arrays.fill(float [], float)
+		float d[] = new float[1000];
+		Arrays.fill(d, Float.MAX_VALUE);
+		for (int i = 0; i < d.length; i++)
+			assertTrue("Failed to fill float array correctly",
+					d[i] == Float.MAX_VALUE);
+	}
+
+	/**
+	 * @tests java.util.Arrays#fill(float[], int, int, float)
+	 */
+	public void test_fill$FIIF() {
+		// Test for method void java.util.Arrays.fill(float [], int, int, float)
+		float val = Float.MAX_VALUE;
+		float d[] = new float[1000];
+		Arrays.fill(d, 400, d.length, val);
+		for (int i = 0; i < 400; i++)
+			assertTrue("Filled elements not in range", !(d[i] == val));
+		for (int i = 400; i < d.length; i++)
+			assertTrue("Failed to fill float array correctly", d[i] == val);
+	}
+
+	/**
+	 * @tests java.util.Arrays#fill(double[], double)
+	 */
+	public void test_fill$DD() {
+		// Test for method void java.util.Arrays.fill(double [], double)
+
+		double d[] = new double[1000];
+		Arrays.fill(d, Double.MAX_VALUE);
+		for (int i = 0; i < d.length; i++)
+			assertTrue("Failed to fill double array correctly",
+					d[i] == Double.MAX_VALUE);
+	}
+
+	/**
+	 * @tests java.util.Arrays#fill(double[], int, int, double)
+	 */
+	public void test_fill$DIID() {
+		// Test for method void java.util.Arrays.fill(double [], int, int,
+		// double)
+		double val = Double.MAX_VALUE;
+		double d[] = new double[1000];
+		Arrays.fill(d, 400, d.length, val);
+		for (int i = 0; i < 400; i++)
+			assertTrue("Filled elements not in range", !(d[i] == val));
+		for (int i = 400; i < d.length; i++)
+			assertTrue("Failed to fill double array correctly", d[i] == val);
+	}
+
+	/**
+	 * @tests java.util.Arrays#fill(boolean[], boolean)
+	 */
+	public void test_fill$ZZ() {
+		// Test for method void java.util.Arrays.fill(boolean [], boolean)
+
+		boolean d[] = new boolean[1000];
+		Arrays.fill(d, true);
+		for (int i = 0; i < d.length; i++)
+			assertTrue("Failed to fill boolean array correctly", d[i] == true);
+	}
+
+	/**
+	 * @tests java.util.Arrays#fill(boolean[], int, int, boolean)
+	 */
+	public void test_fill$ZIIZ() {
+		// Test for method void java.util.Arrays.fill(boolean [], int, int,
+		// boolean)
+		boolean val = true;
+		boolean d[] = new boolean[1000];
+		Arrays.fill(d, 400, d.length, val);
+		for (int i = 0; i < 400; i++)
+			assertTrue("Filled elements not in range", !(d[i] == val));
+		for (int i = 400; i < d.length; i++)
+			assertTrue("Failed to fill boolean array correctly", d[i] == val);
+	}
+
+	/**
+	 * @tests java.util.Arrays#fill(java.lang.Object[], java.lang.Object)
+	 */
+	public void test_fill$Ljava_lang_ObjectLjava_lang_Object() {
+		// Test for method void java.util.Arrays.fill(java.lang.Object [],
+		// java.lang.Object)
+		Object val = new Object();
+		Object d[] = new Object[1000];
+		Arrays.fill(d, 0, d.length, val);
+		for (int i = 0; i < d.length; i++)
+			assertTrue("Failed to fill Object array correctly", d[i] == val);
+	}
+
+	/**
+	 * @tests java.util.Arrays#fill(java.lang.Object[], int, int,
+	 *        java.lang.Object)
+	 */
+	public void test_fill$Ljava_lang_ObjectIILjava_lang_Object() {
+		// Test for method void java.util.Arrays.fill(java.lang.Object [], int,
+		// int, java.lang.Object)
+		Object val = new Object();
+		Object d[] = new Object[1000];
+		Arrays.fill(d, 400, d.length, val);
+		for (int i = 0; i < 400; i++)
+			assertTrue("Filled elements not in range", !(d[i] == val));
+		for (int i = 400; i < d.length; i++)
+			assertTrue("Failed to fill Object array correctly", d[i] == val);
+
+		Arrays.fill(d, 400, d.length, null);
+		for (int i = 400; i < d.length; i++)
+			assertTrue("Failed to fill Object array correctly with nulls",
+					d[i] == null);
+	}
+
+	/**
+	 * @tests java.util.Arrays#equals(byte[], byte[])
+	 */
+	public void test_equals$B$B() {
+		// Test for method boolean java.util.Arrays.equals(byte [], byte [])
+		byte d[] = new byte[1000];
+		byte x[] = new byte[1000];
+		Arrays.fill(d, Byte.MAX_VALUE);
+		Arrays.fill(x, Byte.MIN_VALUE);
+		assertTrue("Inequal arrays returned true", !Arrays.equals(d, x));
+		Arrays.fill(x, Byte.MAX_VALUE);
+		assertTrue("equal arrays returned false", Arrays.equals(d, x));
+	}
+
+	/**
+	 * @tests java.util.Arrays#equals(short[], short[])
+	 */
+	public void test_equals$S$S() {
+		// Test for method boolean java.util.Arrays.equals(short [], short [])
+		short d[] = new short[1000];
+		short x[] = new short[1000];
+		Arrays.fill(d, Short.MAX_VALUE);
+		Arrays.fill(x, Short.MIN_VALUE);
+		assertTrue("Inequal arrays returned true", !Arrays.equals(d, x));
+		Arrays.fill(x, Short.MAX_VALUE);
+		assertTrue("equal arrays returned false", Arrays.equals(d, x));
+	}
+
+	/**
+	 * @tests java.util.Arrays#equals(char[], char[])
+	 */
+	public void test_equals$C$C() {
+		// Test for method boolean java.util.Arrays.equals(char [], char [])
+		char d[] = new char[1000];
+		char x[] = new char[1000];
+		char c = 'T';
+		Arrays.fill(d, c);
+		Arrays.fill(x, 'L');
+		assertTrue("Inequal arrays returned true", !Arrays.equals(d, x));
+		Arrays.fill(x, c);
+		assertTrue("equal arrays returned false", Arrays.equals(d, x));
+	}
+
+	/**
+	 * @tests java.util.Arrays#equals(int[], int[])
+	 */
+	public void test_equals$I$I() {
+		// Test for method boolean java.util.Arrays.equals(int [], int [])
+		int d[] = new int[1000];
+		int x[] = new int[1000];
+		Arrays.fill(d, Integer.MAX_VALUE);
+		Arrays.fill(x, Integer.MIN_VALUE);
+		assertTrue("Inequal arrays returned true", !Arrays.equals(d, x));
+		Arrays.fill(x, Integer.MAX_VALUE);
+		assertTrue("equal arrays returned false", Arrays.equals(d, x));
+
+		assertTrue("wrong result for null array1", !Arrays.equals(new int[2],
+				null));
+		assertTrue("wrong result for null array2", !Arrays.equals(null,
+				new int[2]));
+	}
+
+	/**
+	 * @tests java.util.Arrays#equals(long[], long[])
+	 */
+	public void test_equals$J$J() {
+		// Test for method boolean java.util.Arrays.equals(long [], long [])
+		long d[] = new long[1000];
+		long x[] = new long[1000];
+		Arrays.fill(d, Long.MAX_VALUE);
+		Arrays.fill(x, Long.MIN_VALUE);
+		assertTrue("Inequal arrays returned true", !Arrays.equals(d, x));
+		Arrays.fill(x, Long.MAX_VALUE);
+		assertTrue("equal arrays returned false", Arrays.equals(d, x));
+
+		assertTrue("should be false", !Arrays.equals(
+				new long[] { 0x100000000L }, new long[] { 0x200000000L }));
+
+	}
+
+	/**
+	 * @tests java.util.Arrays#equals(float[], float[])
+	 */
+	public void test_equals$F$F() {
+		// Test for method boolean java.util.Arrays.equals(float [], float [])
+		float d[] = new float[1000];
+		float x[] = new float[1000];
+		Arrays.fill(d, Float.MAX_VALUE);
+		Arrays.fill(x, Float.MIN_VALUE);
+		assertTrue("Inequal arrays returned true", !Arrays.equals(d, x));
+		Arrays.fill(x, Float.MAX_VALUE);
+		assertTrue("equal arrays returned false", Arrays.equals(d, x));
+
+		assertTrue("NaN not equals", Arrays.equals(new float[] { Float.NaN },
+				new float[] { Float.NaN }));
+		assertTrue("0f equals -0f", !Arrays.equals(new float[] { 0f },
+				new float[] { -0f }));
+	}
+
+	/**
+	 * @tests java.util.Arrays#equals(double[], double[])
+	 */
+	public void test_equals$D$D() {
+		// Test for method boolean java.util.Arrays.equals(double [], double [])
+		double d[] = new double[1000];
+		double x[] = new double[1000];
+		Arrays.fill(d, Double.MAX_VALUE);
+		Arrays.fill(x, Double.MIN_VALUE);
+		assertTrue("Inequal arrays returned true", !Arrays.equals(d, x));
+		Arrays.fill(x, Double.MAX_VALUE);
+		assertTrue("equal arrays returned false", Arrays.equals(d, x));
+
+		assertTrue("should be false", !Arrays.equals(new double[] { 1.0 },
+				new double[] { 2.0 }));
+
+		assertTrue("NaN not equals", Arrays.equals(new double[] { Double.NaN },
+				new double[] { Double.NaN }));
+		assertTrue("0d equals -0d", !Arrays.equals(new double[] { 0d },
+				new double[] { -0d }));
+	}
+
+	/**
+	 * @tests java.util.Arrays#equals(boolean[], boolean[])
+	 */
+	public void test_equals$Z$Z() {
+		// Test for method boolean java.util.Arrays.equals(boolean [], boolean
+		// [])
+		boolean d[] = new boolean[1000];
+		boolean x[] = new boolean[1000];
+		Arrays.fill(d, true);
+		Arrays.fill(x, false);
+		assertTrue("Inequal arrays returned true", !Arrays.equals(d, x));
+		Arrays.fill(x, true);
+		assertTrue("equal arrays returned false", Arrays.equals(d, x));
+	}
+
+	/**
+	 * @tests java.util.Arrays#equals(java.lang.Object[], java.lang.Object[])
+	 */
+	public void test_equals$Ljava_lang_Object$Ljava_lang_Object() {
+		// Test for method boolean java.util.Arrays.equals(java.lang.Object [],
+		// java.lang.Object [])
+		Object d[] = new Object[1000];
+		Object x[] = new Object[1000];
+		Object o = new Object();
+		Arrays.fill(d, o);
+		Arrays.fill(x, new Object());
+		assertTrue("Inequal arrays returned true", !Arrays.equals(d, x));
+		Arrays.fill(x, o);
+		d[50] = null;
+		x[50] = null;
+		assertTrue("equal arrays returned false", Arrays.equals(d, x));
+	}
+
+	/**
+	 * @tests java.util.Arrays#sort(byte[])
+	 */
+	public void test_sort$B() {
+		// Test for method void java.util.Arrays.sort(byte [])
+		byte[] reversedArray = new byte[arraySize];
+		for (int counter = 0; counter < arraySize; counter++)
+			reversedArray[counter] = (byte) (arraySize - counter - 1);
+		Arrays.sort(reversedArray);
+		for (int counter = 0; counter < arraySize; counter++)
+			assertTrue("Resulting array not sorted",
+					reversedArray[counter] == (byte) counter);
+	}
+
+	/**
+	 * @tests java.util.Arrays#sort(byte[], int, int)
+	 */
+	public void test_sort$BII() {
+		// Test for method void java.util.Arrays.sort(byte [], int, int)
+		int startIndex = arraySize / 4;
+		int endIndex = 3 * arraySize / 4;
+		byte[] reversedArray = new byte[arraySize];
+		byte[] originalReversedArray = new byte[arraySize];
+		for (int counter = 0; counter < arraySize; counter++) {
+			reversedArray[counter] = (byte) (arraySize - counter - 1);
+			originalReversedArray[counter] = reversedArray[counter];
+		}
+		Arrays.sort(reversedArray, startIndex, endIndex);
+		for (int counter = 0; counter < startIndex; counter++)
+			assertTrue("Array modified outside of bounds",
+					reversedArray[counter] == originalReversedArray[counter]);
+		for (int counter = startIndex; counter < endIndex - 1; counter++)
+			assertTrue("Array not sorted within bounds",
+					reversedArray[counter] <= reversedArray[counter + 1]);
+		for (int counter = endIndex; counter < arraySize; counter++)
+			assertTrue("Array modified outside of bounds",
+					reversedArray[counter] == originalReversedArray[counter]);
+	}
+
+	/**
+	 * @tests java.util.Arrays#sort(char[])
+	 */
+	public void test_sort$C() {
+		// Test for method void java.util.Arrays.sort(char [])
+		char[] reversedArray = new char[arraySize];
+		for (int counter = 0; counter < arraySize; counter++)
+			reversedArray[counter] = (char) (arraySize - counter - 1);
+		Arrays.sort(reversedArray);
+		for (int counter = 0; counter < arraySize; counter++)
+			assertTrue("Resulting array not sorted",
+					reversedArray[counter] == (char) counter);
+
+	}
+
+	/**
+	 * @tests java.util.Arrays#sort(char[], int, int)
+	 */
+	public void test_sort$CII() {
+		// Test for method void java.util.Arrays.sort(char [], int, int)
+		int startIndex = arraySize / 4;
+		int endIndex = 3 * arraySize / 4;
+		char[] reversedArray = new char[arraySize];
+		char[] originalReversedArray = new char[arraySize];
+		for (int counter = 0; counter < arraySize; counter++) {
+			reversedArray[counter] = (char) (arraySize - counter - 1);
+			originalReversedArray[counter] = reversedArray[counter];
+		}
+		Arrays.sort(reversedArray, startIndex, endIndex);
+		for (int counter = 0; counter < startIndex; counter++)
+			assertTrue("Array modified outside of bounds",
+					reversedArray[counter] == originalReversedArray[counter]);
+		for (int counter = startIndex; counter < endIndex - 1; counter++)
+			assertTrue("Array not sorted within bounds",
+					reversedArray[counter] <= reversedArray[counter + 1]);
+		for (int counter = endIndex; counter < arraySize; counter++)
+			assertTrue("Array modified outside of bounds",
+					reversedArray[counter] == originalReversedArray[counter]);
+
+	}
+
+	/**
+	 * @tests java.util.Arrays#sort(double[])
+	 */
+	public void test_sort$D() {
+		// Test for method void java.util.Arrays.sort(double [])
+		double[] reversedArray = new double[arraySize];
+		for (int counter = 0; counter < arraySize; counter++)
+			reversedArray[counter] = (double) (arraySize - counter - 1);
+		Arrays.sort(reversedArray);
+		for (int counter = 0; counter < arraySize; counter++)
+			assertTrue("Resulting array not sorted",
+					reversedArray[counter] == (double) counter);
+
+		double[] specials1 = new double[] { Double.NaN, Double.MAX_VALUE,
+				Double.MIN_VALUE, 0d, -0d, Double.POSITIVE_INFINITY,
+				Double.NEGATIVE_INFINITY };
+		double[] specials2 = new double[] { 0d, Double.POSITIVE_INFINITY, -0d,
+				Double.NEGATIVE_INFINITY, Double.MIN_VALUE, Double.NaN,
+				Double.MAX_VALUE };
+		double[] answer = new double[] { Double.NEGATIVE_INFINITY, -0d, 0d,
+				Double.MIN_VALUE, Double.MAX_VALUE, Double.POSITIVE_INFINITY,
+				Double.NaN };
+
+		Arrays.sort(specials1);
+		Object[] print1 = new Object[specials1.length];
+		for (int i = 0; i < specials1.length; i++)
+			print1[i] = new Double(specials1[i]);
+		assertTrue("specials sort incorrectly 1: " + Arrays.asList(print1),
+				Arrays.equals(specials1, answer));
+
+		Arrays.sort(specials2);
+		Object[] print2 = new Object[specials2.length];
+		for (int i = 0; i < specials2.length; i++)
+			print2[i] = new Double(specials2[i]);
+		assertTrue("specials sort incorrectly 2: " + Arrays.asList(print2),
+				Arrays.equals(specials2, answer));
+	}
+
+	/**
+	 * @tests java.util.Arrays#sort(double[], int, int)
+	 */
+	public void test_sort$DII() {
+		// Test for method void java.util.Arrays.sort(double [], int, int)
+		int startIndex = arraySize / 4;
+		int endIndex = 3 * arraySize / 4;
+		double[] reversedArray = new double[arraySize];
+		double[] originalReversedArray = new double[arraySize];
+		for (int counter = 0; counter < arraySize; counter++) {
+			reversedArray[counter] = (double) (arraySize - counter - 1);
+			originalReversedArray[counter] = reversedArray[counter];
+		}
+		Arrays.sort(reversedArray, startIndex, endIndex);
+		for (int counter = 0; counter < startIndex; counter++)
+			assertTrue("Array modified outside of bounds",
+					reversedArray[counter] == originalReversedArray[counter]);
+		for (int counter = startIndex; counter < endIndex - 1; counter++)
+			assertTrue("Array not sorted within bounds",
+					reversedArray[counter] <= reversedArray[counter + 1]);
+		for (int counter = endIndex; counter < arraySize; counter++)
+			assertTrue("Array modified outside of bounds",
+					reversedArray[counter] == originalReversedArray[counter]);
+
+	}
+
+	/**
+	 * @tests java.util.Arrays#sort(float[])
+	 */
+	public void test_sort$F() {
+		// Test for method void java.util.Arrays.sort(float [])
+		float[] reversedArray = new float[arraySize];
+		for (int counter = 0; counter < arraySize; counter++)
+			reversedArray[counter] = (float) (arraySize - counter - 1);
+		Arrays.sort(reversedArray);
+		for (int counter = 0; counter < arraySize; counter++)
+			assertTrue("Resulting array not sorted",
+					reversedArray[counter] == (float) counter);
+
+		float[] specials1 = new float[] { Float.NaN, Float.MAX_VALUE,
+				Float.MIN_VALUE, 0f, -0f, Float.POSITIVE_INFINITY,
+				Float.NEGATIVE_INFINITY };
+		float[] specials2 = new float[] { 0f, Float.POSITIVE_INFINITY, -0f,
+				Float.NEGATIVE_INFINITY, Float.MIN_VALUE, Float.NaN,
+				Float.MAX_VALUE };
+		float[] answer = new float[] { Float.NEGATIVE_INFINITY, -0f, 0f,
+				Float.MIN_VALUE, Float.MAX_VALUE, Float.POSITIVE_INFINITY,
+				Float.NaN };
+
+		Arrays.sort(specials1);
+		Object[] print1 = new Object[specials1.length];
+		for (int i = 0; i < specials1.length; i++)
+			print1[i] = new Float(specials1[i]);
+		assertTrue("specials sort incorrectly 1: " + Arrays.asList(print1),
+				Arrays.equals(specials1, answer));
+
+		Arrays.sort(specials2);
+		Object[] print2 = new Object[specials2.length];
+		for (int i = 0; i < specials2.length; i++)
+			print2[i] = new Float(specials2[i]);
+		assertTrue("specials sort incorrectly 2: " + Arrays.asList(print2),
+				Arrays.equals(specials2, answer));
+	}
+
+	/**
+	 * @tests java.util.Arrays#sort(float[], int, int)
+	 */
+	public void test_sort$FII() {
+		// Test for method void java.util.Arrays.sort(float [], int, int)
+		int startIndex = arraySize / 4;
+		int endIndex = 3 * arraySize / 4;
+		float[] reversedArray = new float[arraySize];
+		float[] originalReversedArray = new float[arraySize];
+		for (int counter = 0; counter < arraySize; counter++) {
+			reversedArray[counter] = (float) (arraySize - counter - 1);
+			originalReversedArray[counter] = reversedArray[counter];
+		}
+		Arrays.sort(reversedArray, startIndex, endIndex);
+		for (int counter = 0; counter < startIndex; counter++)
+			assertTrue("Array modified outside of bounds",
+					reversedArray[counter] == originalReversedArray[counter]);
+		for (int counter = startIndex; counter < endIndex - 1; counter++)
+			assertTrue("Array not sorted within bounds",
+					reversedArray[counter] <= reversedArray[counter + 1]);
+		for (int counter = endIndex; counter < arraySize; counter++)
+			assertTrue("Array modified outside of bounds",
+					reversedArray[counter] == originalReversedArray[counter]);
+	}
+
+	/**
+	 * @tests java.util.Arrays#sort(int[])
+	 */
+	public void test_sort$I() {
+		// Test for method void java.util.Arrays.sort(int [])
+		int[] reversedArray = new int[arraySize];
+		for (int counter = 0; counter < arraySize; counter++)
+			reversedArray[counter] = arraySize - counter - 1;
+		Arrays.sort(reversedArray);
+		for (int counter = 0; counter < arraySize; counter++)
+			assertTrue("Resulting array not sorted",
+					reversedArray[counter] == counter);
+	}
+
+	/**
+	 * @tests java.util.Arrays#sort(int[], int, int)
+	 */
+	public void test_sort$III() {
+		// Test for method void java.util.Arrays.sort(int [], int, int)
+		int startIndex = arraySize / 4;
+		int endIndex = 3 * arraySize / 4;
+		int[] reversedArray = new int[arraySize];
+		int[] originalReversedArray = new int[arraySize];
+		for (int counter = 0; counter < arraySize; counter++) {
+			reversedArray[counter] = arraySize - counter - 1;
+			originalReversedArray[counter] = reversedArray[counter];
+		}
+		Arrays.sort(reversedArray, startIndex, endIndex);
+		for (int counter = 0; counter < startIndex; counter++)
+			assertTrue("Array modified outside of bounds",
+					reversedArray[counter] == originalReversedArray[counter]);
+		for (int counter = startIndex; counter < endIndex - 1; counter++)
+			assertTrue("Array not sorted within bounds",
+					reversedArray[counter] <= reversedArray[counter + 1]);
+		for (int counter = endIndex; counter < arraySize; counter++)
+			assertTrue("Array modified outside of bounds",
+					reversedArray[counter] == originalReversedArray[counter]);
+
+	}
+
+	/**
+	 * @tests java.util.Arrays#sort(long[])
+	 */
+	public void test_sort$J() {
+		// Test for method void java.util.Arrays.sort(long [])
+		long[] reversedArray = new long[arraySize];
+		for (int counter = 0; counter < arraySize; counter++)
+			reversedArray[counter] = (long) (arraySize - counter - 1);
+		Arrays.sort(reversedArray);
+		for (int counter = 0; counter < arraySize; counter++)
+			assertTrue("Resulting array not sorted",
+					reversedArray[counter] == (long) counter);
+
+	}
+
+	/**
+	 * @tests java.util.Arrays#sort(long[], int, int)
+	 */
+	public void test_sort$JII() {
+		// Test for method void java.util.Arrays.sort(long [], int, int)
+		int startIndex = arraySize / 4;
+		int endIndex = 3 * arraySize / 4;
+		long[] reversedArray = new long[arraySize];
+		long[] originalReversedArray = new long[arraySize];
+		for (int counter = 0; counter < arraySize; counter++) {
+			reversedArray[counter] = (long) (arraySize - counter - 1);
+			originalReversedArray[counter] = reversedArray[counter];
+		}
+		Arrays.sort(reversedArray, startIndex, endIndex);
+		for (int counter = 0; counter < startIndex; counter++)
+			assertTrue("Array modified outside of bounds",
+					reversedArray[counter] == originalReversedArray[counter]);
+		for (int counter = startIndex; counter < endIndex - 1; counter++)
+			assertTrue("Array not sorted within bounds",
+					reversedArray[counter] <= reversedArray[counter + 1]);
+		for (int counter = endIndex; counter < arraySize; counter++)
+			assertTrue("Array modified outside of bounds",
+					reversedArray[counter] == originalReversedArray[counter]);
+
+	}
+
+	/**
+	 * @tests java.util.Arrays#sort(java.lang.Object[])
+	 */
+	public void test_sort$Ljava_lang_Object() {
+		// Test for method void java.util.Arrays.sort(java.lang.Object [])
+		Object[] reversedArray = new Object[arraySize];
+		for (int counter = 0; counter < arraySize; counter++)
+			reversedArray[counter] = objectArray[arraySize - counter - 1];
+		Arrays.sort(reversedArray);
+		for (int counter = 0; counter < arraySize; counter++)
+			assertTrue("Resulting array not sorted",
+					reversedArray[counter] == objectArray[counter]);
+	}
+
+	/**
+	 * @tests java.util.Arrays#sort(java.lang.Object[], int, int)
+	 */
+	public void test_sort$Ljava_lang_ObjectII() {
+		// Test for method void java.util.Arrays.sort(java.lang.Object [], int,
+		// int)
+		int startIndex = arraySize / 4;
+		int endIndex = 3 * arraySize / 4;
+		Object[] reversedArray = new Object[arraySize];
+		Object[] originalReversedArray = new Object[arraySize];
+		for (int counter = 0; counter < arraySize; counter++) {
+			reversedArray[counter] = objectArray[arraySize - counter - 1];
+			originalReversedArray[counter] = reversedArray[counter];
+		}
+		Arrays.sort(reversedArray, startIndex, endIndex);
+		for (int counter = 0; counter < startIndex; counter++)
+			assertTrue("Array modified outside of bounds",
+					reversedArray[counter] == originalReversedArray[counter]);
+		for (int counter = startIndex; counter < endIndex - 1; counter++)
+			assertTrue("Array not sorted within bounds",
+					((Comparable) reversedArray[counter])
+							.compareTo(reversedArray[counter + 1]) <= 0);
+		for (int counter = endIndex; counter < arraySize; counter++)
+			assertTrue("Array modified outside of bounds",
+					reversedArray[counter] == originalReversedArray[counter]);
+	}
+
+	/**
+	 * @tests java.util.Arrays#sort(java.lang.Object[], int, int,
+	 *        java.util.Comparator)
+	 */
+	public void test_sort$Ljava_lang_ObjectIILjava_util_Comparator() {
+		// Test for method void java.util.Arrays.sort(java.lang.Object [], int,
+		// int, java.util.Comparator)
+		int startIndex = arraySize / 4;
+		int endIndex = 3 * arraySize / 4;
+		ReversedIntegerComparator comp = new ReversedIntegerComparator();
+		Object[] originalArray = new Object[arraySize];
+		for (int counter = 0; counter < arraySize; counter++)
+			originalArray[counter] = objectArray[counter];
+		Arrays.sort(objectArray, startIndex, endIndex, comp);
+		for (int counter = 0; counter < startIndex; counter++)
+			assertTrue("Array modified outside of bounds",
+					objectArray[counter] == originalArray[counter]);
+		for (int counter = startIndex; counter < endIndex - 1; counter++)
+			assertTrue("Array not sorted within bounds", comp.compare(
+					objectArray[counter], objectArray[counter + 1]) <= 0);
+		for (int counter = endIndex; counter < arraySize; counter++)
+			assertTrue("Array modified outside of bounds",
+					objectArray[counter] == originalArray[counter]);
+	}
+
+	/**
+	 * @tests java.util.Arrays#sort(java.lang.Object[], java.util.Comparator)
+	 */
+	public void test_sort$Ljava_lang_ObjectLjava_util_Comparator() {
+		// Test for method void java.util.Arrays.sort(java.lang.Object [],
+		// java.util.Comparator)
+		ReversedIntegerComparator comp = new ReversedIntegerComparator();
+		Arrays.sort(objectArray, comp);
+		for (int counter = 0; counter < arraySize - 1; counter++)
+			assertTrue("Array not sorted correctly with custom comparator",
+					comp
+							.compare(objectArray[counter],
+									objectArray[counter + 1]) <= 0);
+	}
+
+	/**
+	 * @tests java.util.Arrays#sort(short[])
+	 */
+	public void test_sort$S() {
+		// Test for method void java.util.Arrays.sort(short [])
+		short[] reversedArray = new short[arraySize];
+		for (int counter = 0; counter < arraySize; counter++)
+			reversedArray[counter] = (short) (arraySize - counter - 1);
+		Arrays.sort(reversedArray);
+		for (int counter = 0; counter < arraySize; counter++)
+			assertTrue("Resulting array not sorted",
+					reversedArray[counter] == (short) counter);
+	}
+
+	/**
+	 * @tests java.util.Arrays#sort(short[], int, int)
+	 */
+	public void test_sort$SII() {
+		// Test for method void java.util.Arrays.sort(short [], int, int)
+		int startIndex = arraySize / 4;
+		int endIndex = 3 * arraySize / 4;
+		short[] reversedArray = new short[arraySize];
+		short[] originalReversedArray = new short[arraySize];
+		for (int counter = 0; counter < arraySize; counter++) {
+			reversedArray[counter] = (short) (arraySize - counter - 1);
+			originalReversedArray[counter] = reversedArray[counter];
+		}
+		Arrays.sort(reversedArray, startIndex, endIndex);
+		for (int counter = 0; counter < startIndex; counter++)
+			assertTrue("Array modified outside of bounds",
+					reversedArray[counter] == originalReversedArray[counter]);
+		for (int counter = startIndex; counter < endIndex - 1; counter++)
+			assertTrue("Array not sorted within bounds",
+					reversedArray[counter] <= reversedArray[counter + 1]);
+		for (int counter = endIndex; counter < arraySize; counter++)
+			assertTrue("Array modified outside of bounds",
+					reversedArray[counter] == originalReversedArray[counter]);
+	}
+
+	/**
+	 * Sets up the fixture, for example, open a network connection. This method
+	 * is called before a test is executed.
+	 */
+	protected void setUp() {
+		booleanArray = new boolean[arraySize];
+		byteArray = new byte[arraySize];
+		charArray = new char[arraySize];
+		doubleArray = new double[arraySize];
+		floatArray = new float[arraySize];
+		intArray = new int[arraySize];
+		longArray = new long[arraySize];
+		objectArray = new Object[arraySize];
+		shortArray = new short[arraySize];
+
+		for (int counter = 0; counter < arraySize; counter++) {
+			byteArray[counter] = (byte) counter;
+			charArray[counter] = (char) (counter + 1);
+			doubleArray[counter] = counter;
+			floatArray[counter] = counter;
+			intArray[counter] = counter;
+			longArray[counter] = counter;
+			objectArray[counter] = objArray[counter];
+			shortArray[counter] = (short) counter;
+		}
+		for (int counter = 0; counter < arraySize; counter += 2) {
+			booleanArray[counter] = false;
+			booleanArray[counter + 1] = true;
+		}
+	}
+
+	/**
+	 * Tears down the fixture, for example, close a network connection. This
+	 * method is called after a test is executed.
+	 */
+	protected void tearDown() {
+	}
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/BitSetTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/BitSetTest.java?rev=386058&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/BitSetTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/BitSetTest.java Wed Mar 15 03:46:17 2006
@@ -0,0 +1,1315 @@
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package tests.api.java.util;
+
+import java.util.BitSet;
+
+public class BitSetTest extends junit.framework.TestCase {
+
+	BitSet eightbs;
+
+	/**
+	 * @tests java.util.BitSet#BitSet()
+	 */
+	public void test_Constructor() {
+		// Test for method java.util.BitSet()
+		BitSet bs = new BitSet();
+		// Default size for a BitSet should be 64 elements;
+
+		assertTrue("Created BitSet of incorrect size", bs.size() == 64);
+		assertTrue("New BitSet had invalid string representation", bs
+				.toString().equals("{}"));
+	}
+
+	/**
+	 * @tests java.util.BitSet#BitSet(int)
+	 */
+	public void test_ConstructorI() {
+		// Test for method java.util.BitSet(int)
+		BitSet bs = new BitSet(128);
+		// Default size for a BitSet should be 64 elements;
+
+		assertTrue("Created BitSet of incorrect size", bs.size() == 128);
+		assertTrue("New BitSet had invalid string representation: "
+				+ bs.toString(), bs.toString().equals("{}"));
+
+		// All BitSets are created with elements of multiples of 64
+
+		bs = new BitSet(89);
+		assertTrue("Failed to round BitSet element size", bs.size() == 128);
+
+		try {
+			bs = new BitSet(-9);
+			fail(
+					"Failed to throw exception when creating a new BitSet with negative elements value");
+		} catch (NegativeArraySizeException e) {
+			// Correct behaviour
+		}
+	}
+
+	/**
+	 * @tests java.util.BitSet#clone()
+	 */
+	public void test_clone() {
+		// Test for method java.lang.Object java.util.BitSet.clone()
+		BitSet bs;
+		bs = (BitSet) eightbs.clone();
+		assertTrue("Clone failed to return equal BitSet", eightbs.equals(bs));
+
+	}
+
+	/**
+	 * @tests java.util.BitSet#equals(java.lang.Object)
+	 */
+	public void test_equalsLjava_lang_Object() {
+		// Test for method boolean java.util.BitSet.equals(java.lang.Object)
+		BitSet bs;
+
+		bs = (BitSet) eightbs.clone();
+		assertTrue("Same BitSet returned false", eightbs.equals(eightbs));
+		assertTrue("Identical BitSets returned false", eightbs.equals(bs));
+		bs.clear(6);
+		assertTrue("Different BitSets returned true", !eightbs.equals(bs));
+		// Grow the BitSet
+		bs = (BitSet) eightbs.clone();
+		bs.set(128);
+		assertTrue("Different sized BitSet with higher bit set returned true",
+				!eightbs.equals(bs));
+		bs.clear(128);
+		assertTrue(
+				"Different sized BitSet with higher bits not set returned false",
+				eightbs.equals(bs));
+	}
+
+	/**
+	 * @tests java.util.BitSet#hashCode()
+	 */
+	public void test_hashCode() {
+		// Test for method int java.util.BitSet.hashCode()
+		BitSet bs = (BitSet) eightbs.clone();
+		bs.clear(2);
+		bs.clear(6);
+		assertTrue("BitSet returns wrong hash value: " + bs.hashCode(), bs
+				.hashCode() == 1129);
+		bs.set(10);
+		bs.clear(3);
+		assertTrue("BitSet returns wrong hash value: " + bs.hashCode(), bs
+				.hashCode() == 97);
+	}
+
+	/**
+	 * @tests java.util.BitSet#clear()
+	 */
+	public void test_clear() {
+		eightbs.clear();
+		for (int i = 0; i < 8; i++)
+			assertTrue("Clear didn't clear bit " + i, !eightbs.get(i));
+		assertEquals("Test1: Wrong length", 0, eightbs.length());
+
+		BitSet bs = new BitSet(3400);
+		bs.set(0, bs.size() - 1); // ensure all bits are 1's
+		bs.set(bs.size() - 1);
+		bs.clear();
+		assertEquals("Test2: Wrong length", 0, bs.length());
+		assertEquals("Test2: isEmpty() returned incorrect value", true, bs
+				.isEmpty());
+		assertEquals("Test2: cardinality() returned incorrect value", 0, bs
+				.cardinality());
+	}
+
+	/**
+	 * @tests java.util.BitSet#clear(int)
+	 */
+	public void test_clearI() {
+		// Test for method void java.util.BitSet.clear(int)
+
+		eightbs.clear(7);
+		assertTrue("Failed to clear bit", !eightbs.get(7));
+
+		// Check to see all other bits are still set
+		for (int i = 0; i < 7; i++)
+			assertTrue("Clear cleared incorrect bits", eightbs.get(i));
+
+		eightbs.clear(165);
+		assertTrue("Failed to clear bit", !eightbs.get(165));
+		// Try out of range
+		try {
+			eightbs.clear(-1);
+			fail("Failed to throw expected out of bounds exception");
+		} catch (IndexOutOfBoundsException e) {
+			// Correct behaviour
+		}
+
+		BitSet bs = new BitSet(0);
+		assertTrue("Test1: Wrong length, " + bs.size(), bs.length() == 0);
+		bs.clear(0);
+		assertTrue("Test2: Wrong length" + bs.size(), bs.length() == 0);
+	}
+
+	/**
+	 * @tests java.util.BitSet#clear(int, int)
+	 */
+	public void test_clearII() {
+		// Test for method void java.util.BitSet.clear(int, int)
+		// pos1 and pos2 are in the same bitset element
+		BitSet bs = new BitSet(16);
+		int initialSize = bs.size();
+		bs.set(0, initialSize);
+		bs.clear(5);
+		bs.clear(15);
+		bs.clear(7, 11);
+		for (int i = 0; i < 7; i++) {
+			if (i == 5)
+				assertTrue("Shouldn't have flipped bit " + i, !bs.get(i));
+			else
+				assertTrue("Shouldn't have cleared bit " + i, bs.get(i));
+		}
+		for (int i = 7; i < 11; i++)
+			assertTrue("Failed to clear bit " + i, !bs.get(i));
+
+		for (int i = 11; i < initialSize; i++) {
+			if (i == 15)
+				assertTrue("Shouldn't have flipped bit " + i, !bs.get(i));
+			else
+				assertTrue("Shouldn't have cleared bit " + i, bs.get(i));
+		}
+
+		for (int i = initialSize; i < bs.size(); i++) {
+			assertTrue("Shouldn't have flipped bit " + i, !bs.get(i));
+		}
+
+		// pos1 and pos2 is in the same bitset element, boundary testing
+		bs = new BitSet(16);
+		initialSize = bs.size();
+		bs.set(0, initialSize);
+		bs.clear(7, 64);
+		assertTrue("Failed to grow BitSet", bs.size() == 128);
+		for (int i = 0; i < 7; i++)
+			assertTrue("Shouldn't have cleared bit " + i, bs.get(i));
+		for (int i = 7; i < 64; i++)
+			assertTrue("Failed to clear bit " + i, !bs.get(i));
+		for (int i = 64; i < bs.size(); i++) {
+			assertTrue("Shouldn't have flipped bit " + i, !bs.get(i));
+		}
+		// more boundary testing
+		bs = new BitSet(32);
+		initialSize = bs.size();
+		bs.set(0, initialSize);
+		bs.clear(0, 64);
+		for (int i = 0; i < 64; i++)
+			assertTrue("Failed to clear bit " + i, !bs.get(i));
+		for (int i = 64; i < bs.size(); i++) {
+			assertTrue("Shouldn't have flipped bit " + i, !bs.get(i));
+		}
+
+		bs = new BitSet(32);
+		initialSize = bs.size();
+		bs.set(0, initialSize);
+		bs.clear(0, 65);
+		for (int i = 0; i < 65; i++)
+			assertTrue("Failed to clear bit " + i, !bs.get(i));
+		for (int i = 65; i < bs.size(); i++) {
+			assertTrue("Shouldn't have flipped bit " + i, !bs.get(i));
+		}
+
+		// pos1 and pos2 are in two sequential bitset elements
+		bs = new BitSet(128);
+		initialSize = bs.size();
+		bs.set(0, initialSize);
+		bs.clear(7);
+		bs.clear(110);
+		bs.clear(9, 74);
+		for (int i = 0; i < 9; i++) {
+			if (i == 7)
+				assertTrue("Shouldn't have flipped bit " + i, !bs.get(i));
+			else
+				assertTrue("Shouldn't have cleared bit " + i, bs.get(i));
+		}
+		for (int i = 9; i < 74; i++)
+			assertTrue("Failed to clear bit " + i, !bs.get(i));
+		for (int i = 74; i < initialSize; i++) {
+			if (i == 110)
+				assertTrue("Shouldn't have flipped bit " + i, !bs.get(i));
+			else
+				assertTrue("Shouldn't have cleared bit " + i, bs.get(i));
+		}
+		for (int i = initialSize; i < bs.size(); i++) {
+			assertTrue("Shouldn't have flipped bit " + i, !bs.get(i));
+		}
+
+		// pos1 and pos2 are in two non-sequential bitset elements
+		bs = new BitSet(256);
+		bs.set(0, 256);
+		bs.clear(7);
+		bs.clear(255);
+		bs.clear(9, 219);
+		for (int i = 0; i < 9; i++) {
+			if (i == 7)
+				assertTrue("Shouldn't have flipped bit " + i, !bs.get(i));
+			else
+				assertTrue("Shouldn't have cleared bit " + i, bs.get(i));
+		}
+
+		for (int i = 9; i < 219; i++)
+			assertTrue("failed to clear bit " + i, !bs.get(i));
+
+		for (int i = 219; i < 255; i++)
+			assertTrue("Shouldn't have cleared bit " + i, bs.get(i));
+
+		for (int i = 255; i < bs.size(); i++)
+			assertTrue("Shouldn't have flipped bit " + i, !bs.get(i));
+
+		// test illegal args
+		bs = new BitSet(10);
+		try {
+			bs.clear(-1, 3);
+			fail(
+					"Test1: Attempt to flip with  negative index failed to generate exception");
+		} catch (IndexOutOfBoundsException e) {
+		}
+
+		try {
+			bs.clear(2, -1);
+			fail(
+					"Test2: Attempt to flip with negative index failed to generate exception");
+		} catch (IndexOutOfBoundsException e) {
+		}
+
+		try {
+			bs.clear(4, 2);
+			fail(
+					"Test4: Attempt to flip with illegal args failed to generate exception");
+		} catch (IndexOutOfBoundsException e) {
+		}
+	}
+
+	/**
+	 * @tests java.util.BitSet#get(int)
+	 */
+	public void test_getI() {
+		// Test for method boolean java.util.BitSet.get(int)
+
+		BitSet bs = new BitSet();
+		bs.set(8);
+		assertTrue("Get returned true for index out of range", !eightbs.get(99));
+		assertTrue("Get returned false for set value", eightbs.get(3));
+		assertTrue("Get returned true for a non set value", !bs.get(0));
+
+		try {
+			bs.get(-1);
+			fail(
+					"Attempt to get at negative index failed to generate exception");
+		} catch (IndexOutOfBoundsException e) {
+			// Correct behaviour
+		}
+
+		bs = new BitSet(1);
+		assertTrue("Access greater than size", !bs.get(64));
+
+		bs = new BitSet();
+		bs.set(63);
+		assertTrue("Test highest bit", bs.get(63));
+	}
+
+	/**
+	 * @tests java.util.BitSet#get(int, int)
+	 */
+	public void test_getII() {
+		// Test for method boolean java.util.BitSet.get(int, int)
+		BitSet bs, resultbs, correctbs;
+		bs = new BitSet(512);
+		bs.set(3, 9);
+		bs.set(10, 20);
+		bs.set(60, 75);
+		bs.set(121);
+		bs.set(130, 140);
+
+		// pos1 and pos2 are in the same bitset element, at index0
+		resultbs = bs.get(3, 6);
+		correctbs = new BitSet(3);
+		correctbs.set(0, 3);
+		assertTrue("Test1: Returned incorrect BitSet", resultbs
+				.equals(correctbs));
+
+		// pos1 and pos2 are in the same bitset element, at index 1
+		resultbs = bs.get(100, 125);
+		correctbs = new BitSet(25);
+		correctbs.set(21);
+		assertTrue("Test2: Returned incorrect BitSet", resultbs
+				.equals(correctbs));
+
+		// pos1 in bitset element at index 0, and pos2 in bitset element at
+		// index 1
+		resultbs = bs.get(15, 125);
+		correctbs = new BitSet(25);
+		correctbs.set(0, 5);
+		correctbs.set(45, 60);
+		correctbs.set(121 - 15);
+		assertTrue("Test3: Returned incorrect BitSet", resultbs
+				.equals(correctbs));
+
+		// pos1 in bitset element at index 1, and pos2 in bitset element at
+		// index 2
+		resultbs = bs.get(70, 145);
+		correctbs = new BitSet(75);
+		correctbs.set(0, 5);
+		correctbs.set(51);
+		correctbs.set(60, 70);
+		assertTrue("Test4: Returned incorrect BitSet", resultbs
+				.equals(correctbs));
+
+		// pos1 in bitset element at index 0, and pos2 in bitset element at
+		// index 2
+		resultbs = bs.get(5, 145);
+		correctbs = new BitSet(140);
+		correctbs.set(0, 4);
+		correctbs.set(5, 15);
+		correctbs.set(55, 70);
+		correctbs.set(116);
+		correctbs.set(125, 135);
+		assertTrue("Test5: Returned incorrect BitSet", resultbs
+				.equals(correctbs));
+
+		// pos1 in bitset element at index 0, and pos2 in bitset element at
+		// index 3
+		resultbs = bs.get(5, 250);
+		correctbs = new BitSet(200);
+		correctbs.set(0, 4);
+		correctbs.set(5, 15);
+		correctbs.set(55, 70);
+		correctbs.set(116);
+		correctbs.set(125, 135);
+		assertTrue("Test6: Returned incorrect BitSet", resultbs
+				.equals(correctbs));
+
+		assertTrue("equality principle", bs.equals(bs.get(0, bs.size())));
+
+		// more tests
+		BitSet bs2 = new BitSet(129);
+		bs2.set(0, 20);
+		bs2.set(62, 65);
+		bs2.set(121, 123);
+		resultbs = bs2.get(1, 124);
+		correctbs = new BitSet(129);
+		correctbs.set(0, 19);
+		correctbs.set(61, 64);
+		correctbs.set(120, 122);
+		assertTrue("Test6: Returned incorrect BitSet", resultbs
+				.equals(correctbs));
+
+		// equality principle with some boundary conditions
+		bs2 = new BitSet(128);
+		bs2.set(2, 20);
+		bs2.set(62);
+		bs2.set(121, 123);
+		bs2.set(127);
+		resultbs = bs2.get(0, bs2.size());
+		assertTrue("equality principle", bs2.equals(resultbs));
+
+		bs2 = new BitSet(128);
+		bs2.set(2, 20);
+		bs2.set(62);
+		bs2.set(121, 123);
+		bs2.set(127);
+		bs2.flip(0, 128);
+		resultbs = bs2.get(0, bs.size());
+		assertTrue("equality principle", bs2.equals(resultbs));
+	}
+
+	/**
+	 * @tests java.util.BitSet#set(int)
+	 */
+	public void test_setI() {
+		// Test for method void java.util.BitSet.set(int)
+
+		BitSet bs = new BitSet();
+		bs.set(8);
+		assertTrue("Failed to set bit", bs.get(8));
+
+		try {
+			bs.set(-1);
+			fail(
+					"Attempt to set at negative index failed to generate exception");
+		} catch (IndexOutOfBoundsException e) {
+			// Correct behaviour
+		}
+
+		// Try setting a bit on a 64 boundary
+		bs.set(128);
+		assertTrue("Failed to grow BitSet", bs.size() == 192);
+		assertTrue("Failed to set bit", bs.get(128));
+
+		bs = new BitSet(64);
+		for (int i = bs.size(); --i >= 0;) {
+			bs.set(i);
+			assertTrue("Incorrectly set", bs.get(i));
+			assertTrue("Incorrect length", bs.length() == (i + 1));
+			for (int j = bs.size(); --j > i;)
+				assertTrue("Incorrectly set bit " + j, !bs.get(j));
+			for (int j = i; --j >= 0;)
+				assertTrue("Incorrectly set bit " + j, !bs.get(j));
+			bs.clear(i);
+		}
+
+		bs = new BitSet(0);
+		assertTrue("Test1: Wrong length, " + bs.size(), bs.length() == 0);
+		bs.set(0);
+		assertTrue("Test2: Wrong length" + bs.size(), bs.length() == 1);
+	}
+
+	/**
+	 * @tests java.util.BitSet#set(int, boolean)
+	 */
+	public void test_setIZ() {
+		// Test for method void java.util.BitSet.set(int, boolean)
+		eightbs.set(5, false);
+		assertTrue("Should have set bit 5 to true", !eightbs.get(5));
+
+		eightbs.set(5, true);
+		assertTrue("Should have set bit 5 to false", eightbs.get(5));
+	}
+
+	/**
+	 * @tests java.util.BitSet#set(int, int)
+	 */
+	public void test_setII() {
+		// Test for method void java.util.BitSet.set(int, int)
+		// pos1 and pos2 are in the same bitset element
+		BitSet bs = new BitSet(16);
+		bs.set(5);
+		bs.set(15);
+		bs.set(7, 11);
+		for (int i = 0; i < 7; i++) {
+			if (i == 5)
+				assertTrue("Shouldn't have flipped bit " + i, bs.get(i));
+			else
+				assertTrue("Shouldn't have set bit " + i, !bs.get(i));
+		}
+		for (int i = 7; i < 11; i++)
+			assertTrue("Failed to set bit " + i, bs.get(i));
+		for (int i = 11; i < bs.size(); i++) {
+			if (i == 15)
+				assertTrue("Shouldn't have flipped bit " + i, bs.get(i));
+			else
+				assertTrue("Shouldn't have set bit " + i, !bs.get(i));
+		}
+
+		// pos1 and pos2 is in the same bitset element, boundary testing
+		bs = new BitSet(16);
+		bs.set(7, 64);
+		assertTrue("Failed to grow BitSet", bs.size() == 128);
+		for (int i = 0; i < 7; i++)
+			assertTrue("Shouldn't have set bit " + i, !bs.get(i));
+		for (int i = 7; i < 64; i++)
+			assertTrue("Failed to set bit " + i, bs.get(i));
+		assertTrue("Shouldn't have set bit 64", !bs.get(64));
+
+		// more boundary testing
+		bs = new BitSet(32);
+		bs.set(0, 64);
+		for (int i = 0; i < 64; i++)
+			assertTrue("Failed to set bit " + i, bs.get(i));
+		assertTrue("Shouldn't have set bit 64", !bs.get(64));
+
+		bs = new BitSet(32);
+		bs.set(0, 65);
+		for (int i = 0; i < 65; i++)
+			assertTrue("Failed to set bit " + i, bs.get(i));
+		assertTrue("Shouldn't have set bit 65", !bs.get(65));
+
+		// pos1 and pos2 are in two sequential bitset elements
+		bs = new BitSet(128);
+		bs.set(7);
+		bs.set(110);
+		bs.set(9, 74);
+		for (int i = 0; i < 9; i++) {
+			if (i == 7)
+				assertTrue("Shouldn't have flipped bit " + i, bs.get(i));
+			else
+				assertTrue("Shouldn't have set bit " + i, !bs.get(i));
+		}
+		for (int i = 9; i < 74; i++)
+			assertTrue("Failed to set bit " + i, bs.get(i));
+		for (int i = 74; i < bs.size(); i++) {
+			if (i == 110)
+				assertTrue("Shouldn't have flipped bit " + i, bs.get(i));
+			else
+				assertTrue("Shouldn't have set bit " + i, !bs.get(i));
+		}
+
+		// pos1 and pos2 are in two non-sequential bitset elements
+		bs = new BitSet(256);
+		bs.set(7);
+		bs.set(255);
+		bs.set(9, 219);
+		for (int i = 0; i < 9; i++) {
+			if (i == 7)
+				assertTrue("Shouldn't have set flipped " + i, bs.get(i));
+			else
+				assertTrue("Shouldn't have set bit " + i, !bs.get(i));
+		}
+
+		for (int i = 9; i < 219; i++)
+			assertTrue("failed to set bit " + i, bs.get(i));
+
+		for (int i = 219; i < 255; i++)
+			assertTrue("Shouldn't have set bit " + i, !bs.get(i));
+
+		assertTrue("Shouldn't have flipped bit 255", bs.get(255));
+
+		// test illegal args
+		bs = new BitSet(10);
+		try {
+			bs.set(-1, 3);
+			fail(
+					"Test1: Attempt to flip with  negative index failed to generate exception");
+		} catch (IndexOutOfBoundsException e) {
+		}
+
+		try {
+			bs.set(2, -1);
+			fail(
+					"Test2: Attempt to flip with negative index failed to generate exception");
+		} catch (IndexOutOfBoundsException e) {
+		}
+
+		try {
+			bs.set(4, 2);
+			fail(
+					"Test4: Attempt to flip with illegal args failed to generate exception");
+		} catch (IndexOutOfBoundsException e) {
+		}
+	}
+
+	/**
+	 * @tests java.util.BitSet#set(int, int, boolean)
+	 */
+	public void test_setIIZ() {
+		// Test for method void java.util.BitSet.set(int, int, boolean)
+		eightbs.set(3, 6, false);
+		assertTrue("Should have set bits 3, 4, and 5 to false", !eightbs.get(3)
+				&& !eightbs.get(4) && !eightbs.get(5));
+
+		eightbs.set(3, 6, true);
+		assertTrue("Should have set bits 3, 4, and 5 to true", eightbs.get(3)
+				&& eightbs.get(4) && eightbs.get(5));
+
+	}
+
+	/**
+	 * @tests java.util.BitSet#flip(int)
+	 */
+	public void test_flipI() {
+		// Test for method void java.util.BitSet.flip(int)
+		BitSet bs = new BitSet();
+		bs.clear(8);
+		bs.clear(9);
+		bs.set(10);
+		bs.flip(9);
+		assertTrue("Failed to flip bit", !bs.get(8));
+		assertTrue("Failed to flip bit", bs.get(9));
+		assertTrue("Failed to flip bit", bs.get(10));
+
+		bs.set(8);
+		bs.set(9);
+		bs.clear(10);
+		bs.flip(9);
+		assertTrue("Failed to flip bit", bs.get(8));
+		assertTrue("Failed to flip bit", !bs.get(9));
+		assertTrue("Failed to flip bit", !bs.get(10));
+
+		try {
+			bs.flip(-1);
+			fail(
+					"Attempt to flip at negative index failed to generate exception");
+		} catch (IndexOutOfBoundsException e) {
+			// Correct behaviour
+		}
+
+		// Try setting a bit on a 64 boundary
+		bs.flip(128);
+		assertTrue("Failed to grow BitSet", bs.size() == 192);
+		assertTrue("Failed to flip bit", bs.get(128));
+
+		bs = new BitSet(64);
+		for (int i = bs.size(); --i >= 0;) {
+			bs.flip(i);
+			assertTrue("Test1: Incorrectly flipped bit" + i, bs.get(i));
+			assertTrue("Incorrect length", bs.length() == (i + 1));
+			for (int j = bs.size(); --j > i;)
+				assertTrue("Test2: Incorrectly flipped bit" + j, !bs.get(j));
+			for (int j = i; --j >= 0;)
+				assertTrue("Test3: Incorrectly flipped bit" + j, !bs.get(j));
+			bs.flip(i);
+		}
+
+		BitSet bs0 = new BitSet(0);
+		assertTrue("Test1: Wrong size", bs0.size() == 0);
+		assertTrue("Test1: Wrong length", bs0.length() == 0);
+
+		bs0.flip(0);
+		assertTrue("Test2: Wrong size", bs0.size() == 64);
+		assertTrue("Test2: Wrong length", bs0.length() == 1);
+
+		bs0.flip(63);
+		assertTrue("Test3: Wrong size", bs0.size() == 64);
+		assertTrue("Test3: Wrong length", bs0.length() == 64);
+
+		eightbs.flip(7);
+		assertTrue("Failed to flip bit 7", !eightbs.get(7));
+
+		// Check to see all other bits are still set
+		for (int i = 0; i < 7; i++)
+			assertTrue("Flip flipped incorrect bits", eightbs.get(i));
+
+		eightbs.flip(127);
+		assertTrue("Failed to flip bit 127", eightbs.get(127));
+
+		eightbs.flip(127);
+		assertTrue("Failed to flip bit 127", !eightbs.get(127));
+	}
+
+	/**
+	 * @tests java.util.BitSet#flip(int, int)
+	 */
+	public void test_flipII() {
+		// Test for method void java.util.BitSet.flip(int, int)
+		// pos1 and pos2 are in the same bitset element
+		BitSet bs = new BitSet(16);
+		bs.set(7);
+		bs.set(10);
+		bs.flip(7, 11);
+		for (int i = 0; i < 7; i++)
+			assertTrue("Shouldn't have flipped bit " + i, !bs.get(i));
+		assertTrue("Failed to flip bit 7", !bs.get(7));
+		assertTrue("Failed to flip bit 8", bs.get(8));
+		assertTrue("Failed to flip bit 9", bs.get(9));
+		assertTrue("Failed to flip bit 10", !bs.get(10));
+		for (int i = 11; i < bs.size(); i++)
+			assertTrue("Shouldn't have flipped bit " + i, !bs.get(i));
+
+		// pos1 and pos2 is in the same bitset element, boundary testing
+		bs = new BitSet(16);
+		bs.set(7);
+		bs.set(10);
+		bs.flip(7, 64);
+		assertTrue("Failed to grow BitSet", bs.size() == 128);
+		for (int i = 0; i < 7; i++)
+			assertTrue("Shouldn't have flipped bit " + i, !bs.get(i));
+		assertTrue("Failed to flip bit 7", !bs.get(7));
+		assertTrue("Failed to flip bit 8", bs.get(8));
+		assertTrue("Failed to flip bit 9", bs.get(9));
+		assertTrue("Failed to flip bit 10", !bs.get(10));
+		for (int i = 11; i < 64; i++)
+			assertTrue("failed to flip bit " + i, bs.get(i));
+		assertTrue("Shouldn't have flipped bit 64", !bs.get(64));
+
+		// more boundary testing
+		bs = new BitSet(32);
+		bs.flip(0, 64);
+		for (int i = 0; i < 64; i++)
+			assertTrue("Failed to flip bit " + i, bs.get(i));
+		assertTrue("Shouldn't have flipped bit 64", !bs.get(64));
+
+		bs = new BitSet(32);
+		bs.flip(0, 65);
+		for (int i = 0; i < 65; i++)
+			assertTrue("Failed to flip bit " + i, bs.get(i));
+		assertTrue("Shouldn't have flipped bit 65", !bs.get(65));
+
+		// pos1 and pos2 are in two sequential bitset elements
+		bs = new BitSet(128);
+		bs.set(7);
+		bs.set(10);
+		bs.set(72);
+		bs.set(110);
+		bs.flip(9, 74);
+		for (int i = 0; i < 7; i++)
+			assertTrue("Shouldn't have flipped bit " + i, !bs.get(i));
+		assertTrue("Shouldn't have flipped bit 7", bs.get(7));
+		assertTrue("Shouldn't have flipped bit 8", !bs.get(8));
+		assertTrue("Failed to flip bit 9", bs.get(9));
+		assertTrue("Failed to flip bit 10", !bs.get(10));
+		for (int i = 11; i < 72; i++)
+			assertTrue("failed to flip bit " + i, bs.get(i));
+		assertTrue("Failed to flip bit 72", !bs.get(72));
+		assertTrue("Failed to flip bit 73", bs.get(73));
+		for (int i = 74; i < 110; i++)
+			assertTrue("Shouldn't have flipped bit " + i, !bs.get(i));
+		assertTrue("Shouldn't have flipped bit 110", bs.get(110));
+		for (int i = 111; i < bs.size(); i++)
+			assertTrue("Shouldn't have flipped bit " + i, !bs.get(i));
+
+		// pos1 and pos2 are in two non-sequential bitset elements
+		bs = new BitSet(256);
+		bs.set(7);
+		bs.set(10);
+		bs.set(72);
+		bs.set(110);
+		bs.set(181);
+		bs.set(220);
+		bs.flip(9, 219);
+		for (int i = 0; i < 7; i++)
+			assertTrue("Shouldn't have flipped bit " + i, !bs.get(i));
+		assertTrue("Shouldn't have flipped bit 7", bs.get(7));
+		assertTrue("Shouldn't have flipped bit 8", !bs.get(8));
+		assertTrue("Failed to flip bit 9", bs.get(9));
+		assertTrue("Failed to flip bit 10", !bs.get(10));
+		for (int i = 11; i < 72; i++)
+			assertTrue("failed to flip bit " + i, bs.get(i));
+		assertTrue("Failed to flip bit 72", !bs.get(72));
+		for (int i = 73; i < 110; i++)
+			assertTrue("failed to flip bit " + i, bs.get(i));
+		assertTrue("Failed to flip bit 110", !bs.get(110));
+		for (int i = 111; i < 181; i++)
+			assertTrue("failed to flip bit " + i, bs.get(i));
+		assertTrue("Failed to flip bit 181", !bs.get(181));
+		for (int i = 182; i < 219; i++)
+			assertTrue("failed to flip bit " + i, bs.get(i));
+		assertTrue("Shouldn't have flipped bit 219", !bs.get(219));
+		assertTrue("Shouldn't have flipped bit 220", bs.get(220));
+		for (int i = 221; i < bs.size(); i++)
+			assertTrue("Shouldn't have flipped bit " + i, !bs.get(i));
+
+		// test illegal args
+		bs = new BitSet(10);
+		try {
+			bs.flip(-1, 3);
+			fail(
+					"Test1: Attempt to flip with  negative index failed to generate exception");
+		} catch (IndexOutOfBoundsException e) {
+		}
+
+		try {
+			bs.flip(2, -1);
+			fail(
+					"Test2: Attempt to flip with negative index failed to generate exception");
+		} catch (IndexOutOfBoundsException e) {
+		}
+
+		try {
+			bs.flip(4, 2);
+			fail(
+					"Test4: Attempt to flip with illegal args failed to generate exception");
+		} catch (IndexOutOfBoundsException e) {
+		}
+	}
+
+	/**
+	 * @tests java.util.BitSet#set(int, int)
+	 * @tests java.util.BitSet#cardinality()
+	 * @tests java.util.BitSet#get(int)
+	 * @tests java.util.BitSet#flip(int, int)
+	 * @tests java.util.BitSet#clear(int,int)
+	 */
+
+	public void test_111478() {
+		// BitSet shouldn't be modified by any of the operations below,
+		// since the affected bits for these methods are defined as inclusive of
+		// pos1, exclusive of pos2.
+		try {
+			eightbs.flip(0, 0);
+			assertTrue("Bit got flipped incorrectly ", eightbs.get(0));
+
+			BitSet bsnew = eightbs.get(2, 2);
+			assertTrue("BitSet retrieved incorrectly ",
+					bsnew.cardinality() == 0);
+
+			eightbs.set(10, 10);
+			assertTrue("Bit got set incorrectly ", !eightbs.get(10));
+
+			eightbs.clear(3, 3);
+			assertTrue("Bit cleared incorrectly ", eightbs.get(3));
+		} catch (IndexOutOfBoundsException e) {
+			fail("Unexpected IndexOutOfBoundsException when pos1 ==pos2");
+		}
+	}
+
+	/**
+	 * @tests java.util.BitSet#intersects(java.util.BitSet)
+	 */
+	public void test_intersectsLjava_util_BitSet() {
+		// Test for method boolean java.util.BitSet.intersects(java.util.BitSet)
+		BitSet bs = new BitSet(500);
+		bs.set(5);
+		bs.set(63);
+		bs.set(64);
+		bs.set(71, 110);
+		bs.set(127, 130);
+		bs.set(192);
+		bs.set(450);
+
+		BitSet bs2 = new BitSet(8);
+		assertEquals("Test1: intersects() returned incorrect value", false, bs
+				.intersects(bs2));
+		assertEquals("Test1: intersects() returned incorrect value", false, bs2
+				.intersects(bs));
+
+		bs2.set(4);
+		assertEquals("Test2: intersects() returned incorrect value", false, bs
+				.intersects(bs2));
+		assertEquals("Test2: intersects() returned incorrect value", false, bs2
+				.intersects(bs));
+
+		bs2.clear();
+		bs2.set(5);
+		assertEquals("Test3: intersects() returned incorrect value", true, bs
+				.intersects(bs2));
+		assertEquals("Test3: intersects() returned incorrect value", true, bs2
+				.intersects(bs));
+
+		bs2.clear();
+		bs2.set(63);
+		assertEquals("Test4: intersects() returned incorrect value", true, bs
+				.intersects(bs2));
+		assertEquals("Test4: intersects() returned incorrect value", true, bs2
+				.intersects(bs));
+
+		bs2.clear();
+		bs2.set(80);
+		assertEquals("Test5: intersects() returned incorrect value", true, bs
+				.intersects(bs2));
+		assertEquals("Test5: intersects() returned incorrect value", true, bs2
+				.intersects(bs));
+
+		bs2.clear();
+		bs2.set(127);
+		assertEquals("Test6: intersects() returned incorrect value", true, bs
+				.intersects(bs2));
+		assertEquals("Test6: intersects() returned incorrect value", true, bs2
+				.intersects(bs));
+
+		bs2.clear();
+		bs2.set(192);
+		assertEquals("Test7: intersects() returned incorrect value", true, bs
+				.intersects(bs2));
+		assertEquals("Test7: intersects() returned incorrect value", true, bs2
+				.intersects(bs));
+
+		bs2.clear();
+		bs2.set(450);
+		assertEquals("Test8: intersects() returned incorrect value", true, bs
+				.intersects(bs2));
+		assertEquals("Test8: intersects() returned incorrect value", true, bs2
+				.intersects(bs));
+
+		bs2.clear();
+		bs2.set(500);
+		assertEquals("Test9: intersects() returned incorrect value", false, bs
+				.intersects(bs2));
+		assertEquals("Test9: intersects() returned incorrect value", false, bs2
+				.intersects(bs));
+	}
+
+	/**
+	 * @tests java.util.BitSet#and(java.util.BitSet)
+	 */
+	public void test_andLjava_util_BitSet() {
+		// Test for method void java.util.BitSet.and(java.util.BitSet)
+		BitSet bs = new BitSet(128);
+		// Initialize the bottom half of the BitSet
+
+		for (int i = 64; i < 128; i++)
+			bs.set(i);
+		eightbs.and(bs);
+		assertTrue("AND failed to clear bits", !eightbs.equals(bs));
+		eightbs.set(3);
+		bs.set(3);
+		eightbs.and(bs);
+		assertTrue("AND failed to maintain set bits", bs.get(3));
+		bs.and(eightbs);
+		for (int i = 64; i < 128; i++)
+			assertTrue("Failed to clear extra bits in the receiver BitSet", !bs
+					.get(i));
+	}
+
+	/**
+	 * @tests java.util.BitSet#andNot(java.util.BitSet)
+	 */
+	public void test_andNotLjava_util_BitSet() {
+		BitSet bs = (BitSet) eightbs.clone();
+		bs.clear(5);
+		BitSet bs2 = new BitSet();
+		bs2.set(2);
+		bs2.set(3);
+		bs.andNot(bs2);
+		assertTrue("Incorrect bitset after andNot", bs.toString().equals(
+				"{0, 1, 4, 6, 7}"));
+
+		bs = new BitSet(0);
+		bs.andNot(bs2);
+		assertTrue("Incorrect size", bs.size() == 0);
+	}
+
+	/**
+	 * @tests java.util.BitSet#or(java.util.BitSet)
+	 */
+	public void test_orLjava_util_BitSet() {
+		// Test for method void java.util.BitSet.or(java.util.BitSet)
+		BitSet bs = new BitSet(128);
+		bs.or(eightbs);
+		for (int i = 0; i < 8; i++)
+			assertTrue("OR failed to set bits", bs.get(i));
+
+		bs = new BitSet(0);
+		bs.or(eightbs);
+		for (int i = 0; i < 8; i++)
+			assertTrue("OR(0) failed to set bits", bs.get(i));
+
+		eightbs.clear(5);
+		bs = new BitSet(128);
+		bs.or(eightbs);
+		assertTrue("OR set a bit which should be off", !bs.get(5));
+	}
+
+	/**
+	 * @tests java.util.BitSet#xor(java.util.BitSet)
+	 */
+	public void test_xorLjava_util_BitSet() {
+		// Test for method void java.util.BitSet.xor(java.util.BitSet)
+
+		BitSet bs = (BitSet) eightbs.clone();
+		bs.xor(eightbs);
+		for (int i = 0; i < 8; i++)
+			assertTrue("XOR failed to clear bits", !bs.get(i));
+
+		bs.xor(eightbs);
+		for (int i = 0; i < 8; i++)
+			assertTrue("XOR failed to set bits", bs.get(i));
+
+		bs = new BitSet(0);
+		bs.xor(eightbs);
+		for (int i = 0; i < 8; i++)
+			assertTrue("XOR(0) failed to set bits", bs.get(i));
+
+		bs = new BitSet();
+		bs.set(63);
+		assertTrue("Test highest bit", bs.toString().equals("{63}"));
+	}
+
+	/**
+	 * @tests java.util.BitSet#size()
+	 */
+	public void test_size() {
+		// Test for method int java.util.BitSet.size()
+		assertTrue("Returned incorrect size", eightbs.size() == 64);
+		eightbs.set(129);
+		assertTrue("Returned incorrect size", eightbs.size() >= 129);
+
+	}
+
+	/**
+	 * @tests java.util.BitSet#toString()
+	 */
+	public void test_toString() {
+		// Test for method java.lang.String java.util.BitSet.toString()
+		assertTrue("Returned incorrect string representation", eightbs
+				.toString().equals("{0, 1, 2, 3, 4, 5, 6, 7}"));
+		eightbs.clear(2);
+		assertTrue("Returned incorrect string representation", eightbs
+				.toString().equals("{0, 1, 3, 4, 5, 6, 7}"));
+	}
+
+	/**
+	 * @tests java.util.BitSet#length()
+	 */
+	public void test_length() {
+		BitSet bs = new BitSet();
+		assertTrue("BitSet returned wrong length--wanted 0, got: "
+				+ bs.length(), bs.length() == 0);
+		bs.set(5);
+		assertTrue("BitSet returned wrong length--wanted 6, got: "
+				+ bs.length(), bs.length() == 6);
+		bs.set(10);
+		assertTrue("BitSet returned wrong length--wanted 11, got: "
+				+ bs.length(), bs.length() == 11);
+		bs.set(432);
+		assertTrue("BitSet returned wrong length--wanted 433, got: "
+				+ bs.length(), bs.length() == 433);
+		bs.set(300);
+		assertTrue("BitSet returned wrong length--wanted 433 (again), got: "
+				+ bs.length(), bs.length() == 433);
+	}
+
+	/**
+	 * @tests java.util.BitSet#nextSetBit(int)
+	 */
+	public void test_nextSetBitI() {
+		// Test for method int java.util.BitSet.nextSetBit()
+		BitSet bs = new BitSet(500);
+		bs.set(5);
+		bs.set(32);
+		bs.set(63);
+		bs.set(64);
+		bs.set(71, 110);
+		bs.set(127, 130);
+		bs.set(193);
+		bs.set(450);
+		try {
+			bs.nextSetBit(-1);
+			fail("Expected IndexOutOfBoundsException for negative index");
+		} catch (IndexOutOfBoundsException e) {
+		}
+		assertEquals("nextSetBit() returned the wrong value", 5, bs
+				.nextSetBit(0));
+		assertEquals("nextSetBit() returned the wrong value", 5, bs
+				.nextSetBit(5));
+		assertEquals("nextSetBit() returned the wrong value", 32, bs
+				.nextSetBit(6));
+		assertEquals("nextSetBit() returned the wrong value", 32, bs
+				.nextSetBit(32));
+		assertEquals("nextSetBit() returned the wrong value", 63, bs
+				.nextSetBit(33));
+
+		// boundary tests
+		assertEquals("nextSetBit() returned the wrong value", 63, bs
+				.nextSetBit(63));
+		assertEquals("nextSetBit() returned the wrong value", 64, bs
+				.nextSetBit(64));
+
+		// at bitset element 1
+		assertEquals("nextSetBit() returned the wrong value", 71, bs
+				.nextSetBit(65));
+		assertEquals("nextSetBit() returned the wrong value", 71, bs
+				.nextSetBit(71));
+		assertEquals("nextSetBit() returned the wrong value", 72, bs
+				.nextSetBit(72));
+		assertEquals("nextSetBit() returned the wrong value", 127, bs
+				.nextSetBit(110));
+
+		// boundary tests
+		assertEquals("nextSetBit() returned the wrong value", 127, bs
+				.nextSetBit(127));
+		assertEquals("nextSetBit() returned the wrong value", 128, bs
+				.nextSetBit(128));
+
+		// at bitset element 2
+		assertEquals("nextSetBit() returned the wrong value", 193, bs
+				.nextSetBit(130));
+
+		assertEquals("nextSetBit() returned the wrong value", 193, bs
+				.nextSetBit(191));
+		assertEquals("nextSetBit() returned the wrong value", 193, bs
+				.nextSetBit(192));
+		assertEquals("nextSetBit() returned the wrong value", 193, bs
+				.nextSetBit(193));
+		assertEquals("nextSetBit() returned the wrong value", 450, bs
+				.nextSetBit(194));
+		assertEquals("nextSetBit() returned the wrong value", 450, bs
+				.nextSetBit(255));
+		assertEquals("nextSetBit() returned the wrong value", 450, bs
+				.nextSetBit(256));
+		assertEquals("nextSetBit() returned the wrong value", 450, bs
+				.nextSetBit(450));
+
+		assertEquals("nextSetBit() returned the wrong value", -1, bs
+				.nextSetBit(451));
+		assertEquals("nextSetBit() returned the wrong value", -1, bs
+				.nextSetBit(511));
+		assertEquals("nextSetBit() returned the wrong value", -1, bs
+				.nextSetBit(512));
+		assertEquals("nextSetBit() returned the wrong value", -1, bs
+				.nextSetBit(800));
+	}
+
+	/**
+	 * @tests java.util.BitSet#nextClearBit(int)
+	 */
+	public void test_nextClearBitI() {
+		// Test for method int java.util.BitSet.nextSetBit()
+		BitSet bs = new BitSet(500);
+		// ensure all the bits from 0 to bs.size() - 1 are set to true
+		bs.set(0, bs.size() - 1); 
+		bs.set(bs.size() - 1);
+		bs.clear(5);
+		bs.clear(32);
+		bs.clear(63);
+		bs.clear(64);
+		bs.clear(71, 110);
+		bs.clear(127, 130);
+		bs.clear(193);
+		bs.clear(450);
+		try {
+			bs.nextClearBit(-1);
+			fail("Expected IndexOutOfBoundsException for negative index");
+		} catch (IndexOutOfBoundsException e) {
+		}
+		assertEquals("nextClearBit() returned the wrong value", 5, bs
+				.nextClearBit(0));
+		assertEquals("nextClearBit() returned the wrong value", 5, bs
+				.nextClearBit(5));
+		assertEquals("nextClearBit() returned the wrong value", 32, bs
+				.nextClearBit(6));
+		assertEquals("nextClearBit() returned the wrong value", 32, bs
+				.nextClearBit(32));
+		assertEquals("nextClearBit() returned the wrong value", 63, bs
+				.nextClearBit(33));
+
+		// boundary tests
+		assertEquals("nextClearBit() returned the wrong value", 63, bs
+				.nextClearBit(63));
+		assertEquals("nextClearBit() returned the wrong value", 64, bs
+				.nextClearBit(64));
+
+		// at bitset element 1
+		assertEquals("nextClearBit() returned the wrong value", 71, bs
+				.nextClearBit(65));
+		assertEquals("nextClearBit() returned the wrong value", 71, bs
+				.nextClearBit(71));
+		assertEquals("nextClearBit() returned the wrong value", 72, bs
+				.nextClearBit(72));
+		assertEquals("nextClearBit() returned the wrong value", 127, bs
+				.nextClearBit(110));
+
+		// boundary tests
+		assertEquals("nextClearBit() returned the wrong value", 127, bs
+				.nextClearBit(127));
+		assertEquals("nextClearBit() returned the wrong value", 128, bs
+				.nextClearBit(128));
+
+		// at bitset element 2
+		assertEquals("nextClearBit() returned the wrong value", 193, bs
+				.nextClearBit(130));
+		assertEquals("nextClearBit() returned the wrong value", 193, bs
+				.nextClearBit(191));
+
+		assertEquals("nextClearBit() returned the wrong value", 193, bs
+				.nextClearBit(192));
+		assertEquals("nextClearBit() returned the wrong value", 193, bs
+				.nextClearBit(193));
+		assertEquals("nextClearBit() returned the wrong value", 450, bs
+				.nextClearBit(194));
+		assertEquals("nextClearBit() returned the wrong value", 450, bs
+				.nextClearBit(255));
+		assertEquals("nextClearBit() returned the wrong value", 450, bs
+				.nextClearBit(256));
+		assertEquals("nextClearBit() returned the wrong value", 450, bs
+				.nextClearBit(450));
+
+		// bitset has 1 still the end of bs.size() -1, but calling nextClearBit
+		// with any index value after the last true bit should return bs.size()
+		assertEquals("nextClearBit() returned the wrong value", 512, bs
+				.nextClearBit(451));
+		assertEquals("nextClearBit() returned the wrong value", 512, bs
+				.nextClearBit(511));
+		assertEquals("nextClearBit() returned the wrong value", 512, bs
+				.nextClearBit(512));
+
+		// if the index is larger than bs.size(), nextClearBit should return
+		// index
+		assertEquals("nextClearBit() returned the wrong value", 513, bs
+				.nextClearBit(513));
+		assertEquals("nextClearBit() returned the wrong value", 800, bs
+				.nextClearBit(800));
+	}
+
+	/**
+	 * @tests java.util.BitSet#isEmpty()
+	 */
+	public void test_isEmpty() {
+		BitSet bs = new BitSet(500);
+		assertEquals("Test: isEmpty() returned wrong value", true, bs.isEmpty());
+
+		// at bitset element 0
+		bs.set(3);
+		assertEquals("Test0: isEmpty() returned wrong value", false, bs
+				.isEmpty());
+
+		// at bitset element 1
+		bs.clear();
+		bs.set(12);
+		assertEquals("Test1: isEmpty() returned wrong value", false, bs
+				.isEmpty());
+
+		// at bitset element 2
+		bs.clear();
+		bs.set(128);
+		assertEquals("Test2: isEmpty() returned wrong value", false, bs
+				.isEmpty());
+
+		// boundary testing
+		bs.clear();
+		bs.set(459);
+		assertEquals("Test3: isEmpty() returned wrong value", false, bs
+				.isEmpty());
+
+		bs.clear();
+		bs.set(511);
+		assertEquals("Test4: isEmpty() returned wrong value", false, bs
+				.isEmpty());
+	}
+
+	/**
+	 * @tests java.util.BitSet#cardinality()
+	 */
+	public void test_cardinality() {
+		// test for method int java.util.BitSet.cardinality()
+		BitSet bs = new BitSet(500);
+		bs.set(5);
+		bs.set(32);
+		bs.set(63);
+		bs.set(64);
+		bs.set(71, 110);
+		bs.set(127, 130);
+		bs.set(193);
+		bs.set(450);
+		assertEquals("cardinality() returned wrong value", 48, bs.cardinality());
+
+		bs.flip(0, 500);
+		assertEquals("cardinality() returned wrong value", 452, bs
+				.cardinality());
+
+		bs.clear();
+		assertEquals("cardinality() returned wrong value", 0, bs.cardinality());
+
+		bs.set(0, 500);
+		assertEquals("cardinality() returned wrong value", 500, bs
+				.cardinality());
+	}
+
+	/**
+	 * helper method to display the contents of a bitset
+	 * 
+	 */
+	private static void printBitset(BitSet bs) {
+		System.out.println();
+		for (int i = bs.size() - 1; i >= 0; i--) {
+			if (bs.get(i))
+				System.out.print(1);
+			else
+				System.out.print(0);
+		}
+	}
+
+	/**
+	 * Sets up the fixture, for example, open a network connection. This method
+	 * is called before a test is executed.
+	 */
+	protected void setUp() {
+
+		eightbs = new BitSet();
+
+		for (int i = 0; i < 8; i++)
+			eightbs.set(i);
+	}
+
+	/**
+	 * Tears down the fixture, for example, close a network connection. This
+	 * method is called after a test is executed.
+	 */
+	protected void tearDown() {
+	}
+}



Mime
View raw message