-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestDivide.java
More file actions
99 lines (59 loc) · 1.74 KB
/
TestDivide.java
File metadata and controls
99 lines (59 loc) · 1.74 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
87
88
89
90
91
92
93
94
95
96
97
98
99
import static org.junit.Assert.*;
import org.junit.Assert;
import org.junit.Test;
public class TestDivide {
//First failing red line test
@Test //Declares that the function is a Junit test
public void assertDivideClassExists(){
Divide d = new Divide(); //Creates a divide object and test if the reference exists
Assert.assertNotNull(d);
}
/**
//Second failing red line test
@Test
public void assertDivideMethodAcceptsParameters(){
Divide d = new Divide();
Assert.assertTrue(d.divide(1,1) == 1); //tests that the divide function exists and accepts parameters
}
**/
/**
//Third Failing red line test
@Test
public void assertDivideCanDivideTwoPositiveNumbers(){
Divide d = new Divide();
Assert.assertEquals(d.divide(9, 3), 3); //tests that dividing 9 by 3 returns 3
}
**/
/**
//fourth failing red line test
@Test(expected = IllegalArgumentException.class) //test is expecting an error
public void assertDivideByZeroError(){
Divide d = new Divide();
d.divide(1, 0);
}
**/
/**
//fifth passing red line test
@Test
public void assertDivideWorksForOneNegativeNumber(){
Divide d = new Divide();
Assert.assertEquals(d.divide(-16, 4), -4 ); //test that dividing a negative by positive returns negative
}
**/
/**
//sixth passing red line test
@Test
public void assertDivideWorksForTwoNegativeNumbers(){
Divide d = new Divide();
Assert.assertEquals(d.divide(-16, -4), 4 ); //test that dividing a negative by negative returns positive
}
**/
/**
//seventh passing red line test
@Test
public void assertDivideIntoZero(){
Divide d = new Divide();
Assert.assertEquals(d.divide(0, 1000000), 0); //test that dividing from 0 returns 0
}
**/
}