-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestClock.java
More file actions
77 lines (56 loc) · 1.36 KB
/
TestClock.java
File metadata and controls
77 lines (56 loc) · 1.36 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
import org.junit.Test;
import junit.framework.TestCase;
public class TestClock extends TestCase {
ClockPuzzle clock ;
protected void setUp() throws Exception {
super.setUp();
clock = new ClockPuzzle();
}
protected void tearDown() throws Exception {
super.tearDown();
}
@Test
public void testClockObjNotNull(){
assertNotNull(clock);
}
@Test
public void testPrintTime(){
clock.setHours(10);
clock.setMinutes(10);
assertEquals(clock.getTime(),"10:10");
}
//e.g: input => "03:00", the output should be 270
//input => "09:30", the output should be 255
//input => "04:15", the output should be 322.5
//input => "04:45", the output should be 232.5
@Test
public void testGetClockAngle(){
clock.setHours(3);
clock.setMinutes(0);
assertEquals(clock.getClockAngle(),270.00);
}
@Test
public void testGetClockAngleFail(){
clock.setHours(13);
clock.setMinutes(0);
assertEquals(clock.getClockAngle(),-1.0);
}
@Test
public void testGetClockAngle9_30(){
clock.setHours(9);
clock.setMinutes(30);
assertEquals(clock.getClockAngle(),255.0);
}
@Test
public void testGetClockAngle4_15(){
clock.setHours(4);
clock.setMinutes(15);
assertEquals(clock.getClockAngle(),322.5);
}
@Test
public void testGetClockAngle4_45(){
clock.setHours(4);
clock.setMinutes(45);
assertEquals(clock.getClockAngle(),232.5);
}
}