-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathTestSubtraction.java
80 lines (74 loc) · 2.15 KB
/
TestSubtraction.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
import org.junit.Test;
import static org.junit.Assert.assertEquals;
/**
* @author leon on 8/26/18.
*/
public class TestSubtraction {
private static volatile MathUtilities mathUtils = new MathUtilities();
@Test
public void testIntegerSubtraction(){
// : Given
int baseValue = 20;
int difference = 7;
int expectedInt = 13;
// : When
int actualInt = mathUtils.subtract(baseValue,difference);
// : Then
assertEquals(expectedInt,actualInt);
}
@Test
public void testLongSubtraction() {
// : Given
long baseValue = 228437266;
long difference = 228437265;
long expectedLong = 1;
// : When
long actualLong = mathUtils.subtract(baseValue, difference);
// : Then
assertEquals(expectedLong,actualLong);
}
@Test
public void testShortSubtraction() {
// : Given
short baseValue = 16384;
short difference = 16383;
short expectedShort = 1;
// : When
short actualShort = mathUtils.subtract(baseValue, difference);
// : Then
assertEquals(expectedShort,actualShort);
}
@Test
public void testByteSubtraction() {
// : Given
byte baseValue = 63;
byte difference = 64;
byte expectedByte = -1;
// : When
byte actualByte = mathUtils.subtract(baseValue, difference);
// : Then
assertEquals(expectedByte,actualByte);
}
@Test
public void testFloatSubtraction() {
// : Given
float baseValue = 750.585F;
float difference = 795.0F;
float expectedFloat = -44.415F;
// : When
float actualFloat = mathUtils.subtract(baseValue,difference);
// : Then
assertEquals(expectedFloat,actualFloat, 0.005);
}
@Test
public void testDoubleSubtraction() {
// : Given
double baseValue = 225.25;
double difference = 231;
double expectedDouble = -5.75;
// : When
double actualDouble = mathUtils.subtract(baseValue, difference);
// : Then
assertEquals(expectedDouble,actualDouble, 0);
}
}