Skip to content

Commit 7ebf6f9

Browse files
authored
[bigDecimal-x-int] Multiply a BigDecimal By an Integer in Java (eugenp#13320)
1 parent fb8f443 commit 7ebf6f9

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.baeldung.bigdecimaltimesint;
2+
3+
import static org.assertj.core.api.Assertions.assertThat;
4+
import static org.junit.jupiter.api.Assertions.assertEquals;
5+
6+
import java.math.BigDecimal;
7+
8+
import org.junit.jupiter.api.Test;
9+
10+
public class BigDecimalxIntegerUnitTest {
11+
private static final BigDecimal BIG = new BigDecimal("42.42");
12+
private static final int INT = 10;
13+
private static final BigDecimal EXPECTED = new BigDecimal("424.2");
14+
15+
@Test
16+
void givenBigDecimalAndInt_whenTimes_thenGetExpectedResult() {
17+
BigDecimal result = BIG.multiply(BigDecimal.valueOf(INT));
18+
19+
assertEquals(0, EXPECTED.compareTo(result));
20+
assertThat(result).isEqualByComparingTo(EXPECTED);
21+
}
22+
}

0 commit comments

Comments
 (0)