commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1132837 - /commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/ClassUtilsTest.java
Date Tue, 07 Jun 2011 00:03:16 GMT
Author: sebb
Date: Tue Jun  7 00:03:16 2011
New Revision: 1132837

URL: http://svn.apache.org/viewvc?rev=1132837&view=rev
Log:
Additional null cast tests for varargs methods

Modified:
    commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/ClassUtilsTest.java

Modified: commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/ClassUtilsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/ClassUtilsTest.java?rev=1132837&r1=1132836&r2=1132837&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/ClassUtilsTest.java (original)
+++ commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/ClassUtilsTest.java Tue
Jun  7 00:03:16 2011
@@ -730,9 +730,14 @@ public class ClassUtilsTest extends Test
 
     public void testPrimitivesToWrappers() {
         // test null
-//        assertNull("null -> null", ClassUtils.primitivesToWrappers(null));
-        assertNull("null -> null", ClassUtils.primitivesToWrappers((Class<?>[])
null)); // explicit cast to avoid warning
-        // test empty array
+//        assertNull("null -> null", ClassUtils.primitivesToWrappers(null)); // generates
warning
+        assertNull("null -> null", ClassUtils.primitivesToWrappers((Class<?>[])
null)); // equivalent cast to avoid warning
+        // Other possible casts for null
+        assertTrue("empty -> empty", Arrays.equals(ArrayUtils.EMPTY_CLASS_ARRAY, ClassUtils.primitivesToWrappers()));
+        Class<?>[] castNull = ClassUtils.primitivesToWrappers((Class<?>)null);
// == new Class<?>[]{null}
+        assertTrue("(Class<?>)null -> [null]", Arrays.equals(new Class<?>[]{null},
castNull));
+        // test empty array is returned unchanged
+        // TODO this is not documented
         assertEquals("empty -> empty",
                 ArrayUtils.EMPTY_CLASS_ARRAY, ClassUtils.primitivesToWrappers(ArrayUtils.EMPTY_CLASS_ARRAY));
 
@@ -801,9 +806,13 @@ public class ClassUtilsTest extends Test
     }
 
     public void testWrappersToPrimitivesNull() {
-//        assertNull("Wrong result for null input", ClassUtils.wrappersToPrimitives(null));
-        assertNull("Wrong result for null input", ClassUtils.wrappersToPrimitives((Class<?>[])
null)); // explicit cast
-    }
+//        assertNull("Wrong result for null input", ClassUtils.wrappersToPrimitives(null));
// generates warning
+        assertNull("Wrong result for null input", ClassUtils.wrappersToPrimitives((Class<?>[])
null)); // equivalent cast
+        // Other possible casts for null
+        assertTrue("empty -> empty", Arrays.equals(ArrayUtils.EMPTY_CLASS_ARRAY, ClassUtils.wrappersToPrimitives()));
+        Class<?>[] castNull = ClassUtils.wrappersToPrimitives((Class<?>)null);
// == new Class<?>[]{null}
+        assertTrue("(Class<?>)null -> [null]", Arrays.equals(new Class<?>[]{null},
castNull));
+}
 
     public void testWrappersToPrimitivesEmpty() {
         Class<?>[] empty = new Class[0];



Mime
View raw message