Skip to content

Commit 18fa979

Browse files
committed
Add a few additional test cases
1 parent 139664a commit 18fa979

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

java-numbers-3/src/test/java/com/baeldung/doubletolong/DoubleToLongUnitTest.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public void givenDoubleValue_whenLongValueCalled_thenLongValueReturned() {
1313
}
1414

1515
@Test
16-
public void givenDoubleValue_whenMathRoundUsed_thenLongValueReturned() {
16+
public void givenDoubleValue_whenMathRoundUsed_thenRoundUp() {
1717
Assert.assertEquals(10000L, Math.round(VALUE));
1818
}
1919

@@ -22,6 +22,11 @@ public void givenDoubleValue_whenMathRoundUsed_thenRoundDown() {
2222
Assert.assertEquals(9999L, Math.round(9999.444));
2323
}
2424

25+
@Test
26+
public void givenDoubleValue_whenMathRoundUsed_thenSameValueReturned() {
27+
Assert.assertEquals(9999L, Math.round(9999.0));
28+
}
29+
2530
@Test
2631
public void givenDoubleValue_whenMathCeilUsed_thenLongValueReturned() {
2732
Assert.assertEquals(10000L, Math.ceil(VALUE), 0);
@@ -47,6 +52,11 @@ public void givenDoubleValue_whenMathFloorUsed_thenSameValueReturned() {
4752
Assert.assertEquals(9999L, Math.floor(9999.0), 0);
4853
}
4954

55+
@Test
56+
public void givenDoubleValue_whenMathFloorUsed_thenDifferentThanCeil() {
57+
Assert.assertEquals(9999L, Math.floor(9999.444), 0);
58+
}
59+
5060
@Test
5161
public void givenDoubleValue_whenTypeCasted_thenLongValueReturned() {
5262
Assert.assertEquals(9999L, (long) VALUE);

0 commit comments

Comments
 (0)