-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathProblem6Test.java
More file actions
146 lines (109 loc) · 3.85 KB
/
Problem6Test.java
File metadata and controls
146 lines (109 loc) · 3.85 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
package io.zipcoder;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
public class Problem6Test {
Problem6 problem6;
@Before
public void setUp() {
problem6 = new Problem6();
}
@Test
public void convertToMilitaryTimeTest_Input130pm() {
String input = "1:30pm";
String expected = "Thirteen Hundred and Thirty Hours";
String actual = problem6.convertToMilitaryTime(input);
Assert.assertEquals(expected, actual);
}
@Test
public void convertToMilitaryTimeTest_Input130am() {
String input = "1:30am";
String expected = "Zero One Hundred and Thirty Hours";
String actual = problem6.convertToMilitaryTime(input);
Assert.assertEquals(expected, actual);
}
@Test
public void convertToMilitaryTimeTest_Input222pm() {
String input = "2:22pm";
String expected = "Fourteen Hundred and Twenty Two Hours";
String actual = problem6.convertToMilitaryTime(input);
Assert.assertEquals(expected, actual);
}
@Test
public void convertToMilitaryTimeTest_Input211am() {
String input = "2:11am";
String expected = "Zero Two Hundred and Eleven Hours";
String actual = problem6.convertToMilitaryTime(input);
Assert.assertEquals(expected, actual);
}
@Test
public void convertToMilitaryTimeTest_Input1002am() {
String input = "10:02am";
String expected = "Ten Hundred Zero Two Hours";
String actual = problem6.convertToMilitaryTime(input);
Assert.assertEquals(expected, actual);
}
@Test
public void checkIfPmTest_expectedTrue() {
String input = "1:30pm";
Assert.assertTrue(problem6.checkIfPm(input));
}
@Test
public void checkIfPmTest_expectedFalse() {
String input = "5:30am";
Assert.assertFalse(problem6.checkIfPm(input));
}
@Test
public void getHoursTest_expected1() {
String input = "1:30pm";
Integer expected = 1;
Integer actual = problem6.getHours(input);
Assert.assertEquals(expected, actual);
}
@Test (expected = NumberFormatException.class)
public void verifyValidInputTestFromGetHours_ExpectedNumberFormatException() {
String input = "Tariq:30pm";
Integer actual = problem6.getHours(input);
}
@Test
public void getMinutesTest_expected30() {
String input = "1:30pm";
Integer expected = 30;
Integer actual = problem6.getMinutes(input);
Assert.assertEquals(expected, actual);
}
@Test (expected = NumberFormatException.class)
public void verifyValidInputTestFromGetMinutes_expectedNumberFormatException() {
String input = "1:lolpm";
Integer actual = problem6.getMinutes(input);
}
@Test
public void testPopulateHours_ExpectedSize25() {
int expected = 25;
int actual = problem6.getHoursArrayList().size();
Assert.assertEquals(expected, actual);
}
@Test
public void testPopulateMinutes_ExpectedSize60() {
int expected = 60;
int actual = problem6.getMinutesArrayList().size();
Assert.assertEquals(expected, actual);
}
@Test
public void convertHoursToString_expectedFourteen() {
String input = "2:30pm";
String expected = "Fourteen";
Integer hours = problem6.getHours(input);
boolean isPm = problem6.checkIfPm(input);
String actual = problem6.convertHoursToString(hours, isPm);
Assert.assertEquals(expected, actual);
}
@Test
public void convertMinutesToString_expectedThirty() {
String input = "2:30pm";
String expected = "and Thirty";
Integer minutes = problem6.getMinutes(input);
String actual = problem6.convertMinutesToString(minutes);
Assert.assertEquals(expected, actual);
}
}