BAEL-2995 - possible lossy conversion - assert fix
This commit is contained in:
parent
a3e08f7ce0
commit
8b87952f5b
|
@ -12,29 +12,27 @@ public class ConversionTechniquesUnitTest {
|
|||
|
||||
long longNum = 24;
|
||||
short shortNum = (short) longNum;
|
||||
|
||||
assertEquals(24, shortNum);
|
||||
|
||||
double doubleNum = 15.6;
|
||||
int integerNum = (int) doubleNum;
|
||||
|
||||
assertEquals(15, integerNum);
|
||||
|
||||
long largeLongNum = 32768;
|
||||
long smallLongNum = -32769;
|
||||
short shortNum1 = (short) largeLongNum;
|
||||
short shortNum2 = (short) smallLongNum;
|
||||
|
||||
assertEquals(-32768, shortNum1);
|
||||
|
||||
long smallLongNum = -32769;
|
||||
short shortNum2 = (short) smallLongNum;
|
||||
assertEquals(32767, shortNum2);
|
||||
|
||||
long maxLong = Long.MAX_VALUE;
|
||||
long minLong = Long.MIN_VALUE;
|
||||
int minInt = (int) maxLong;
|
||||
int maxInt = (int) minLong;
|
||||
int int1 = (int) maxLong;
|
||||
assertEquals(-1, int1);
|
||||
|
||||
assertEquals(-1, minInt);
|
||||
assertEquals(0, maxInt);
|
||||
long minLong = Long.MIN_VALUE;
|
||||
int int2 = (int) minLong;
|
||||
assertEquals(0, int2);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -42,12 +40,10 @@ public class ConversionTechniquesUnitTest {
|
|||
|
||||
Float floatNum = 17.564f;
|
||||
long longNum = floatNum.longValue();
|
||||
|
||||
assertEquals(17, longNum);
|
||||
|
||||
Double doubleNum = 15.9999;
|
||||
longNum = doubleNum.longValue();
|
||||
|
||||
assertEquals(15, longNum);
|
||||
}
|
||||
|
||||
|
@ -56,7 +52,6 @@ public class ConversionTechniquesUnitTest {
|
|||
|
||||
Double doubleNum = 15.9999;
|
||||
long longNum = Math.round(doubleNum);
|
||||
|
||||
assertEquals(16, longNum);
|
||||
}
|
||||
|
||||
|
@ -67,8 +62,7 @@ public class ConversionTechniquesUnitTest {
|
|||
double dbl = doubleNum.doubleValue(); //unboxing
|
||||
int intgr = (int) dbl; //downcasting
|
||||
Integer intNum = Integer.valueOf(intgr);
|
||||
|
||||
assertTrue(intNum == 10);
|
||||
assertEquals(Integer.valueOf(10), intNum);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue