Add a few additional test cases
@@ -13,7 +13,7 @@ public class DoubleToLongUnitTest {
}
@Test
- public void givenDoubleValue_whenMathRoundUsed_thenLongValueReturned() {
+ public void givenDoubleValue_whenMathRoundUsed_thenRoundUp() {
Assert.assertEquals(10000L, Math.round(VALUE));
}
@@ -22,6 +22,11 @@ public class DoubleToLongUnitTest {
Assert.assertEquals(9999L, Math.round(9999.444));
}
+ @Test
+ public void givenDoubleValue_whenMathRoundUsed_thenSameValueReturned() {
+ Assert.assertEquals(9999L, Math.round(9999.0));
+ }
+
@Test
public void givenDoubleValue_whenMathCeilUsed_thenLongValueReturned() {
Assert.assertEquals(10000L, Math.ceil(VALUE), 0);
@@ -47,6 +52,11 @@ public class DoubleToLongUnitTest {
Assert.assertEquals(9999L, Math.floor(9999.0), 0);
}
+ @Test
+ public void givenDoubleValue_whenMathFloorUsed_thenDifferentThanCeil() {
+ Assert.assertEquals(9999L, Math.floor(9999.444), 0);
+ }
+
@Test
public void givenDoubleValue_whenTypeCasted_thenLongValueReturned() {
Assert.assertEquals(9999L, (long) VALUE);
