harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smish...@apache.org
Subject svn commit: r396807 - in /incubator/harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/util/Arrays.java test/java/tests/api/java/util/ArraysTest.java
Date Tue, 25 Apr 2006 08:05:45 GMT
Author: smishura
Date: Tue Apr 25 01:05:41 2006
New Revision: 396807

URL: http://svn.apache.org/viewcvs?rev=396807&view=rev
Log:
Apply patch for HARMONY-378 (java.util.Arrays.sort(null,(int)-1,(int)1) should throw NullPointerException)

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Arrays.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/ArraysTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Arrays.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Arrays.java?rev=396807&r1=396806&r2=396807&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Arrays.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Arrays.java
Tue Apr 25 01:05:41 2006
@@ -1085,6 +1085,9 @@
 	 *                <code>end > array.size()</code>
 	 */
 	public static void sort(byte[] array, int start, int end) {
+		if (array == null) {
+			throw new NullPointerException();
+		}
 		if (start >= 0 && end <= array.length) {
 			if (start <= end)
 				sort(start, end, array);
@@ -1195,6 +1198,9 @@
 	 *                <code>end > array.size()</code>
 	 */
 	public static void sort(char[] array, int start, int end) {
+		if (array == null) {
+			throw new NullPointerException();
+		}
 		if (start >= 0 && end <= array.length) {
 			if (start <= end)
 				sort(start, end, array);
@@ -1310,6 +1316,9 @@
 	 * @see Double#compareTo(Double)
 	 */
 	public static void sort(double[] array, int start, int end) {
+		if (array == null) {
+			throw new NullPointerException();
+		}
 		if (start >= 0 && end <= array.length) {
 			if (start <= end)
 				sort(start, end, array);
@@ -1425,6 +1434,9 @@
 	 * @see Float#compareTo(Float)
 	 */
 	public static void sort(float[] array, int start, int end) {
+		if (array == null) {
+			throw new NullPointerException();
+		}
 		if (start >= 0 && end <= array.length) {
 			if (start <= end)
 				sort(start, end, array);
@@ -1535,6 +1547,9 @@
 	 *                <code>end > array.size()</code>
 	 */
 	public static void sort(int[] array, int start, int end) {
+		if (array == null) {
+			throw new NullPointerException();
+		}
 		if (start >= 0 && end <= array.length) {
 			if (start <= end)
 				sort(start, end, array);
@@ -1645,6 +1660,9 @@
 	 *                <code>end > array.size()</code>
 	 */
 	public static void sort(long[] array, int start, int end) {
+		if (array == null) {
+			throw new NullPointerException();
+		}
 		if (start >= 0 && end <= array.length) {
 			if (start <= end)
 				sort(start, end, array);
@@ -1762,6 +1780,9 @@
 	 *                <code>end > array.size()</code>
 	 */
 	public static void sort(Object[] array, int start, int end) {
+		if (array == null) {
+			throw new NullPointerException();
+		}
 		if (start >= 0 && end <= array.length) {
 			if (start <= end)
 				sort(start, end, array);
@@ -1822,6 +1843,9 @@
 	 */
 	public static void sort(Object[] array, int start, int end,
 			Comparator comparator) {
+		if (array == null) {
+			throw new NullPointerException();
+		}
 		if (start >= 0 && end <= array.length) {
 			if (start <= end)
 				sort(start, end, array, comparator);
@@ -1903,6 +1927,9 @@
 	 *                <code>end > array.size()</code>
 	 */
 	public static void sort(short[] array, int start, int end) {
+		if (array == null) {
+			throw new NullPointerException();
+		}
 		if (start >= 0 && end <= array.length) {
 			if (start <= end)
 				sort(start, end, array);

Modified: 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=396807&r1=396806&r2=396807&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/ArraysTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/ArraysTest.java
Tue Apr 25 01:05:41 2006
@@ -1142,6 +1142,173 @@
 					reversedArray[counter] == originalReversedArray[counter]);
 	}
 
+    /**
+     * @tests java.util.Arrays#sort(byte[], int, int)
+     */
+    public void test_java_util_Arrays_sort_byte_array_NPE() {
+        byte[] byte_array_null = null;
+        try {
+            java.util.Arrays.sort(byte_array_null);
+            fail("Should throw java.lang.NullPointerException");
+        } catch (NullPointerException e) {
+            // Expected
+        }
+        try {
+            // Regression for HARMONY-378
+            java.util.Arrays.sort(byte_array_null, (int) -1, (int) 1);
+            fail("Should throw java.lang.NullPointerException");
+        } catch (NullPointerException e) {
+            // Expected
+        }
+    }
+
+    /**
+     * @tests java.util.Arrays#sort(char[], int, int)
+     */
+    public void test_java_util_Arrays_sort_char_array_NPE() {
+        char[] char_array_null = null;
+        try {
+            java.util.Arrays.sort(char_array_null);
+            fail("Should throw java.lang.NullPointerException");
+        } catch (NullPointerException e) {
+            // Expected
+        }
+        try {
+            // Regression for HARMONY-378
+            java.util.Arrays.sort(char_array_null, (int) -1, (int) 1);
+            fail("Should throw java.lang.NullPointerException");
+        } catch (NullPointerException e) {
+            // Expected
+        }
+    }
+
+    /**
+     * @tests java.util.Arrays#sort(double[], int, int)
+     */
+    public void test_java_util_Arrays_sort_double_array_NPE() {
+        double[] double_array_null = null;
+        try {
+            java.util.Arrays.sort(double_array_null);
+            fail("Should throw java.lang.NullPointerException");
+        } catch (NullPointerException e) {
+            // Expected
+        }
+        try {
+            // Regression for HARMONY-378
+            java.util.Arrays.sort(double_array_null, (int) -1, (int) 1);
+            fail("Should throw java.lang.NullPointerException");
+        } catch (NullPointerException e) {
+            // Expected
+        }
+    }
+
+    /**
+     * @tests java.util.Arrays#sort(float[], int, int)
+     */
+    public void test_java_util_Arrays_sort_float_array_NPE() {
+        float[] float_array_null = null;
+        try {
+            java.util.Arrays.sort(float_array_null);
+            fail("Should throw java.lang.NullPointerException");
+        } catch (NullPointerException e) {
+            // Expected
+        }
+        try {
+            // Regression for HARMONY-378
+            java.util.Arrays.sort(float_array_null, (int) -1, (int) 1);
+            fail("Should throw java.lang.NullPointerException");
+        } catch (NullPointerException e) {
+            // Expected
+        }
+    }
+
+    /**
+     * @tests java.util.Arrays#sort(int[], int, int)
+     */
+    public void test_java_util_Arrays_sort_int_array_NPE() {
+        int[] int_array_null = null;
+        try {
+            java.util.Arrays.sort(int_array_null);
+            fail("Should throw java.lang.NullPointerException");
+        } catch (NullPointerException e) {
+            // Expected
+        }
+        try {
+            // Regression for HARMONY-378
+            java.util.Arrays.sort(int_array_null, (int) -1, (int) 1);
+            fail("Should throw java.lang.NullPointerException");
+        } catch (NullPointerException e) {
+            // Expected
+        }
+    }
+
+    /**
+     * @tests java.util.Arrays#sort(Object[], int, int)
+     */
+    public void test_java_util_Arrays_sort_object_array_NPE() {
+        Object[] object_array_null = null;
+        try {
+            java.util.Arrays.sort(object_array_null);
+            fail("Should throw java.lang.NullPointerException");
+        } catch (NullPointerException e) {
+            // Expected
+        }
+        try {
+            // Regression for HARMONY-378
+            java.util.Arrays.sort(object_array_null, (int) -1, (int) 1);
+            fail("Should throw java.lang.NullPointerException");
+        } catch (NullPointerException e) {
+            // Expected
+        }
+        try {
+            // Regression for HARMONY-378
+            java.util.Arrays.sort(object_array_null, (int) -1, (int) 1, null);
+            fail("Should throw java.lang.NullPointerException");
+        } catch (NullPointerException e) {
+            // Expected
+        }
+    }
+
+    /**
+     * @tests java.util.Arrays#sort(long[], int, int)
+     */
+    public void test_java_util_Arrays_sort_long_array_NPE() {
+        long[] long_array_null = null;
+        try {
+            java.util.Arrays.sort(long_array_null);
+            fail("Should throw java.lang.NullPointerException");
+        } catch (NullPointerException e) {
+            // Expected
+        }
+        try {
+            // Regression for HARMONY-378
+            java.util.Arrays.sort(long_array_null, (int) -1, (int) 1);
+            fail("Should throw java.lang.NullPointerException");
+        } catch (NullPointerException e) {
+            // Expected
+        }
+    }
+
+    /**
+     * @tests java.util.Arrays#sort(short[], int, int)
+     */
+    public void test_java_util_Arrays_sort_short_array_NPE() {
+        short[] short_array_null = null;
+        try {
+            java.util.Arrays.sort(short_array_null);
+            fail("Should throw java.lang.NullPointerException");
+        } catch (NullPointerException e) {
+            // Expected
+        }
+        try {
+            // Regression for HARMONY-378
+            java.util.Arrays.sort(short_array_null, (int) -1, (int) 1);
+            fail("Should throw java.lang.NullPointerException");
+        } catch (NullPointerException e) {
+            // Expected
+        }
+    }
+
 	/**
 	 * Sets up the fixture, for example, open a network connection. This method
 	 * is called before a test is executed.



Mime
View raw message