|
@@ -20,22 +20,140 @@ public class CalcEngineTest {
|
20
|
20
|
}
|
21
|
21
|
|
22
|
22
|
@Test
|
23
|
|
- public void add() {
|
24
|
|
- Assert.assertTrue("", (testCalc.add(1.0, 1.0) == 2.0));
|
|
23
|
+ public void testSquare(){
|
|
24
|
+ // set up data
|
|
25
|
+ double x = 3.0;
|
|
26
|
+
|
|
27
|
+ //invoke method under test
|
|
28
|
+ double actualResult = CalcEngine.square(x);
|
|
29
|
+
|
|
30
|
+ //verify result
|
|
31
|
+ double expectResult = 9.0;
|
|
32
|
+ assertEquals(expectResult, actualResult, 0.001);
|
|
33
|
+
|
25
|
34
|
}
|
26
|
35
|
|
27
|
36
|
@Test
|
28
|
|
- public void subtract() {
|
29
|
|
- Assert.assertTrue("", (testCalc.subtract(17.0, 13.0) == 4.0));
|
|
37
|
+ public void testsquareroot(){
|
|
38
|
+ double x = 25.0;
|
|
39
|
+
|
|
40
|
+ double actualResult = CalcEngine.squareroot(x);
|
|
41
|
+
|
|
42
|
+ double expectResult = 5.0;
|
|
43
|
+ assertEquals(expectResult, actualResult, 0.001);
|
30
|
44
|
}
|
31
|
45
|
|
32
|
46
|
@Test
|
33
|
|
- public void multiply() {
|
34
|
|
- Assert.assertTrue("", (testCalc.multiply(8.0, 3.0) == 24.0));
|
|
47
|
+ public void testinverse(){
|
|
48
|
+ double x = 2;
|
|
49
|
+
|
|
50
|
+ double actualResult = CalcEngine.inverse(x);
|
|
51
|
+
|
|
52
|
+ double expectResult = 0.5;
|
|
53
|
+ assertEquals(expectResult, actualResult, 0.001);
|
35
|
54
|
}
|
36
|
55
|
|
37
|
56
|
@Test
|
38
|
|
- public void divide() {
|
39
|
|
- Assert.assertTrue("", (testCalc.divide(10.0, 2.0) == 5.0));
|
|
57
|
+ public void testinvert(){
|
|
58
|
+ double x = 12.0;
|
|
59
|
+
|
|
60
|
+ double actualResult = CalcEngine.invert(x);
|
|
61
|
+
|
|
62
|
+ double expectResult = -12.0;
|
|
63
|
+ assertEquals(expectResult, actualResult, 0.001);
|
40
|
64
|
}
|
|
65
|
+
|
|
66
|
+/* @Test
|
|
67
|
+ public void testfindSin(){
|
|
68
|
+ double x = 90.0;
|
|
69
|
+
|
|
70
|
+ double actualResult = CalcEngine.findSin(x);
|
|
71
|
+
|
|
72
|
+ double expectResult = 0.8939966636;
|
|
73
|
+ assertEquals(expectResult, actualResult, 0.001);
|
|
74
|
+ }
|
|
75
|
+
|
|
76
|
+ @Test
|
|
77
|
+ public void testfindCos(){
|
|
78
|
+ double x = 45.0;
|
|
79
|
+
|
|
80
|
+ double actualResult = CalcEngine.findCos(x);
|
|
81
|
+
|
|
82
|
+ double expectResult = 0.52532198881;
|
|
83
|
+ assertEquals(expectResult, actualResult, 0.001);
|
|
84
|
+ }
|
|
85
|
+
|
|
86
|
+ @Test
|
|
87
|
+ public void testfindTan(){
|
|
88
|
+ double x = 100.0;
|
|
89
|
+
|
|
90
|
+ double actualResult = CalcEngine.findTan(x);
|
|
91
|
+
|
|
92
|
+ double expectResult = -0.58721391515;
|
|
93
|
+ assertEquals(expectResult, actualResult, 0.001);
|
|
94
|
+ }
|
|
95
|
+
|
|
96
|
+ @Test
|
|
97
|
+ public void testfindAsin(){
|
|
98
|
+ double x = 0.5;
|
|
99
|
+
|
|
100
|
+ double actualResult = CalcEngine.findAsin(x);
|
|
101
|
+
|
|
102
|
+ double expectResult = 0.52359877559;
|
|
103
|
+ assertEquals(expectResult, actualResult, 0.001);
|
|
104
|
+ }
|
|
105
|
+
|
|
106
|
+ @Test
|
|
107
|
+ public void testfindAcos(){
|
|
108
|
+ double x = 1.0;
|
|
109
|
+
|
|
110
|
+ double actualResult = CalcEngine.findAcos(x);
|
|
111
|
+
|
|
112
|
+ double expectResult = 0;
|
|
113
|
+ assertEquals(expectResult, actualResult, 0.001);
|
|
114
|
+ }
|
|
115
|
+
|
|
116
|
+ @Test
|
|
117
|
+ public void testfindAtan(){
|
|
118
|
+ double x = 1.0;
|
|
119
|
+
|
|
120
|
+ double actualResult = CalcEngine.findAtan(x);
|
|
121
|
+
|
|
122
|
+ double expectResult = 0.78539816339;
|
|
123
|
+ assertEquals(expectResult, actualResult, 0.001);
|
|
124
|
+
|
|
125
|
+ }*/
|
|
126
|
+
|
|
127
|
+ @Test
|
|
128
|
+ public void testAddition()
|
|
129
|
+ {
|
|
130
|
+ assertEquals(20.0, CalcEngine.addition(15, 5), 0.1);
|
|
131
|
+ }
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+ @Test
|
|
135
|
+ public void testSubstraction()
|
|
136
|
+ {
|
|
137
|
+ assertEquals(3.0, CalcEngine.subtraction(5, 2), 0.1);
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+ }
|
|
141
|
+
|
|
142
|
+ @Test
|
|
143
|
+ public void testMultiplication(){
|
|
144
|
+ assertEquals(6.0, CalcEngine.multiplication(3, 2), 0.1);
|
|
145
|
+ }
|
|
146
|
+
|
|
147
|
+ @Test
|
|
148
|
+ public void testDivision()
|
|
149
|
+ {
|
|
150
|
+ assertEquals(3.0, CalcEngine.division(6, 2), 0.1);
|
|
151
|
+ }
|
|
152
|
+
|
|
153
|
+ @Test
|
|
154
|
+ public void testExponent()
|
|
155
|
+ {
|
|
156
|
+ assertEquals(64.0, CalcEngine.exponent(4, 3), 0.1);
|
|
157
|
+ }
|
|
158
|
+
|
41
|
159
|
}
|