Replace Character constructor (deprecated on Java 9+) calls in tests with Character#valueOf.
This commit is contained in:
parent
325d9a97d6
commit
cb2ec37bd3
|
@ -4340,11 +4340,11 @@ public class ArrayUtilsTest {
|
|||
|
||||
assertSame(ArrayUtils.EMPTY_CHAR_ARRAY, ArrayUtils.toPrimitive(new Character[0]));
|
||||
|
||||
assertArrayEquals(new char[]{Character.MIN_VALUE, Character.MAX_VALUE, '0'}, ArrayUtils.toPrimitive(new Character[]{new Character(Character.MIN_VALUE),
|
||||
new Character(Character.MAX_VALUE), new Character('0')}));
|
||||
assertArrayEquals(new char[]{Character.MIN_VALUE, Character.MAX_VALUE, '0'}, ArrayUtils.toPrimitive(new Character[]{Character.valueOf(Character.MIN_VALUE),
|
||||
Character.valueOf(Character.MAX_VALUE), Character.valueOf('0')}));
|
||||
|
||||
assertThrows(NullPointerException.class,
|
||||
() -> ArrayUtils.toPrimitive(new Character[]{new Character(Character.MIN_VALUE), null}));
|
||||
() -> ArrayUtils.toPrimitive(new Character[]{Character.valueOf(Character.MIN_VALUE), null}));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -4355,12 +4355,12 @@ public class ArrayUtilsTest {
|
|||
assertSame(ArrayUtils.EMPTY_CHAR_ARRAY,
|
||||
ArrayUtils.toPrimitive(new Character[0], (char) 0));
|
||||
|
||||
assertArrayEquals(new char[]{Character.MIN_VALUE, Character.MAX_VALUE, '0'}, ArrayUtils.toPrimitive(new Character[]{new Character(Character.MIN_VALUE),
|
||||
new Character(Character.MAX_VALUE), new Character('0')},
|
||||
assertArrayEquals(new char[]{Character.MIN_VALUE, Character.MAX_VALUE, '0'}, ArrayUtils.toPrimitive(new Character[]{Character.valueOf(Character.MIN_VALUE),
|
||||
Character.valueOf(Character.MAX_VALUE), Character.valueOf('0')},
|
||||
Character.MIN_VALUE));
|
||||
|
||||
assertArrayEquals(new char[]{Character.MIN_VALUE, Character.MAX_VALUE, '0'}, ArrayUtils.toPrimitive(new Character[]{new Character(Character.MIN_VALUE), null,
|
||||
new Character('0')}, Character.MAX_VALUE));
|
||||
assertArrayEquals(new char[]{Character.MIN_VALUE, Character.MAX_VALUE, '0'}, ArrayUtils.toPrimitive(new Character[]{Character.valueOf(Character.MIN_VALUE), null,
|
||||
Character.valueOf('0')}, Character.MAX_VALUE));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -4371,8 +4371,8 @@ public class ArrayUtilsTest {
|
|||
assertSame(ArrayUtils.EMPTY_CHARACTER_OBJECT_ARRAY,
|
||||
ArrayUtils.toObject(new char[0]));
|
||||
|
||||
assertArrayEquals(new Character[]{new Character(Character.MIN_VALUE),
|
||||
new Character(Character.MAX_VALUE), new Character('0')}, ArrayUtils.toObject(new char[]{Character.MIN_VALUE, Character.MAX_VALUE,
|
||||
assertArrayEquals(new Character[]{Character.valueOf(Character.MIN_VALUE),
|
||||
Character.valueOf(Character.MAX_VALUE), Character.valueOf('0')}, ArrayUtils.toObject(new char[]{Character.MIN_VALUE, Character.MAX_VALUE,
|
||||
'0'}));
|
||||
}
|
||||
|
||||
|
|
|
@ -36,8 +36,8 @@ import org.junit.jupiter.api.Test;
|
|||
public class CharUtilsTest {
|
||||
|
||||
private static final char CHAR_COPY = '\u00a9';
|
||||
private static final Character CHARACTER_A = new Character('A');
|
||||
private static final Character CHARACTER_B = new Character('B');
|
||||
private static final Character CHARACTER_A = Character.valueOf('A');
|
||||
private static final Character CHARACTER_B = Character.valueOf('B');
|
||||
|
||||
@Test
|
||||
public void testCompare() {
|
||||
|
@ -229,7 +229,7 @@ public class CharUtilsTest {
|
|||
@SuppressWarnings("deprecation") // intentional test of deprecated method
|
||||
@Test
|
||||
public void testToCharacterObject_char() {
|
||||
assertEquals(new Character('a'), CharUtils.toCharacterObject('a'));
|
||||
assertEquals(Character.valueOf('a'), CharUtils.toCharacterObject('a'));
|
||||
assertSame(CharUtils.toCharacterObject('a'), CharUtils.toCharacterObject('a'));
|
||||
|
||||
for (int i = 0; i < 128; i++) {
|
||||
|
@ -253,8 +253,8 @@ public class CharUtilsTest {
|
|||
public void testToCharacterObject_String() {
|
||||
assertNull(CharUtils.toCharacterObject(null));
|
||||
assertNull(CharUtils.toCharacterObject(""));
|
||||
assertEquals(new Character('a'), CharUtils.toCharacterObject("a"));
|
||||
assertEquals(new Character('a'), CharUtils.toCharacterObject("abc"));
|
||||
assertEquals(Character.valueOf('a'), CharUtils.toCharacterObject("a"));
|
||||
assertEquals(Character.valueOf('a'), CharUtils.toCharacterObject("abc"));
|
||||
assertSame(CharUtils.toCharacterObject("a"), CharUtils.toCharacterObject("a"));
|
||||
}
|
||||
|
||||
|
@ -282,17 +282,17 @@ public class CharUtilsTest {
|
|||
|
||||
@Test
|
||||
public void testToIntValue_Character() {
|
||||
assertEquals(0, CharUtils.toIntValue(new Character('0')));
|
||||
assertEquals(3, CharUtils.toIntValue(new Character('3')));
|
||||
assertEquals(0, CharUtils.toIntValue(Character.valueOf('0')));
|
||||
assertEquals(3, CharUtils.toIntValue(Character.valueOf('3')));
|
||||
assertThrows(IllegalArgumentException.class, () -> CharUtils.toIntValue(null));
|
||||
assertThrows(IllegalArgumentException.class, () -> CharUtils.toIntValue(CHARACTER_A));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToIntValue_Character_int() {
|
||||
assertEquals(0, CharUtils.toIntValue(new Character('0'), -1));
|
||||
assertEquals(3, CharUtils.toIntValue(new Character('3'), -1));
|
||||
assertEquals(-1, CharUtils.toIntValue(new Character('A'), -1));
|
||||
assertEquals(0, CharUtils.toIntValue(Character.valueOf('0'), -1));
|
||||
assertEquals(3, CharUtils.toIntValue(Character.valueOf('3'), -1));
|
||||
assertEquals(-1, CharUtils.toIntValue(Character.valueOf('A'), -1));
|
||||
assertEquals(-1, CharUtils.toIntValue(null, -1));
|
||||
}
|
||||
|
||||
|
|
|
@ -498,8 +498,8 @@ public class RandomStringUtilsTest {
|
|||
final char o = orig.charAt(i);
|
||||
final char c = copy.charAt(i);
|
||||
assertEquals(o, c,
|
||||
"differs at " + i + "(" + Integer.toHexString(new Character(o).hashCode()) + "," +
|
||||
Integer.toHexString(new Character(c).hashCode()) + ")");
|
||||
"differs at " + i + "(" + Integer.toHexString(Character.valueOf(o).hashCode()) + "," +
|
||||
Integer.toHexString(Character.valueOf(c).hashCode()) + ")");
|
||||
}
|
||||
// compare length also
|
||||
assertEquals(orig.length(), copy.length());
|
||||
|
|
|
@ -235,8 +235,8 @@ public class StringEscapeUtilsTest {
|
|||
assertEquals("\u0080\u009F", StringEscapeUtils.unescapeHtml4("€Ÿ"), "hex number unescape");
|
||||
// Test all Character values:
|
||||
for (char i = Character.MIN_VALUE; i < Character.MAX_VALUE; i++) {
|
||||
final Character c1 = new Character(i);
|
||||
final Character c2 = new Character((char) (i+1));
|
||||
final Character c1 = Character.valueOf(i);
|
||||
final Character c2 = Character.valueOf((char) (i+1));
|
||||
final String expected = c1.toString() + c2.toString();
|
||||
final String escapedC1 = "&#x" + Integer.toHexString((c1.charValue())) + ";";
|
||||
final String escapedC2 = "&#x" + Integer.toHexString((c2.charValue())) + ";";
|
||||
|
|
Loading…
Reference in New Issue