Remove explicit (redundant) array creations for var args parameters

This commit is contained in:
Benedikt Ritter 2015-05-07 17:53:23 +02:00
parent 405bde36c4
commit ec4d8a9a6b
1 changed files with 24 additions and 24 deletions

View File

@ -117,18 +117,18 @@ public class StringUtilsEqualsIndexOfTest {
public void testContainsAny_StringCharArray() { public void testContainsAny_StringCharArray() {
assertFalse(StringUtils.containsAny(null, (char[]) null)); assertFalse(StringUtils.containsAny(null, (char[]) null));
assertFalse(StringUtils.containsAny(null, new char[0])); assertFalse(StringUtils.containsAny(null, new char[0]));
assertFalse(StringUtils.containsAny(null, new char[] { 'a', 'b' })); assertFalse(StringUtils.containsAny(null, 'a', 'b'));
assertFalse(StringUtils.containsAny("", (char[]) null)); assertFalse(StringUtils.containsAny("", (char[]) null));
assertFalse(StringUtils.containsAny("", new char[0])); assertFalse(StringUtils.containsAny("", new char[0]));
assertFalse(StringUtils.containsAny("", new char[] { 'a', 'b' })); assertFalse(StringUtils.containsAny("", 'a', 'b'));
assertFalse(StringUtils.containsAny("zzabyycdxx", (char[]) null)); assertFalse(StringUtils.containsAny("zzabyycdxx", (char[]) null));
assertFalse(StringUtils.containsAny("zzabyycdxx", new char[0])); assertFalse(StringUtils.containsAny("zzabyycdxx", new char[0]));
assertTrue(StringUtils.containsAny("zzabyycdxx", new char[] { 'z', 'a' })); assertTrue(StringUtils.containsAny("zzabyycdxx", 'z', 'a'));
assertTrue(StringUtils.containsAny("zzabyycdxx", new char[] { 'b', 'y' })); assertTrue(StringUtils.containsAny("zzabyycdxx", 'b', 'y'));
assertTrue(StringUtils.containsAny("zzabyycdxx", new char[] { 'z', 'y' })); assertTrue(StringUtils.containsAny("zzabyycdxx", 'z', 'y'));
assertFalse(StringUtils.containsAny("ab", new char[] { 'z' })); assertFalse(StringUtils.containsAny("ab", 'z'));
} }
/** /**
@ -225,10 +225,10 @@ public class StringUtilsEqualsIndexOfTest {
assertFalse(StringUtils.containsAny("", new String[] { "hello" })); assertFalse(StringUtils.containsAny("", new String[] { "hello" }));
assertFalse(StringUtils.containsAny("hello, goodbye", (String[]) null)); assertFalse(StringUtils.containsAny("hello, goodbye", (String[]) null));
assertFalse(StringUtils.containsAny("hello, goodbye", new String[0])); assertFalse(StringUtils.containsAny("hello, goodbye", new String[0]));
assertTrue(StringUtils.containsAny("hello, goodbye", new String[] { "hello", "goodbye" })); assertTrue(StringUtils.containsAny("hello, goodbye", new String[]{"hello", "goodbye"}));
assertTrue(StringUtils.containsAny("hello, goodbye", new String[] { "hello", "Goodbye" })); assertTrue(StringUtils.containsAny("hello, goodbye", new String[]{"hello", "Goodbye"}));
assertFalse(StringUtils.containsAny("hello, goodbye", new String[] { "Hello", "Goodbye" })); assertFalse(StringUtils.containsAny("hello, goodbye", new String[]{"Hello", "Goodbye"}));
assertFalse(StringUtils.containsAny("hello, goodbye", new String[] { "Hello", null })); assertFalse(StringUtils.containsAny("hello, goodbye", new String[]{"Hello", null}));
assertFalse(StringUtils.containsAny("hello, null", new String[] { "Hello", null })); assertFalse(StringUtils.containsAny("hello, null", new String[] { "Hello", null }));
} }
@ -649,17 +649,17 @@ public class StringUtilsEqualsIndexOfTest {
public void testIndexOfAny_StringCharArray() { public void testIndexOfAny_StringCharArray() {
assertEquals(-1, StringUtils.indexOfAny(null, (char[]) null)); assertEquals(-1, StringUtils.indexOfAny(null, (char[]) null));
assertEquals(-1, StringUtils.indexOfAny(null, new char[0])); assertEquals(-1, StringUtils.indexOfAny(null, new char[0]));
assertEquals(-1, StringUtils.indexOfAny(null, new char[] {'a','b'})); assertEquals(-1, StringUtils.indexOfAny(null, 'a','b'));
assertEquals(-1, StringUtils.indexOfAny("", (char[]) null)); assertEquals(-1, StringUtils.indexOfAny("", (char[]) null));
assertEquals(-1, StringUtils.indexOfAny("", new char[0])); assertEquals(-1, StringUtils.indexOfAny("", new char[0]));
assertEquals(-1, StringUtils.indexOfAny("", new char[] {'a','b'})); assertEquals(-1, StringUtils.indexOfAny("", 'a','b'));
assertEquals(-1, StringUtils.indexOfAny("zzabyycdxx", (char[]) null)); assertEquals(-1, StringUtils.indexOfAny("zzabyycdxx", (char[]) null));
assertEquals(-1, StringUtils.indexOfAny("zzabyycdxx", new char[0])); assertEquals(-1, StringUtils.indexOfAny("zzabyycdxx", new char[0]));
assertEquals(0, StringUtils.indexOfAny("zzabyycdxx", new char[] {'z','a'})); assertEquals(0, StringUtils.indexOfAny("zzabyycdxx", 'z','a'));
assertEquals(3, StringUtils.indexOfAny("zzabyycdxx", new char[] {'b','y'})); assertEquals(3, StringUtils.indexOfAny("zzabyycdxx", 'b','y'));
assertEquals(-1, StringUtils.indexOfAny("ab", new char[] {'z'})); assertEquals(-1, StringUtils.indexOfAny("ab", 'z'));
} }
/** /**
@ -722,19 +722,19 @@ public class StringUtilsEqualsIndexOfTest {
@Test @Test
public void testIndexOfAnyBut_StringCharArray() { public void testIndexOfAnyBut_StringCharArray() {
assertEquals(-1, StringUtils.indexOfAnyBut(null, (char[]) null)); assertEquals(-1, StringUtils.indexOfAnyBut(null, (char[]) null));
assertEquals(-1, StringUtils.indexOfAnyBut(null, new char[0])); assertEquals(-1, StringUtils.indexOfAnyBut(null));
assertEquals(-1, StringUtils.indexOfAnyBut(null, new char[] {'a','b'})); assertEquals(-1, StringUtils.indexOfAnyBut(null, 'a','b'));
assertEquals(-1, StringUtils.indexOfAnyBut("", (char[]) null)); assertEquals(-1, StringUtils.indexOfAnyBut("", (char[]) null));
assertEquals(-1, StringUtils.indexOfAnyBut("", new char[0])); assertEquals(-1, StringUtils.indexOfAnyBut(""));
assertEquals(-1, StringUtils.indexOfAnyBut("", new char[] {'a','b'})); assertEquals(-1, StringUtils.indexOfAnyBut("", 'a','b'));
assertEquals(-1, StringUtils.indexOfAnyBut("zzabyycdxx", (char[]) null)); assertEquals(-1, StringUtils.indexOfAnyBut("zzabyycdxx", (char[]) null));
assertEquals(-1, StringUtils.indexOfAnyBut("zzabyycdxx", new char[0])); assertEquals(-1, StringUtils.indexOfAnyBut("zzabyycdxx"));
assertEquals(3, StringUtils.indexOfAnyBut("zzabyycdxx", new char[] {'z','a'})); assertEquals(3, StringUtils.indexOfAnyBut("zzabyycdxx", 'z','a'));
assertEquals(0, StringUtils.indexOfAnyBut("zzabyycdxx", new char[] {'b','y'})); assertEquals(0, StringUtils.indexOfAnyBut("zzabyycdxx", 'b','y'));
assertEquals(-1, StringUtils.indexOfAnyBut("aba", new char[] {'a', 'b'})); assertEquals(-1, StringUtils.indexOfAnyBut("aba", 'a', 'b'));
assertEquals(0, StringUtils.indexOfAnyBut("aba", new char[] {'z'})); assertEquals(0, StringUtils.indexOfAnyBut("aba", 'z'));
} }