Add a few additional test cases

This commit is contained in:
eric-martin 2020-01-01 17:51:52 -06:00
parent 60880ad401
commit a0fa9f23b3
1 changed files with 11 additions and 1 deletions

View File

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