Remove unnecessary array creation for varargs.
This commit is contained in:
parent
7bbbdd2477
commit
1e70575586
|
@ -60,7 +60,7 @@ public class NumericEntityUnescaper extends CharSequenceTranslator {
|
|||
if (options.length > 0) {
|
||||
this.options = EnumSet.copyOf(Arrays.asList(options));
|
||||
} else {
|
||||
this.options = EnumSet.copyOf(Arrays.asList(new OPTION[] { OPTION.semiColonRequired }));
|
||||
this.options = EnumSet.copyOf(Arrays.asList(OPTION.semiColonRequired));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -64,18 +64,18 @@ public class CharSetUtilsTest {
|
|||
@Test
|
||||
public void testSqueeze_StringStringarray() {
|
||||
assertNull(CharSetUtils.squeeze(null, (String[]) null));
|
||||
assertNull(CharSetUtils.squeeze(null, new String[0]));
|
||||
assertNull(CharSetUtils.squeeze(null, new String[] {null}));
|
||||
assertNull(CharSetUtils.squeeze(null, new String[] {"el"}));
|
||||
assertNull(CharSetUtils.squeeze(null));
|
||||
assertNull(CharSetUtils.squeeze(null, null));
|
||||
assertNull(CharSetUtils.squeeze(null, "el"));
|
||||
|
||||
assertEquals("", CharSetUtils.squeeze("", (String[]) null));
|
||||
assertEquals("", CharSetUtils.squeeze(""));
|
||||
assertEquals("", CharSetUtils.squeeze("", new String[] {null}));
|
||||
assertEquals("", CharSetUtils.squeeze("", null));
|
||||
assertEquals("", CharSetUtils.squeeze("", "a-e"));
|
||||
|
||||
assertEquals("hello", CharSetUtils.squeeze("hello", (String[]) null));
|
||||
assertEquals("hello", CharSetUtils.squeeze("hello"));
|
||||
assertEquals("hello", CharSetUtils.squeeze("hello", new String[] {null}));
|
||||
assertEquals("hello", CharSetUtils.squeeze("hello", null));
|
||||
assertEquals("hello", CharSetUtils.squeeze("hello", "a-e"));
|
||||
|
||||
assertEquals("helo", CharSetUtils.squeeze("hello", "el"));
|
||||
|
@ -104,17 +104,17 @@ public class CharSetUtilsTest {
|
|||
public void testContainsAny_StringStringarray() {
|
||||
assertFalse(CharSetUtils.containsAny(null, (String[]) null));
|
||||
assertFalse(CharSetUtils.containsAny(null));
|
||||
assertFalse(CharSetUtils.containsAny(null, new String[] {null}));
|
||||
assertFalse(CharSetUtils.containsAny(null, null));
|
||||
assertFalse(CharSetUtils.containsAny(null, "a-e"));
|
||||
|
||||
assertFalse(CharSetUtils.containsAny("", (String[]) null));
|
||||
assertFalse(CharSetUtils.containsAny(""));
|
||||
assertFalse(CharSetUtils.containsAny("", new String[] {null}));
|
||||
assertFalse(CharSetUtils.containsAny("", null));
|
||||
assertFalse(CharSetUtils.containsAny("", "a-e"));
|
||||
|
||||
assertFalse(CharSetUtils.containsAny("hello", (String[]) null));
|
||||
assertFalse(CharSetUtils.containsAny("hello"));
|
||||
assertFalse(CharSetUtils.containsAny("hello", new String[] {null}));
|
||||
assertFalse(CharSetUtils.containsAny("hello", null));
|
||||
assertTrue(CharSetUtils.containsAny("hello", "a-e"));
|
||||
|
||||
assertTrue(CharSetUtils.containsAny("hello", "el"));
|
||||
|
@ -144,17 +144,17 @@ public class CharSetUtilsTest {
|
|||
public void testCount_StringStringarray() {
|
||||
assertEquals(0, CharSetUtils.count(null, (String[]) null));
|
||||
assertEquals(0, CharSetUtils.count(null));
|
||||
assertEquals(0, CharSetUtils.count(null, new String[] {null}));
|
||||
assertEquals(0, CharSetUtils.count(null, null));
|
||||
assertEquals(0, CharSetUtils.count(null, "a-e"));
|
||||
|
||||
assertEquals(0, CharSetUtils.count("", (String[]) null));
|
||||
assertEquals(0, CharSetUtils.count(""));
|
||||
assertEquals(0, CharSetUtils.count("", new String[] {null}));
|
||||
assertEquals(0, CharSetUtils.count("", null));
|
||||
assertEquals(0, CharSetUtils.count("", "a-e"));
|
||||
|
||||
assertEquals(0, CharSetUtils.count("hello", (String[]) null));
|
||||
assertEquals(0, CharSetUtils.count("hello"));
|
||||
assertEquals(0, CharSetUtils.count("hello", new String[] {null}));
|
||||
assertEquals(0, CharSetUtils.count("hello", null));
|
||||
assertEquals(1, CharSetUtils.count("hello", "a-e"));
|
||||
|
||||
assertEquals(3, CharSetUtils.count("hello", "el"));
|
||||
|
@ -185,18 +185,18 @@ public class CharSetUtilsTest {
|
|||
@Test
|
||||
public void testKeep_StringStringarray() {
|
||||
assertNull(CharSetUtils.keep(null, (String[]) null));
|
||||
assertNull(CharSetUtils.keep(null, new String[0]));
|
||||
assertNull(CharSetUtils.keep(null, new String[] {null}));
|
||||
assertNull(CharSetUtils.keep(null, new String[] {"a-e"}));
|
||||
assertNull(CharSetUtils.keep(null));
|
||||
assertNull(CharSetUtils.keep(null, null));
|
||||
assertNull(CharSetUtils.keep(null, "a-e"));
|
||||
|
||||
assertEquals("", CharSetUtils.keep("", (String[]) null));
|
||||
assertEquals("", CharSetUtils.keep(""));
|
||||
assertEquals("", CharSetUtils.keep("", new String[] {null}));
|
||||
assertEquals("", CharSetUtils.keep("", null));
|
||||
assertEquals("", CharSetUtils.keep("", "a-e"));
|
||||
|
||||
assertEquals("", CharSetUtils.keep("hello", (String[]) null));
|
||||
assertEquals("", CharSetUtils.keep("hello"));
|
||||
assertEquals("", CharSetUtils.keep("hello", new String[] {null}));
|
||||
assertEquals("", CharSetUtils.keep("hello", null));
|
||||
assertEquals("e", CharSetUtils.keep("hello", "a-e"));
|
||||
|
||||
assertEquals("e", CharSetUtils.keep("hello", "a-e"));
|
||||
|
@ -227,18 +227,18 @@ public class CharSetUtilsTest {
|
|||
@Test
|
||||
public void testDelete_StringStringarray() {
|
||||
assertNull(CharSetUtils.delete(null, (String[]) null));
|
||||
assertNull(CharSetUtils.delete(null, new String[0]));
|
||||
assertNull(CharSetUtils.delete(null, new String[] {null}));
|
||||
assertNull(CharSetUtils.delete(null, new String[] {"el"}));
|
||||
assertNull(CharSetUtils.delete(null));
|
||||
assertNull(CharSetUtils.delete(null, null));
|
||||
assertNull(CharSetUtils.delete(null, "el"));
|
||||
|
||||
assertEquals("", CharSetUtils.delete("", (String[]) null));
|
||||
assertEquals("", CharSetUtils.delete(""));
|
||||
assertEquals("", CharSetUtils.delete("", new String[] {null}));
|
||||
assertEquals("", CharSetUtils.delete("", null));
|
||||
assertEquals("", CharSetUtils.delete("", "a-e"));
|
||||
|
||||
assertEquals("hello", CharSetUtils.delete("hello", (String[]) null));
|
||||
assertEquals("hello", CharSetUtils.delete("hello"));
|
||||
assertEquals("hello", CharSetUtils.delete("hello", new String[] {null}));
|
||||
assertEquals("hello", CharSetUtils.delete("hello", null));
|
||||
assertEquals("hello", CharSetUtils.delete("hello", "xyz"));
|
||||
|
||||
assertEquals("ho", CharSetUtils.delete("hello", "el"));
|
||||
|
|
|
@ -1260,7 +1260,7 @@ public class ClassUtilsTest {
|
|||
|
||||
// Tests with a public Class
|
||||
final Method toStringMethod = ClassUtils.getPublicMethod(Object.class, "toString");
|
||||
assertEquals(Object.class.getMethod("toString", new Class[0]), toStringMethod);
|
||||
assertEquals(Object.class.getMethod("toString"), toStringMethod);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -220,7 +220,7 @@ public class ObjectUtilsTest {
|
|||
|
||||
@Test
|
||||
public void testHashCodeMulti_multiple_likeList() {
|
||||
final List<Object> list0 = new ArrayList<>(Arrays.asList(new Object[0]));
|
||||
final List<Object> list0 = new ArrayList<>(Arrays.asList());
|
||||
assertEquals(list0.hashCode(), ObjectUtils.hashCodeMulti());
|
||||
|
||||
final List<Object> list1 = new ArrayList<>(Arrays.asList("a"));
|
||||
|
|
|
@ -73,7 +73,7 @@ public class StringUtilsEmptyBlankTest {
|
|||
@Test
|
||||
public void testIsAllEmpty() {
|
||||
assertTrue(StringUtils.isAllEmpty());
|
||||
assertTrue(StringUtils.isAllEmpty(new String[]{}));
|
||||
assertTrue(StringUtils.isAllEmpty());
|
||||
assertTrue(StringUtils.isAllEmpty((String) null));
|
||||
assertTrue(StringUtils.isAllEmpty((String[]) null));
|
||||
assertFalse(StringUtils.isAllEmpty(null, "foo"));
|
||||
|
|
|
@ -92,7 +92,7 @@ public class StringUtilsStartsEndsWithTest {
|
|||
assertTrue(StringUtils.startsWithAny("abcxyz", "abc"));
|
||||
assertTrue(StringUtils.startsWithAny("abcxyz", null, "xyz", "abc"));
|
||||
assertFalse(StringUtils.startsWithAny("abcxyz", null, "xyz", "abcd"));
|
||||
assertTrue(StringUtils.startsWithAny("abcxyz", new String[]{""}));
|
||||
assertTrue(StringUtils.startsWithAny("abcxyz", ""));
|
||||
assertFalse(StringUtils.startsWithAny("abcxyz", null, "xyz", "ABCX"));
|
||||
assertFalse(StringUtils.startsWithAny("ABCXYZ", null, "xyz", "abc"));
|
||||
|
||||
|
@ -171,12 +171,12 @@ public class StringUtilsStartsEndsWithTest {
|
|||
@Test
|
||||
public void testEndsWithAny() {
|
||||
assertFalse(StringUtils.endsWithAny(null, (String) null), "StringUtils.endsWithAny(null, null)");
|
||||
assertFalse(StringUtils.endsWithAny(null, new String[] {"abc"}), "StringUtils.endsWithAny(null, new String[] {abc})");
|
||||
assertFalse(StringUtils.endsWithAny(null, "abc"), "StringUtils.endsWithAny(null, new String[] {abc})");
|
||||
assertFalse(StringUtils.endsWithAny("abcxyz", (String) null), "StringUtils.endsWithAny(abcxyz, null)");
|
||||
assertTrue(StringUtils.endsWithAny("abcxyz", new String[] {""}), "StringUtils.endsWithAny(abcxyz, new String[] {\"\"})");
|
||||
assertTrue(StringUtils.endsWithAny("abcxyz", new String[] {"xyz"}), "StringUtils.endsWithAny(abcxyz, new String[] {xyz})");
|
||||
assertTrue(StringUtils.endsWithAny("abcxyz", new String[] {null, "xyz", "abc"}), "StringUtils.endsWithAny(abcxyz, new String[] {null, xyz, abc})");
|
||||
assertFalse(StringUtils.endsWithAny("defg", new String[] {null, "xyz", "abc"}), "StringUtils.endsWithAny(defg, new String[] {null, xyz, abc})");
|
||||
assertTrue(StringUtils.endsWithAny("abcxyz", ""), "StringUtils.endsWithAny(abcxyz, new String[] {\"\"})");
|
||||
assertTrue(StringUtils.endsWithAny("abcxyz", "xyz"), "StringUtils.endsWithAny(abcxyz, new String[] {xyz})");
|
||||
assertTrue(StringUtils.endsWithAny("abcxyz", null, "xyz", "abc"), "StringUtils.endsWithAny(abcxyz, new String[] {null, xyz, abc})");
|
||||
assertFalse(StringUtils.endsWithAny("defg", null, "xyz", "abc"), "StringUtils.endsWithAny(defg, new String[] {null, xyz, abc})");
|
||||
assertTrue(StringUtils.endsWithAny("abcXYZ", "def", "XYZ"));
|
||||
assertFalse(StringUtils.endsWithAny("abcXYZ", "def", "xyz"));
|
||||
assertTrue(StringUtils.endsWithAny("abcXYZ", "def", "YZ"));
|
||||
|
|
|
@ -430,7 +430,7 @@ public class StringUtilsTest {
|
|||
assertNull(StringUtils.appendIfMissing(null, null, (CharSequence[]) null), "appendIfMissing(null,null,null)");
|
||||
assertEquals("abc", StringUtils.appendIfMissing("abc", null, (CharSequence[]) null), "appendIfMissing(abc,null,null)");
|
||||
assertEquals("xyz", StringUtils.appendIfMissing("", "xyz", (CharSequence[]) null), "appendIfMissing(\"\",xyz,null))");
|
||||
assertEquals("abcxyz", StringUtils.appendIfMissing("abc", "xyz", new CharSequence[]{null}), "appendIfMissing(abc,xyz,{null})");
|
||||
assertEquals("abcxyz", StringUtils.appendIfMissing("abc", "xyz", null), "appendIfMissing(abc,xyz,{null})");
|
||||
assertEquals("abc", StringUtils.appendIfMissing("abc", "xyz", ""), "appendIfMissing(abc,xyz,\"\")");
|
||||
assertEquals("abcxyz", StringUtils.appendIfMissing("abc", "xyz", "mno"), "appendIfMissing(abc,xyz,mno)");
|
||||
assertEquals("abcxyz", StringUtils.appendIfMissing("abcxyz", "xyz", "mno"), "appendIfMissing(abcxyz,xyz,mno)");
|
||||
|
@ -454,7 +454,7 @@ public class StringUtilsTest {
|
|||
assertNull(StringUtils.appendIfMissingIgnoreCase(null, null, (CharSequence[]) null), "appendIfMissingIgnoreCase(null,null,null)");
|
||||
assertEquals("abc", StringUtils.appendIfMissingIgnoreCase("abc", null, (CharSequence[]) null), "appendIfMissingIgnoreCase(abc,null,null)");
|
||||
assertEquals("xyz", StringUtils.appendIfMissingIgnoreCase("", "xyz", (CharSequence[]) null), "appendIfMissingIgnoreCase(\"\",xyz,null)");
|
||||
assertEquals("abcxyz", StringUtils.appendIfMissingIgnoreCase("abc", "xyz", new CharSequence[]{null}), "appendIfMissingIgnoreCase(abc,xyz,{null})");
|
||||
assertEquals("abcxyz", StringUtils.appendIfMissingIgnoreCase("abc", "xyz", null), "appendIfMissingIgnoreCase(abc,xyz,{null})");
|
||||
assertEquals("abc", StringUtils.appendIfMissingIgnoreCase("abc", "xyz", ""), "appendIfMissingIgnoreCase(abc,xyz,\"\")");
|
||||
assertEquals("abcxyz", StringUtils.appendIfMissingIgnoreCase("abc", "xyz", "mno"), "appendIfMissingIgnoreCase(abc,xyz,mno)");
|
||||
assertEquals("abcxyz", StringUtils.appendIfMissingIgnoreCase("abcxyz", "xyz", "mno"), "appendIfMissingIgnoreCase(abcxyz,xyz,mno)");
|
||||
|
@ -797,22 +797,22 @@ public class StringUtilsTest {
|
|||
@Test
|
||||
public void testDifferenceAt_StringArray() {
|
||||
assertEquals(-1, StringUtils.indexOfDifference((String[]) null));
|
||||
assertEquals(-1, StringUtils.indexOfDifference(new String[]{}));
|
||||
assertEquals(-1, StringUtils.indexOfDifference(new String[]{"abc"}));
|
||||
assertEquals(-1, StringUtils.indexOfDifference(new String[]{null, null}));
|
||||
assertEquals(-1, StringUtils.indexOfDifference(new String[]{"", ""}));
|
||||
assertEquals(0, StringUtils.indexOfDifference(new String[]{"", null}));
|
||||
assertEquals(0, StringUtils.indexOfDifference(new String[]{"abc", null, null}));
|
||||
assertEquals(0, StringUtils.indexOfDifference(new String[]{null, null, "abc"}));
|
||||
assertEquals(0, StringUtils.indexOfDifference(new String[]{"", "abc"}));
|
||||
assertEquals(0, StringUtils.indexOfDifference(new String[]{"abc", ""}));
|
||||
assertEquals(-1, StringUtils.indexOfDifference(new String[]{"abc", "abc"}));
|
||||
assertEquals(1, StringUtils.indexOfDifference(new String[]{"abc", "a"}));
|
||||
assertEquals(2, StringUtils.indexOfDifference(new String[]{"ab", "abxyz"}));
|
||||
assertEquals(2, StringUtils.indexOfDifference(new String[]{"abcde", "abxyz"}));
|
||||
assertEquals(0, StringUtils.indexOfDifference(new String[]{"abcde", "xyz"}));
|
||||
assertEquals(0, StringUtils.indexOfDifference(new String[]{"xyz", "abcde"}));
|
||||
assertEquals(7, StringUtils.indexOfDifference(new String[]{"i am a machine", "i am a robot"}));
|
||||
assertEquals(-1, StringUtils.indexOfDifference());
|
||||
assertEquals(-1, StringUtils.indexOfDifference("abc"));
|
||||
assertEquals(-1, StringUtils.indexOfDifference(null, null));
|
||||
assertEquals(-1, StringUtils.indexOfDifference("", ""));
|
||||
assertEquals(0, StringUtils.indexOfDifference("", null));
|
||||
assertEquals(0, StringUtils.indexOfDifference("abc", null, null));
|
||||
assertEquals(0, StringUtils.indexOfDifference(null, null, "abc"));
|
||||
assertEquals(0, StringUtils.indexOfDifference("", "abc"));
|
||||
assertEquals(0, StringUtils.indexOfDifference("abc", ""));
|
||||
assertEquals(-1, StringUtils.indexOfDifference("abc", "abc"));
|
||||
assertEquals(1, StringUtils.indexOfDifference("abc", "a"));
|
||||
assertEquals(2, StringUtils.indexOfDifference("ab", "abxyz"));
|
||||
assertEquals(2, StringUtils.indexOfDifference("abcde", "abxyz"));
|
||||
assertEquals(0, StringUtils.indexOfDifference("abcde", "xyz"));
|
||||
assertEquals(0, StringUtils.indexOfDifference("xyz", "abcde"));
|
||||
assertEquals(7, StringUtils.indexOfDifference("i am a machine", "i am a robot"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -1531,7 +1531,7 @@ public class StringUtilsTest {
|
|||
assertNull(StringUtils.prependIfMissing(null, null, (CharSequence[]) null), "prependIfMissing(null,null null)");
|
||||
assertEquals("abc", StringUtils.prependIfMissing("abc", null, (CharSequence[]) null), "prependIfMissing(abc,null,null)");
|
||||
assertEquals("xyz", StringUtils.prependIfMissing("", "xyz", (CharSequence[]) null), "prependIfMissing(\"\",xyz,null)");
|
||||
assertEquals("xyzabc", StringUtils.prependIfMissing("abc", "xyz", new CharSequence[]{null}), "prependIfMissing(abc,xyz,{null})");
|
||||
assertEquals("xyzabc", StringUtils.prependIfMissing("abc", "xyz", null), "prependIfMissing(abc,xyz,{null})");
|
||||
assertEquals("abc", StringUtils.prependIfMissing("abc", "xyz", ""), "prependIfMissing(abc,xyz,\"\")");
|
||||
assertEquals("xyzabc", StringUtils.prependIfMissing("abc", "xyz", "mno"), "prependIfMissing(abc,xyz,mno)");
|
||||
assertEquals("xyzabc", StringUtils.prependIfMissing("xyzabc", "xyz", "mno"), "prependIfMissing(xyzabc,xyz,mno)");
|
||||
|
@ -1555,7 +1555,7 @@ public class StringUtilsTest {
|
|||
assertNull(StringUtils.prependIfMissingIgnoreCase(null, null, (CharSequence[]) null), "prependIfMissingIgnoreCase(null,null null)");
|
||||
assertEquals("abc", StringUtils.prependIfMissingIgnoreCase("abc", null, (CharSequence[]) null), "prependIfMissingIgnoreCase(abc,null,null)");
|
||||
assertEquals("xyz", StringUtils.prependIfMissingIgnoreCase("", "xyz", (CharSequence[]) null), "prependIfMissingIgnoreCase(\"\",xyz,null)");
|
||||
assertEquals("xyzabc", StringUtils.prependIfMissingIgnoreCase("abc", "xyz", new CharSequence[]{null}), "prependIfMissingIgnoreCase(abc,xyz,{null})");
|
||||
assertEquals("xyzabc", StringUtils.prependIfMissingIgnoreCase("abc", "xyz", null), "prependIfMissingIgnoreCase(abc,xyz,{null})");
|
||||
assertEquals("abc", StringUtils.prependIfMissingIgnoreCase("abc", "xyz", ""), "prependIfMissingIgnoreCase(abc,xyz,\"\")");
|
||||
assertEquals("xyzabc", StringUtils.prependIfMissingIgnoreCase("abc", "xyz", "mno"), "prependIfMissingIgnoreCase(abc,xyz,mno)");
|
||||
assertEquals("xyzabc", StringUtils.prependIfMissingIgnoreCase("xyzabc", "xyz", "mno"), "prependIfMissingIgnoreCase(xyzabc,xyz,mno)");
|
||||
|
|
|
@ -82,7 +82,7 @@ public class IEEE754rUtilsTest {
|
|||
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> IEEE754rUtils.min(new double[0]),
|
||||
() -> IEEE754rUtils.min(),
|
||||
"IllegalArgumentException expected for empty input");
|
||||
|
||||
assertThrows(
|
||||
|
@ -92,7 +92,7 @@ public class IEEE754rUtilsTest {
|
|||
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> IEEE754rUtils.max(new double[0]),
|
||||
() -> IEEE754rUtils.max(),
|
||||
"IllegalArgumentException expected for empty input");
|
||||
}
|
||||
|
||||
|
|
|
@ -691,16 +691,16 @@ public class NumberUtilsTest {
|
|||
|
||||
@Test
|
||||
public void testMinLong_emptyArray() {
|
||||
assertThrows(IllegalArgumentException.class, () -> NumberUtils.min(new long[0]));
|
||||
assertThrows(IllegalArgumentException.class, () -> NumberUtils.min());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMinLong() {
|
||||
assertEquals(5, NumberUtils.min(new long[] { 5 }), "min(long[]) failed for array length 1");
|
||||
assertEquals(6, NumberUtils.min(new long[] { 6, 9 }), "min(long[]) failed for array length 2");
|
||||
assertEquals(5, NumberUtils.min(5), "min(long[]) failed for array length 1");
|
||||
assertEquals(6, NumberUtils.min(6, 9), "min(long[]) failed for array length 2");
|
||||
|
||||
assertEquals(-10, NumberUtils.min(new long[] { -10, -5, 0, 5, 10 }));
|
||||
assertEquals(-10, NumberUtils.min(new long[] { -5, 0, -10, 5, 10 }));
|
||||
assertEquals(-10, NumberUtils.min(-10, -5, 0, 5, 10));
|
||||
assertEquals(-10, NumberUtils.min(-5, 0, -10, 5, 10));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -710,7 +710,7 @@ public class NumberUtilsTest {
|
|||
|
||||
@Test
|
||||
public void testMinInt_emptyArray() {
|
||||
assertThrows(IllegalArgumentException.class, () -> NumberUtils.min(new int[0]));
|
||||
assertThrows(IllegalArgumentException.class, () -> NumberUtils.min());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -729,16 +729,16 @@ public class NumberUtilsTest {
|
|||
|
||||
@Test
|
||||
public void testMinShort_emptyArray() {
|
||||
assertThrows(IllegalArgumentException.class, () -> NumberUtils.min(new short[0]));
|
||||
assertThrows(IllegalArgumentException.class, () -> NumberUtils.min());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMinShort() {
|
||||
assertEquals(5, NumberUtils.min(new short[] { 5 }), "min(short[]) failed for array length 1");
|
||||
assertEquals(6, NumberUtils.min(new short[] { 6, 9 }), "min(short[]) failed for array length 2");
|
||||
assertEquals(5, NumberUtils.min(5), "min(short[]) failed for array length 1");
|
||||
assertEquals(6, NumberUtils.min(6, 9), "min(short[]) failed for array length 2");
|
||||
|
||||
assertEquals(-10, NumberUtils.min(new short[] { -10, -5, 0, 5, 10 }));
|
||||
assertEquals(-10, NumberUtils.min(new short[] { -5, 0, -10, 5, 10 }));
|
||||
assertEquals(-10, NumberUtils.min(-10, -5, 0, 5, 10));
|
||||
assertEquals(-10, NumberUtils.min(-5, 0, -10, 5, 10));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -753,11 +753,11 @@ public class NumberUtilsTest {
|
|||
|
||||
@Test
|
||||
public void testMinByte() {
|
||||
assertEquals(5, NumberUtils.min(new byte[] { 5 }), "min(byte[]) failed for array length 1");
|
||||
assertEquals(6, NumberUtils.min(new byte[] { 6, 9 }), "min(byte[]) failed for array length 2");
|
||||
assertEquals(5, NumberUtils.min(5), "min(byte[]) failed for array length 1");
|
||||
assertEquals(6, NumberUtils.min(6, 9), "min(byte[]) failed for array length 2");
|
||||
|
||||
assertEquals(-10, NumberUtils.min(new byte[] { -10, -5, 0, 5, 10 }));
|
||||
assertEquals(-10, NumberUtils.min(new byte[] { -5, 0, -10, 5, 10 }));
|
||||
assertEquals(-10, NumberUtils.min(-10, -5, 0, 5, 10));
|
||||
assertEquals(-10, NumberUtils.min(-5, 0, -10, 5, 10));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -767,7 +767,7 @@ public class NumberUtilsTest {
|
|||
|
||||
@Test
|
||||
public void testMinDouble_emptyArray() {
|
||||
assertThrows(IllegalArgumentException.class, () -> NumberUtils.min(new double[0]));
|
||||
assertThrows(IllegalArgumentException.class, () -> NumberUtils.min());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -775,8 +775,8 @@ public class NumberUtilsTest {
|
|||
assertEquals(5.12, NumberUtils.min(5.12), "min(double[]) failed for array length 1");
|
||||
assertEquals(6.23, NumberUtils.min(6.23, 9.34), "min(double[]) failed for array length 2");
|
||||
assertEquals(-10.45, NumberUtils.min(-10.45, -5.56, 0, 5.67, 10.78), "min(double[]) failed for array length 5");
|
||||
assertEquals(-10, NumberUtils.min(new double[] { -10, -5, 0, 5, 10 }), 0.0001);
|
||||
assertEquals(-10, NumberUtils.min(new double[] { -5, 0, -10, 5, 10 }), 0.0001);
|
||||
assertEquals(-10, NumberUtils.min(-10, -5, 0, 5, 10), 0.0001);
|
||||
assertEquals(-10, NumberUtils.min(-5, 0, -10, 5, 10), 0.0001);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -786,7 +786,7 @@ public class NumberUtilsTest {
|
|||
|
||||
@Test
|
||||
public void testMinFloat_emptyArray() {
|
||||
assertThrows(IllegalArgumentException.class, () -> NumberUtils.min(new float[0]));
|
||||
assertThrows(IllegalArgumentException.class, () -> NumberUtils.min());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -794,8 +794,8 @@ public class NumberUtilsTest {
|
|||
assertEquals(5.9f, NumberUtils.min(5.9f), "min(float[]) failed for array length 1");
|
||||
assertEquals(6.8f, NumberUtils.min(6.8f, 9.7f), "min(float[]) failed for array length 2");
|
||||
assertEquals(-10.6f, NumberUtils.min(-10.6f, -5.5f, 0, 5.4f, 10.3f), "min(float[]) failed for array length 5");
|
||||
assertEquals(-10, NumberUtils.min(new float[] { -10, -5, 0, 5, 10 }), 0.0001f);
|
||||
assertEquals(-10, NumberUtils.min(new float[] { -5, 0, -10, 5, 10 }), 0.0001f);
|
||||
assertEquals(-10, NumberUtils.min(-10, -5, 0, 5, 10), 0.0001f);
|
||||
assertEquals(-10, NumberUtils.min(-5, 0, -10, 5, 10), 0.0001f);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -805,16 +805,16 @@ public class NumberUtilsTest {
|
|||
|
||||
@Test
|
||||
public void testMaxLong_emptyArray() {
|
||||
assertThrows(IllegalArgumentException.class, () -> NumberUtils.max(new long[0]));
|
||||
assertThrows(IllegalArgumentException.class, () -> NumberUtils.max());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMaxLong() {
|
||||
assertEquals(5, NumberUtils.max(new long[] { 5 }), "max(long[]) failed for array length 1");
|
||||
assertEquals(9, NumberUtils.max(new long[] { 6, 9 }), "max(long[]) failed for array length 2");
|
||||
assertEquals(10, NumberUtils.max(new long[] { -10, -5, 0, 5, 10 }), "max(long[]) failed for array length 5");
|
||||
assertEquals(10, NumberUtils.max(new long[] { -10, -5, 0, 5, 10 }));
|
||||
assertEquals(10, NumberUtils.max(new long[] { -5, 0, 10, 5, -10 }));
|
||||
assertEquals(5, NumberUtils.max(5), "max(long[]) failed for array length 1");
|
||||
assertEquals(9, NumberUtils.max(6, 9), "max(long[]) failed for array length 2");
|
||||
assertEquals(10, NumberUtils.max(-10, -5, 0, 5, 10), "max(long[]) failed for array length 5");
|
||||
assertEquals(10, NumberUtils.max(-10, -5, 0, 5, 10));
|
||||
assertEquals(10, NumberUtils.max(-5, 0, 10, 5, -10));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -824,7 +824,7 @@ public class NumberUtilsTest {
|
|||
|
||||
@Test
|
||||
public void testMaxInt_emptyArray() {
|
||||
assertThrows(IllegalArgumentException.class, () -> NumberUtils.max(new int[0]));
|
||||
assertThrows(IllegalArgumentException.class, () -> NumberUtils.max());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -843,16 +843,16 @@ public class NumberUtilsTest {
|
|||
|
||||
@Test
|
||||
public void testMaxShort_emptyArray() {
|
||||
assertThrows(IllegalArgumentException.class, () -> NumberUtils.max(new short[0]));
|
||||
assertThrows(IllegalArgumentException.class, () -> NumberUtils.max());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMaxShort() {
|
||||
assertEquals(5, NumberUtils.max(new short[] { 5 }), "max(short[]) failed for array length 1");
|
||||
assertEquals(9, NumberUtils.max(new short[] { 6, 9 }), "max(short[]) failed for array length 2");
|
||||
assertEquals(10, NumberUtils.max(new short[] { -10, -5, 0, 5, 10 }), "max(short[]) failed for array length 5");
|
||||
assertEquals(10, NumberUtils.max(new short[] { -10, -5, 0, 5, 10 }));
|
||||
assertEquals(10, NumberUtils.max(new short[] { -5, 0, 10, 5, -10 }));
|
||||
assertEquals(5, NumberUtils.max(5), "max(short[]) failed for array length 1");
|
||||
assertEquals(9, NumberUtils.max(6, 9), "max(short[]) failed for array length 2");
|
||||
assertEquals(10, NumberUtils.max(-10, -5, 0, 5, 10), "max(short[]) failed for array length 5");
|
||||
assertEquals(10, NumberUtils.max(-10, -5, 0, 5, 10));
|
||||
assertEquals(10, NumberUtils.max(-5, 0, 10, 5, -10));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -867,11 +867,11 @@ public class NumberUtilsTest {
|
|||
|
||||
@Test
|
||||
public void testMaxByte() {
|
||||
assertEquals(5, NumberUtils.max(new byte[] { 5 }), "max(byte[]) failed for array length 1");
|
||||
assertEquals(9, NumberUtils.max(new byte[] { 6, 9 }), "max(byte[]) failed for array length 2");
|
||||
assertEquals(10, NumberUtils.max(new byte[] { -10, -5, 0, 5, 10 }), "max(byte[]) failed for array length 5");
|
||||
assertEquals(10, NumberUtils.max(new byte[] { -10, -5, 0, 5, 10 }));
|
||||
assertEquals(10, NumberUtils.max(new byte[] { -5, 0, 10, 5, -10 }));
|
||||
assertEquals(5, NumberUtils.max(5), "max(byte[]) failed for array length 1");
|
||||
assertEquals(9, NumberUtils.max(6, 9), "max(byte[]) failed for array length 2");
|
||||
assertEquals(10, NumberUtils.max(-10, -5, 0, 5, 10), "max(byte[]) failed for array length 5");
|
||||
assertEquals(10, NumberUtils.max(-10, -5, 0, 5, 10));
|
||||
assertEquals(10, NumberUtils.max(-5, 0, 10, 5, -10));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -881,7 +881,7 @@ public class NumberUtilsTest {
|
|||
|
||||
@Test
|
||||
public void testMaxDouble_emptyArray() {
|
||||
assertThrows(IllegalArgumentException.class, () -> NumberUtils.max(new double[0]));
|
||||
assertThrows(IllegalArgumentException.class, () -> NumberUtils.max());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -892,14 +892,14 @@ public class NumberUtilsTest {
|
|||
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> NumberUtils.max(new double[0]),
|
||||
() -> NumberUtils.max(),
|
||||
"No exception was thrown for empty input.");
|
||||
|
||||
assertEquals(5.1f, NumberUtils.max(new double[]{5.1f}), "max(double[]) failed for array length 1");
|
||||
assertEquals(9.2f, NumberUtils.max(new double[]{6.3f, 9.2f}), "max(double[]) failed for array length 2");
|
||||
assertEquals(10.4f, NumberUtils.max(new double[]{-10.5f, -5.6f, 0, 5.7f, 10.4f}), "max(double[]) failed for float length 5");
|
||||
assertEquals(10, NumberUtils.max(new double[] { -10, -5, 0, 5, 10 }), 0.0001);
|
||||
assertEquals(10, NumberUtils.max(new double[] { -5, 0, 10, 5, -10 }), 0.0001);
|
||||
assertEquals(5.1f, NumberUtils.max(5.1f), "max(double[]) failed for array length 1");
|
||||
assertEquals(9.2f, NumberUtils.max(6.3f, 9.2f), "max(double[]) failed for array length 2");
|
||||
assertEquals(10.4f, NumberUtils.max(-10.5f, -5.6f, 0, 5.7f, 10.4f), "max(double[]) failed for float length 5");
|
||||
assertEquals(10, NumberUtils.max(-10, -5, 0, 5, 10), 0.0001);
|
||||
assertEquals(10, NumberUtils.max(-5, 0, 10, 5, -10), 0.0001);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -909,7 +909,7 @@ public class NumberUtilsTest {
|
|||
|
||||
@Test
|
||||
public void testMaxFloat_emptyArray() {
|
||||
assertThrows(IllegalArgumentException.class, () -> NumberUtils.max(new float[0]));
|
||||
assertThrows(IllegalArgumentException.class, () -> NumberUtils.max());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -917,8 +917,8 @@ public class NumberUtilsTest {
|
|||
assertEquals(5.1f, NumberUtils.max(5.1f), "max(float[]) failed for array length 1");
|
||||
assertEquals(9.2f, NumberUtils.max(6.3f, 9.2f), "max(float[]) failed for array length 2");
|
||||
assertEquals(10.4f, NumberUtils.max(-10.5f, -5.6f, 0, 5.7f, 10.4f), "max(float[]) failed for float length 5");
|
||||
assertEquals(10, NumberUtils.max(new float[] { -10, -5, 0, 5, 10 }), 0.0001f);
|
||||
assertEquals(10, NumberUtils.max(new float[] { -5, 0, 10, 5, -10 }), 0.0001f);
|
||||
assertEquals(10, NumberUtils.max(-10, -5, 0, 5, 10), 0.0001f);
|
||||
assertEquals(10, NumberUtils.max(-5, 0, 10, 5, -10), 0.0001f);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -504,7 +504,7 @@ public class TypeUtilsTest<B> {
|
|||
assertEquals(Integer.class, typeVarAssigns.get(treeSetTypeVar),
|
||||
"Type argument of Comparable from int: " + typeArg);
|
||||
|
||||
final Collection<Integer> col = Arrays.asList(new Integer[0]);
|
||||
final Collection<Integer> col = Arrays.asList();
|
||||
typeVarAssigns = TypeUtils.getTypeArguments(List.class, Collection.class);
|
||||
treeSetTypeVar = Comparable.class.getTypeParameters()[0];
|
||||
assertFalse(typeVarAssigns.containsKey(treeSetTypeVar),
|
||||
|
|
|
@ -1030,7 +1030,7 @@ public class StrBuilderAppendInsertTest {
|
|||
assertEquals("", sb.toString());
|
||||
|
||||
sb.clear();
|
||||
sb.appendAll(Arrays.asList(new Object[]{"foo", "bar", "baz"}));
|
||||
sb.appendAll(Arrays.asList("foo", "bar", "baz"));
|
||||
assertEquals("foobarbaz", sb.toString());
|
||||
}
|
||||
|
||||
|
@ -1046,7 +1046,7 @@ public class StrBuilderAppendInsertTest {
|
|||
assertEquals("", sb.toString());
|
||||
|
||||
sb.clear();
|
||||
sb.appendAll(Arrays.asList(new Object[]{"foo", "bar", "baz"}).iterator());
|
||||
sb.appendAll(Arrays.asList("foo", "bar", "baz").iterator());
|
||||
assertEquals("foobarbaz", sb.toString());
|
||||
}
|
||||
|
||||
|
@ -1086,15 +1086,15 @@ public class StrBuilderAppendInsertTest {
|
|||
assertEquals("", sb.toString());
|
||||
|
||||
sb.clear();
|
||||
sb.appendWithSeparators(Arrays.asList(new Object[]{"foo", "bar", "baz"}), ",");
|
||||
sb.appendWithSeparators(Arrays.asList("foo", "bar", "baz"), ",");
|
||||
assertEquals("foo,bar,baz", sb.toString());
|
||||
|
||||
sb.clear();
|
||||
sb.appendWithSeparators(Arrays.asList(new Object[]{"foo", "bar", "baz"}), null);
|
||||
sb.appendWithSeparators(Arrays.asList("foo", "bar", "baz"), null);
|
||||
assertEquals("foobarbaz", sb.toString());
|
||||
|
||||
sb.clear();
|
||||
sb.appendWithSeparators(Arrays.asList(new Object[]{"foo", null, "baz"}), ",");
|
||||
sb.appendWithSeparators(Arrays.asList("foo", null, "baz"), ",");
|
||||
assertEquals("foo,,baz", sb.toString());
|
||||
}
|
||||
|
||||
|
@ -1110,15 +1110,15 @@ public class StrBuilderAppendInsertTest {
|
|||
assertEquals("", sb.toString());
|
||||
|
||||
sb.clear();
|
||||
sb.appendWithSeparators(Arrays.asList(new Object[]{"foo", "bar", "baz"}).iterator(), ",");
|
||||
sb.appendWithSeparators(Arrays.asList("foo", "bar", "baz").iterator(), ",");
|
||||
assertEquals("foo,bar,baz", sb.toString());
|
||||
|
||||
sb.clear();
|
||||
sb.appendWithSeparators(Arrays.asList(new Object[]{"foo", "bar", "baz"}).iterator(), null);
|
||||
sb.appendWithSeparators(Arrays.asList("foo", "bar", "baz").iterator(), null);
|
||||
assertEquals("foobarbaz", sb.toString());
|
||||
|
||||
sb.clear();
|
||||
sb.appendWithSeparators(Arrays.asList(new Object[]{"foo", null, "baz"}).iterator(), ",");
|
||||
sb.appendWithSeparators(Arrays.asList("foo", null, "baz").iterator(), ",");
|
||||
assertEquals("foo,,baz", sb.toString());
|
||||
}
|
||||
|
||||
|
@ -1131,7 +1131,7 @@ public class StrBuilderAppendInsertTest {
|
|||
assertEquals("foo,null,baz", sb.toString());
|
||||
|
||||
sb.clear();
|
||||
sb.appendWithSeparators(Arrays.asList(new Object[]{"foo", null, "baz"}), ",");
|
||||
sb.appendWithSeparators(Arrays.asList("foo", null, "baz"), ",");
|
||||
assertEquals("foo,null,baz", sb.toString());
|
||||
}
|
||||
|
||||
|
|
|
@ -200,8 +200,8 @@ public class WordUtilsTest {
|
|||
@Test
|
||||
public void testCapitalizeWithDelimiters_String() {
|
||||
assertNull(WordUtils.capitalize(null, null));
|
||||
assertEquals("", WordUtils.capitalize("", new char[0]));
|
||||
assertEquals(" ", WordUtils.capitalize(" ", new char[0]));
|
||||
assertEquals("", WordUtils.capitalize(""));
|
||||
assertEquals(" ", WordUtils.capitalize(" "));
|
||||
|
||||
char[] chars = new char[] { '-', '+', ' ', '@' };
|
||||
assertEquals("I", WordUtils.capitalize("I", chars) );
|
||||
|
@ -232,8 +232,8 @@ public class WordUtilsTest {
|
|||
@Test
|
||||
public void testCapitalizeFullyWithDelimiters_String() {
|
||||
assertNull(WordUtils.capitalizeFully(null, null));
|
||||
assertEquals("", WordUtils.capitalizeFully("", new char[0]));
|
||||
assertEquals(" ", WordUtils.capitalizeFully(" ", new char[0]));
|
||||
assertEquals("", WordUtils.capitalizeFully(""));
|
||||
assertEquals(" ", WordUtils.capitalizeFully(" "));
|
||||
|
||||
char[] chars = new char[] { '-', '+', ' ', '@' };
|
||||
assertEquals("I", WordUtils.capitalizeFully("I", chars) );
|
||||
|
@ -284,8 +284,8 @@ public class WordUtilsTest {
|
|||
@Test
|
||||
public void testUncapitalizeWithDelimiters_String() {
|
||||
assertNull(WordUtils.uncapitalize(null, null));
|
||||
assertEquals("", WordUtils.uncapitalize("", new char[0]));
|
||||
assertEquals(" ", WordUtils.uncapitalize(" ", new char[0]));
|
||||
assertEquals("", WordUtils.uncapitalize(""));
|
||||
assertEquals(" ", WordUtils.uncapitalize(" "));
|
||||
|
||||
char[] chars = new char[] { '-', '+', ' ', '@' };
|
||||
assertEquals("i", WordUtils.uncapitalize("I", chars) );
|
||||
|
|
Loading…
Reference in New Issue