BAEL-6819 convert from int to Long in Java (#14671)
* BAEL-6819 convert from int to Long in Java * BAEL-6819 update package name
This commit is contained in:
parent
259de2ed39
commit
86f7514df6
|
@ -0,0 +1,36 @@
|
|||
package com.baeldung.inttolong;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class IntToLongUnitTest {
|
||||
|
||||
@Test
|
||||
void whenUsingTheAutoboxing_thenGetTheExpectedLong() {
|
||||
int intTen = 10;
|
||||
Long longTen = (long) intTen;
|
||||
assertEquals(intTen, longTen);
|
||||
}
|
||||
|
||||
@Test
|
||||
void whenUsingTheValueOf_thenGetTheExpectedLong() {
|
||||
int intTen = 10;
|
||||
Long longTen = Long.valueOf(intTen);
|
||||
assertEquals(intTen, longTen);
|
||||
}
|
||||
|
||||
@Test
|
||||
void whenUsingTheConstructor_thenGetTheExpectedLong() {
|
||||
int intTen = 10;
|
||||
Long longTen = new Long(intTen);
|
||||
assertEquals(intTen, longTen);
|
||||
}
|
||||
|
||||
@Test
|
||||
void whenUsingTheParseLong_thenGetTheExpectedLong() {
|
||||
int intTen = 10;
|
||||
Long longTen = Long.parseLong(String.valueOf(intTen));
|
||||
assertEquals(intTen, longTen);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue