Merge pull request #9423 from alimate/BAEL-4147
BAEL-4147: Introducing Integer Cache
This commit is contained in:
commit
024874d9c8
@ -26,6 +26,17 @@ public class StringToIntOrIntegerUnitTest {
|
||||
assertThat(result).isEqualTo(new Integer(42));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenString_whenCallingValueOf_shouldCacheSomeValues() {
|
||||
for (int i = -128; i <= 127; i++) {
|
||||
String value = i + "";
|
||||
Integer first = Integer.valueOf(value);
|
||||
Integer second = Integer.valueOf(value);
|
||||
|
||||
assertThat(first).isSameAs(second);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenString_whenCallingIntegerConstructor_shouldConvertToInt() {
|
||||
String givenString = "42";
|
||||
|
Loading…
x
Reference in New Issue
Block a user