commons-commits mailing list archives

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

URL: http://svn.apache.org/viewvc?rev=1132845&view=rev
Log:
Additional varargs tests

Modified:
    commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/ClassUtilsTest.java
    commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/StringUtilsEqualsIndexOfTest.java
    commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/StringUtilsTest.java
    commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/StringUtilsTrimEmptyTest.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=1132845&r1=1132844&r2=1132845&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:50:50 2011
@@ -966,8 +966,13 @@ public class ClassUtilsTest extends Test
     }
 
     public void testToClass_object() {
-//        assertNull(ClassUtils.toClass(null));
-        assertNull(ClassUtils.toClass((Object[]) null)); // explicit cast
+//        assertNull(ClassUtils.toClass(null)); // generates warning
+        assertNull(ClassUtils.toClass((Object[]) null)); // equivalent explicit cast
+        
+        // Additional varargs tests
+        assertTrue("empty -> empty", Arrays.equals(ArrayUtils.EMPTY_CLASS_ARRAY, ClassUtils.toClass()));
+        Class<?>[] castNull = ClassUtils.toClass((Object) null); // == new Object[]{null}
+        assertTrue("(Object)null -> [null]", Arrays.equals(new Object[]{null}, castNull));
 
         assertSame(ArrayUtils.EMPTY_CLASS_ARRAY, ClassUtils.toClass(ArrayUtils.EMPTY_OBJECT_ARRAY));
 

Modified: commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/StringUtilsEqualsIndexOfTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/StringUtilsEqualsIndexOfTest.java?rev=1132845&r1=1132844&r2=1132845&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/StringUtilsEqualsIndexOfTest.java
(original)
+++ commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/StringUtilsEqualsIndexOfTest.java
Tue Jun  7 00:50:50 2011
@@ -732,9 +732,11 @@ public class StringUtilsEqualsIndexOfTes
     public void testLastIndexOfAny_StringStringArray() {
         assertEquals(-1, StringUtils.lastIndexOfAny(null, (CharSequence) null));   // test
both types of ...
         assertEquals(-1, StringUtils.lastIndexOfAny(null, (CharSequence[]) null)); // ...
varargs invocation
+        assertEquals(-1, StringUtils.lastIndexOfAny(null)); // Missing varag
         assertEquals(-1, StringUtils.lastIndexOfAny(null, FOOBAR_SUB_ARRAY));
         assertEquals(-1, StringUtils.lastIndexOfAny(FOOBAR, (CharSequence) null));   // test
both types of ...
         assertEquals(-1, StringUtils.lastIndexOfAny(FOOBAR, (CharSequence[]) null)); // ...
varargs invocation
+        assertEquals(-1, StringUtils.lastIndexOfAny(FOOBAR)); // Missing vararg
         assertEquals(3, StringUtils.lastIndexOfAny(FOOBAR, FOOBAR_SUB_ARRAY));
         assertEquals(-1, StringUtils.lastIndexOfAny(FOOBAR, new String[0]));
         assertEquals(-1, StringUtils.lastIndexOfAny(null, new String[0]));

Modified: commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/StringUtilsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/StringUtilsTest.java?rev=1132845&r1=1132844&r2=1132845&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/StringUtilsTest.java
(original)
+++ commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/StringUtilsTest.java
Tue Jun  7 00:50:50 2011
@@ -174,8 +174,12 @@ public class StringUtilsTest extends Tes
     }
 
     public void testJoin_Objectarray() {
-//        assertEquals(null, StringUtils.join(null));
-        assertEquals(null, StringUtils.join((Object[]) null)); // explicit cast
+//        assertEquals(null, StringUtils.join(null)); // generates warning
+        assertEquals(null, StringUtils.join((Object[]) null)); // equivalent explicit cast
+        // test additional varargs calls
+        assertEquals("", StringUtils.join()); // empty array
+        assertEquals("", StringUtils.join((Object) null)); // => new Object[]{null}
+
         assertEquals("", StringUtils.join(EMPTY_ARRAY_LIST));
         assertEquals("", StringUtils.join(NULL_ARRAY_LIST));
         assertEquals("abc", StringUtils.join(new String[] {"a", "b", "c"}));

Modified: commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/StringUtilsTrimEmptyTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/StringUtilsTrimEmptyTest.java?rev=1132845&r1=1132844&r2=1132845&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/StringUtilsTrimEmptyTest.java
(original)
+++ commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/StringUtilsTrimEmptyTest.java
Tue Jun  7 00:50:50 2011
@@ -230,8 +230,12 @@ public class StringUtilsTrimEmptyTest ex
         String[] fooDots = new String[] { ".."+FOO+"..", ".."+FOO, FOO+".." };
         String[] foo = new String[] { FOO, FOO, FOO };
 
-//        assertEquals(null, StringUtils.stripAll(null));
-        assertEquals(null, StringUtils.stripAll((String[]) null)); // explicit cast
+//        assertEquals(null, StringUtils.stripAll(null)); // generates warning
+        assertEquals(null, StringUtils.stripAll((String[]) null)); // equivalent explicit
cast
+        // Additional varargs tests
+        assertArrayEquals(empty, StringUtils.stripAll()); // empty array
+        assertArrayEquals(new String[]{null}, StringUtils.stripAll((String) null)); // ==
new String[]{null}
+
         assertArrayEquals(empty, StringUtils.stripAll(empty));
         assertArrayEquals(foo, StringUtils.stripAll(fooSpace));
         



Mime
View raw message