-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtests.py
More file actions
61 lines (42 loc) · 1.78 KB
/
tests.py
File metadata and controls
61 lines (42 loc) · 1.78 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
import unittest
from converter import ConvertTimeToSpoken
class TestTimeConversionOutputs(unittest.TestCase):
def test_simple_am_time_test(self):
input = "01:13"
expectedOutput = "It's one thirteen am"
actualOutput = ConvertTimeToSpoken.convert(input);
self.assertEqual(expectedOutput, actualOutput)
def test_pm_time_test(self) :
input = "13:45"
expectedOutput = "It's one forty five pm"
actualOutput = ConvertTimeToSpoken.convert(input);
self.assertEqual(expectedOutput, actualOutput)
def test_twelve_pm_time_test(self) :
input = "12:45"
expectedOutput = "It's twelve forty five pm"
actualOutput = ConvertTimeToSpoken.convert(input);
self.assertEqual(expectedOutput, actualOutput)
def test_reddit_tests(self):
inputs = ["00:00", "01:30", "12:05", "14:01", "20:29", "21:00"]
expectedOutput = ["It's twelve am", "It's one thirty am", "It's twelve oh five pm", "It's two oh one pm", "It's eight twenty nine pm", "It's nine pm"]
self.assertEqual(len(inputs), len(expectedOutput))
for i in range(0, len(inputs)):
actualOutput = ConvertTimeToSpoken.convert(inputs[i]);
self.assertEqual(expectedOutput[i], actualOutput)
def test_invalid_input(self):
expectedOutput = "Invalid input"
input = ""
assert_expected(self, input, expectedOutput)
input = "asfasdgasggggggg"
assert_expected(self, input, expectedOutput)
input = "as:f&"
assert_expected(self, input, expectedOutput)
input = "1:23"
assert_expected(self, input, expectedOutput)
input = "12/34"
assert_expected(self, input, expectedOutput)
input = "99:99"
assert_expected(self, input, expectedOutput)
def assert_expected(self, input, expectedOutput):
actualoutput = ConvertTimeToSpoken.convert(input)
return self.assertEqual(expectedOutput, actualoutput)