Merge pull request #9423 from alimate/BAEL-4147

BAEL-4147: Introducing Integer Cache
This commit is contained in:
Eric Martin
2020-06-07 11:16:44 -05:00
committed by GitHub

View File

@@ -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";