-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathTestMultiplication.java
More file actions
79 lines (74 loc) · 2.18 KB
/
TestMultiplication.java
File metadata and controls
79 lines (74 loc) · 2.18 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
import org.junit.Test;
import static org.junit.Assert.assertEquals;
/**
* @author leon on 8/26/18.
*/
public class TestMultiplication {
private static volatile MathUtilities mathUtils = new MathUtilities();
@Test
public void testIntegerMultiplication(){
// : Given
int multiplicand = 5;
int multiplier = 2;
int expectedInt = 10;
// : When
int actualInt = mathUtils.multiply(multiplicand,multiplier);
// : Then
assertEquals(expectedInt,actualInt);
}
@Test
public void testLongMultiplication() {
// : Given
long multiplicand = 20;
long multiplier = 1000;
long expectedLong = 20000;
// : When
long actualLong = mathUtils.multiply(multiplicand, multiplier);
// : Then
assertEquals(expectedLong, actualLong);
}
@Test
public void testShortMultiplication() {
// : Given
short multiplicand = 2;
short multiplier = 1;
short expectedShort = 2;
// : When
short actualShort = mathUtils.multiply(multiplicand, multiplier);
// : Then
assertEquals(expectedShort, actualShort);
}
@Test
public void testByteMultiplication() {
// : Given
byte multiplicand = 16;
byte multiplier = 14;
byte expectedByte = 64;
// : When
byte actualByte = mathUtils.multiply(multiplicand, multiplier);
// : Then
assertEquals(expectedByte, actualByte);
}
@Test
public void testFloatMultiplication() {
// : Given
float multiplicand = 2.5F;
float multiplier = 1;
float expectedFloat = 2.50F;
// : When
float actualFloat = mathUtils.multiply(multiplicand,multiplier);
// : Then
assertEquals(expectedFloat, actualFloat, 0);
}
@Test
public void testDoubleMultiplication() {
// : Given
double multiplicand = 3.25;
double multiplier = 3.0;
double expectedDouble = 9.75;
// : When
double actualDouble = mathUtils.multiply(multiplicand,multiplier);
// : Then
assertEquals(expectedDouble, actualDouble, 0);
}
}