-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathTestDivision.java
More file actions
86 lines (74 loc) · 2.06 KB
/
TestDivision.java
File metadata and controls
86 lines (74 loc) · 2.06 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import org.junit.Test;
import static org.junit.Assert.assertEquals;
/**
* @author leon on 8/26/18.
*/
public class TestDivision {
private static volatile MathUtilities mathUtils = new MathUtilities();
@Test
public void testIntegerDivision() {
// : Given
int dividend = 20;
int divisor = 2;
int expectedInt = 10;
// : When
int actualInt = mathUtils.divide(dividend, divisor);
// : Then
assertEquals(expectedInt, actualInt);
}
@Test
public void testLongDivision() {
// : Given
long dividend = 20000000L;
long divisor = 1000L;
long expectedLong = 20000;
// : When
long actualLong = mathUtils.divide(dividend, divisor);
// : Then
assertEquals(expectedLong, actualLong);
}
@Test
public void testShortDivision() {
// : Given
short dividend = 2;
short divisor = 1;
short expectedShort = 2;
// : When
short actualShort = mathUtils.divide(dividend, divisor);
// : Then
assertEquals(expectedShort, actualShort);
}
@Test
public void testByteDivision() {
// : Given
byte dividend = 64;
byte divisor = 32;
byte expectedByte = 2;
// : When
byte actualByte = mathUtils.divide(dividend, divisor);
// : Then
assertEquals(expectedByte, actualByte);
}
@Test
public void testFloatDivision() {
// : Given
float dividend = 7.5F;
float divisor = 3;
float expectedFloat = 2.50F;
// : When
float actualFloat = mathUtils.divide(dividend, divisor);
// : Then
assertEquals(expectedFloat, actualFloat, 0);
}
@Test
public void testDoubleDivision() {
// : Given
double dividend = 5.0;
double divisor = 4.0;
double expectedDouble = 1.25;
// : When
double actualDouble = mathUtils.divide(dividend, divisor);
// : Then
assertEquals(expectedDouble, actualDouble, 0);
}
}