-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathTestAddition.java
84 lines (74 loc) · 2.02 KB
/
TestAddition.java
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
import org.junit.Test;
import static org.junit.Assert.assertEquals;
/**
* @author leon on 8/26/18.
*/
public class TestAddition {
private static volatile MathUtilities mathUtils = new MathUtilities();
@Test
public void testIntegerAddition() {
// : Given
int baseValue = 20;
int addedValue = 7;
int expected = 27;
// : When
int actual = mathUtils.add(baseValue, addedValue);
// : Then
assertEquals(expected, actual);
}
@Test
public void testLongAddition() {
// : Given
long baseValue = 228437266;
long difference = 228437265;
long expected = 456874531;
// : When
long actual = mathUtils.add(baseValue, difference);
// : Then
assertEquals(expected, actual);
}
@Test
public void testShortAddition() {
// : Given
short baseValue = 16384;
short addedValue = 7;
short expected = 16391;
// : When
short actual = mathUtils.add(baseValue, addedValue);
// : Then
assertEquals(expected, actual);
}
@Test
public void testByteAddition() {
// : Given
byte baseValue = 63;
byte addedValue = 64;
byte expected = 127;
// : When
byte actual = mathUtils.add(baseValue, addedValue);
// : Then
assertEquals(expected, actual);
}
@Test
public void testFloatAddition() {
// : Given
float baseValue = 750.585F;
float addedValue = 795.000F;
float expected = 1545.585F;
// : When
float actual = mathUtils.add(baseValue, addedValue);
// : Then
assertEquals(expected, actual, 0);
}
@Test
public void testDoubleAddition() {
// : Given
double baseValue = 225.25;
double addedValue = 231;
double expected = 456.25;
// : When
double actual = mathUtils.add(baseValue, addedValue);
// : Then
assertEquals(expected, actual, 0);
}
}