File tree Expand file tree Collapse file tree
core-java-modules/core-java-numbers-conversions/src/test/java/com/baeldung/inttolong Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package com .baeldung .inttolong ;
2+
3+ import static org .junit .jupiter .api .Assertions .assertEquals ;
4+
5+ import org .junit .jupiter .api .Test ;
6+
7+ class IntToLongUnitTest {
8+
9+ @ Test
10+ void whenUsingTheAutoboxing_thenGetTheExpectedLong () {
11+ int intTen = 10 ;
12+ Long longTen = (long ) intTen ;
13+ assertEquals (intTen , longTen );
14+ }
15+
16+ @ Test
17+ void whenUsingTheValueOf_thenGetTheExpectedLong () {
18+ int intTen = 10 ;
19+ Long longTen = Long .valueOf (intTen );
20+ assertEquals (intTen , longTen );
21+ }
22+
23+ @ Test
24+ void whenUsingTheConstructor_thenGetTheExpectedLong () {
25+ int intTen = 10 ;
26+ Long longTen = new Long (intTen );
27+ assertEquals (intTen , longTen );
28+ }
29+
30+ @ Test
31+ void whenUsingTheParseLong_thenGetTheExpectedLong () {
32+ int intTen = 10 ;
33+ Long longTen = Long .parseLong (String .valueOf (intTen ));
34+ assertEquals (intTen , longTen );
35+ }
36+ }
You can’t perform that action at this time.
0 commit comments