|
@@ -0,0 +1,160 @@
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+import static org.junit.Assert.*;
|
|
4
|
+import org.junit.After;
|
|
5
|
+import org.junit.Before;
|
|
6
|
+import org.junit.Test;
|
|
7
|
+
|
|
8
|
+/**
|
|
9
|
+ * The test class simpleOpTest.
|
|
10
|
+ *
|
|
11
|
+ * @author (your name)
|
|
12
|
+ * @version (a version number or a date)
|
|
13
|
+ */
|
|
14
|
+public class simpleOpTest
|
|
15
|
+{
|
|
16
|
+ /**
|
|
17
|
+ * Default constructor for test class simpleOpTest
|
|
18
|
+ */
|
|
19
|
+ public simpleOpTest()
|
|
20
|
+ {
|
|
21
|
+ }
|
|
22
|
+
|
|
23
|
+ /**
|
|
24
|
+ * Sets up the test fixture.
|
|
25
|
+ *
|
|
26
|
+ * Called before every test case method.
|
|
27
|
+ */
|
|
28
|
+ @Before
|
|
29
|
+ public void setUp()
|
|
30
|
+ {
|
|
31
|
+ }
|
|
32
|
+
|
|
33
|
+ /**
|
|
34
|
+ * Tears down the test fixture.
|
|
35
|
+ *
|
|
36
|
+ * Called after every test case method.
|
|
37
|
+ */
|
|
38
|
+ @After
|
|
39
|
+ public void tearDown()
|
|
40
|
+ {
|
|
41
|
+ }
|
|
42
|
+
|
|
43
|
+ @Test
|
|
44
|
+ public void firstAddTest()
|
|
45
|
+ {
|
|
46
|
+ assertEquals(4.0, simpleOp.add(2, 2), 0.1);
|
|
47
|
+ }
|
|
48
|
+
|
|
49
|
+ @Test
|
|
50
|
+ public void secondAddTestNegative()
|
|
51
|
+ {
|
|
52
|
+ assertEquals(-8.0, simpleOp.add(-100, 92), 0.1);
|
|
53
|
+ }
|
|
54
|
+
|
|
55
|
+ @Test
|
|
56
|
+ public void firstSubtractTest()
|
|
57
|
+ {
|
|
58
|
+ assertEquals(13.0, simpleOp.sub(25, 12), 0.1);
|
|
59
|
+ }
|
|
60
|
+
|
|
61
|
+ @Test
|
|
62
|
+ public void secondSubtractTestNegative()
|
|
63
|
+ {
|
|
64
|
+ assertEquals(-8.0, simpleOp.sub(-100, -92), 0.1);
|
|
65
|
+ }
|
|
66
|
+
|
|
67
|
+ @Test
|
|
68
|
+ public void firstMultiplyTest()
|
|
69
|
+ {
|
|
70
|
+ assertEquals(0.0, simpleOp.mul(3, 0), 0.1);
|
|
71
|
+ }
|
|
72
|
+
|
|
73
|
+ @Test
|
|
74
|
+ public void secondMultiplyTestNegative()
|
|
75
|
+ {
|
|
76
|
+ assertEquals(125.0, simpleOp.mul(-25, -5), 0.1);
|
|
77
|
+ }
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+ @Test
|
|
81
|
+ public void DivideTest2Negative()
|
|
82
|
+ {
|
|
83
|
+ assertEquals(20.0, simpleOp.div(100, 5), 0.1);
|
|
84
|
+ }
|
|
85
|
+
|
|
86
|
+ @Test
|
|
87
|
+ public void firstSquareTest()
|
|
88
|
+ {
|
|
89
|
+ assertEquals(25.0, simpleOp.squ(5), 0.1);
|
|
90
|
+ }
|
|
91
|
+
|
|
92
|
+ @Test
|
|
93
|
+ public void secondSquareTestNegative()
|
|
94
|
+ {
|
|
95
|
+ assertEquals(49.0, simpleOp.squ(-7), 0.1);
|
|
96
|
+ }
|
|
97
|
+
|
|
98
|
+ @Test
|
|
99
|
+ public void firstExponentTest()
|
|
100
|
+ {
|
|
101
|
+ assertEquals(125.0, simpleOp.exp(5, 3), 0.1);
|
|
102
|
+ }
|
|
103
|
+
|
|
104
|
+ @Test
|
|
105
|
+ public void SecondExponentTestNegative()
|
|
106
|
+ {
|
|
107
|
+ assertEquals(0.008, simpleOp.exp(5, -3), 0.1);
|
|
108
|
+ }
|
|
109
|
+
|
|
110
|
+ @Test
|
|
111
|
+ public void firstInverseTest()
|
|
112
|
+ {
|
|
113
|
+ assertEquals(0.01, simpleOp.inv(100), 0.1);
|
|
114
|
+ }
|
|
115
|
+
|
|
116
|
+ @Test
|
|
117
|
+ public void secondInverseTest()
|
|
118
|
+ {
|
|
119
|
+ assertEquals(0.0002, simpleOp.inv(5000), 0.1);
|
|
120
|
+ }
|
|
121
|
+
|
|
122
|
+ @Test
|
|
123
|
+ public void divideByZero()
|
|
124
|
+ {
|
|
125
|
+ assertEquals(0.0, simpleOp.div(100, 0), 0.1);
|
|
126
|
+ }
|
|
127
|
+
|
|
128
|
+ @Test
|
|
129
|
+ public void firstInvertTest()
|
|
130
|
+ {
|
|
131
|
+ assertEquals(-237.0, simpleOp.invert(237), 0.1);
|
|
132
|
+ }
|
|
133
|
+
|
|
134
|
+ @Test
|
|
135
|
+ public void secondInvertTest()
|
|
136
|
+ {
|
|
137
|
+ assertEquals(253.0, simpleOp.invert(-253), 0.1);
|
|
138
|
+ }
|
|
139
|
+
|
|
140
|
+}
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
|