Additional varargs tests
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1132845 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d3e471045c
commit
6887d0f09c
|
@ -966,8 +966,13 @@ public class ClassUtilsTest extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testToClass_object() {
|
public void testToClass_object() {
|
||||||
// assertNull(ClassUtils.toClass(null));
|
// assertNull(ClassUtils.toClass(null)); // generates warning
|
||||||
assertNull(ClassUtils.toClass((Object[]) null)); // explicit cast
|
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));
|
assertSame(ArrayUtils.EMPTY_CLASS_ARRAY, ClassUtils.toClass(ArrayUtils.EMPTY_OBJECT_ARRAY));
|
||||||
|
|
||||||
|
|
|
@ -732,9 +732,11 @@ public class StringUtilsEqualsIndexOfTest extends TestCase {
|
||||||
public void testLastIndexOfAny_StringStringArray() {
|
public void testLastIndexOfAny_StringStringArray() {
|
||||||
assertEquals(-1, StringUtils.lastIndexOfAny(null, (CharSequence) null)); // test both types of ...
|
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, (CharSequence[]) null)); // ... varargs invocation
|
||||||
|
assertEquals(-1, StringUtils.lastIndexOfAny(null)); // Missing varag
|
||||||
assertEquals(-1, StringUtils.lastIndexOfAny(null, FOOBAR_SUB_ARRAY));
|
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)); // test both types of ...
|
||||||
assertEquals(-1, StringUtils.lastIndexOfAny(FOOBAR, (CharSequence[]) null)); // ... varargs invocation
|
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(3, StringUtils.lastIndexOfAny(FOOBAR, FOOBAR_SUB_ARRAY));
|
||||||
assertEquals(-1, StringUtils.lastIndexOfAny(FOOBAR, new String[0]));
|
assertEquals(-1, StringUtils.lastIndexOfAny(FOOBAR, new String[0]));
|
||||||
assertEquals(-1, StringUtils.lastIndexOfAny(null, new String[0]));
|
assertEquals(-1, StringUtils.lastIndexOfAny(null, new String[0]));
|
||||||
|
|
|
@ -174,8 +174,12 @@ public class StringUtilsTest extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testJoin_Objectarray() {
|
public void testJoin_Objectarray() {
|
||||||
// assertEquals(null, StringUtils.join(null));
|
// assertEquals(null, StringUtils.join(null)); // generates warning
|
||||||
assertEquals(null, StringUtils.join((Object[]) null)); // explicit cast
|
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(EMPTY_ARRAY_LIST));
|
||||||
assertEquals("", StringUtils.join(NULL_ARRAY_LIST));
|
assertEquals("", StringUtils.join(NULL_ARRAY_LIST));
|
||||||
assertEquals("abc", StringUtils.join(new String[] {"a", "b", "c"}));
|
assertEquals("abc", StringUtils.join(new String[] {"a", "b", "c"}));
|
||||||
|
|
|
@ -230,8 +230,12 @@ public class StringUtilsTrimEmptyTest extends TestCase {
|
||||||
String[] fooDots = new String[] { ".."+FOO+"..", ".."+FOO, FOO+".." };
|
String[] fooDots = new String[] { ".."+FOO+"..", ".."+FOO, FOO+".." };
|
||||||
String[] foo = new String[] { FOO, FOO, FOO };
|
String[] foo = new String[] { FOO, FOO, FOO };
|
||||||
|
|
||||||
// assertEquals(null, StringUtils.stripAll(null));
|
// assertEquals(null, StringUtils.stripAll(null)); // generates warning
|
||||||
assertEquals(null, StringUtils.stripAll((String[]) null)); // explicit cast
|
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(empty, StringUtils.stripAll(empty));
|
||||||
assertArrayEquals(foo, StringUtils.stripAll(fooSpace));
|
assertArrayEquals(foo, StringUtils.stripAll(fooSpace));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue