-
Notifications
You must be signed in to change notification settings - Fork 51
Expand file tree
/
Copy pathMathTest.java
More file actions
38 lines (29 loc) · 1.25 KB
/
Copy pathMathTest.java
File metadata and controls
38 lines (29 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package com.amazonaws.samples.appconfig.movies;
import java.math.BigDecimal;
import java.math.RoundingMode;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import com.amazonaws.samples.appconfig.utils.Math;
public class MathTest {
@Test
public void testDivide() {
Math math = new Math();
math.divide();
// Test divide(BigDecimal, BigDecimal, int)
BigDecimal bd = BigDecimal.valueOf(10);
BigDecimal bd2 = BigDecimal.valueOf(2);
BigDecimal expectedResult1 = BigDecimal.valueOf(5);
assertEquals(expectedResult1, bd.divide(bd2, RoundingMode.DOWN));
// Test divide(BigDecimal, int)
BigDecimal expectedResult2 = BigDecimal.valueOf(5.0);
// Test divide(BigDecimal, int, int)
BigDecimal expectedResult3 = BigDecimal.valueOf(5.0);
assertEquals(expectedResult3, bd.divide(bd2, 1, RoundingMode.CEILING));
BigDecimal expectedResult4 = BigDecimal.valueOf(5.0);
assertEquals(expectedResult4, bd.divide(bd2, 1, RoundingMode.DOWN));
// Test setScale(int, int)
BigDecimal expectedResult5 = BigDecimal.valueOf(10);
bd.setScale(2, RoundingMode.DOWN);
assertEquals(expectedResult5, bd);
}
}