forked from Kyle-Pu/Mathematics
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCalculationTest.java
More file actions
64 lines (53 loc) · 1.54 KB
/
CalculationTest.java
File metadata and controls
64 lines (53 loc) · 1.54 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
import static org.junit.Assert.*;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
public class CalculationTest {
private static Calculation testItem ;
@BeforeClass
public static void setUp() throws Exception { testItem = new Sine(); }
@AfterClass
public static void tearDown() throws Exception { testItem = null; }
/**
* Purpose : test convertToRadians()
* Input : "30","60"
* Expected :
* input = "30" -> result = 0.5235987755982988
* input = "60" -> result = 1.0471975511965976
*/
@Test
public void testConvertToRadians() {
testItem.angle="30";
assertEquals(0.5235987755982988, testItem.convertToRadians(),0);
testItem.angle="60";
assertEquals(1.0471975511965976, testItem.convertToRadians(),0);
}
/**
* Purpose : test convertToDouble()
* Input : "30","60"
* Expected :
* input = "30" -> result = 30
* input = "60" -> result = 60
*/
@Test
public void testConvertToDouble() {
testItem.angle="30";
assertEquals(30.0, testItem.convertToDouble(),0);
testItem.angle="60";
assertEquals(60.0, testItem.convertToDouble(),0);
}
/**
* Purpose : test getValue() for Sine class
* Input : "45", "180"
* Expected :
* input = "45" -> result = 0.7071067811865475
* input = "180" -> result = 0.0
*/
@Test
public void testGetValueSine() {
testItem.angle="45";
assertEquals(0.7071067811865475, testItem.getValue(),0);
testItem.angle="180";
assertEquals(0.0, testItem.getValue(),0);
}
}