BAEL-5418 - Convert long to int type in Java (#8) (#11895)

This commit is contained in:
alemoles
2022-03-07 01:34:14 -05:00
committed by GitHub
parent b88561186e
commit 3fbad0691d
3 changed files with 72 additions and 0 deletions
@@ -0,0 +1,23 @@
package com.baeldung.convertLongToInt;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
class ConvertLongToIntUnitTest {
@Test
void longToInt() {
long number = 186762L;
int expected = 186762;
assertEquals(expected, ConvertLongToInt.longToIntCast(number));
assertEquals(expected, ConvertLongToInt.longToIntJavaWithMath(number));
assertEquals(expected, ConvertLongToInt.longToIntJavaWithLambda(number));
assertEquals(expected, ConvertLongToInt.longToIntBoxingValues(number));
assertEquals(expected, ConvertLongToInt.longToIntGuava(number));
assertEquals(expected, ConvertLongToInt.longToIntGuavaSaturated(number));
assertEquals(expected, ConvertLongToInt.longToIntWithBigDecimal(number));
}
}