-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy path6-max_integer_test.py
61 lines (47 loc) · 1.85 KB
/
6-max_integer_test.py
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
#!/usr/bin/python3
"""Unittests for max_integer([..])."""
import unittest
max_integer = __import__('6-max_integer').max_integer
class TestMaxInteger(unittest.TestCase):
"""Define unittests for max_integer([..])."""
def test_ordered_list(self):
"""Test an ordered list of integers."""
ordered = [1, 2, 3, 4]
self.assertEqual(max_integer(ordered), 4)
def test_unordered_list(self):
"""Test an unordered list of integers."""
unordered = [1, 2, 4, 3]
self.assertEqual(max_integer(unordered), 4)
def test_max_at_begginning(self):
"""Test a list with a beginning max value."""
max_at_beginning = [4, 3, 2, 1]
self.assertEqual(max_integer(max_at_beginning), 4)
def test_empty_list(self):
"""Test an empty list."""
empty = []
self.assertEqual(max_integer(empty), None)
def test_one_element_list(self):
"""Test a list with a single element."""
one_element = [7]
self.assertEqual(max_integer(one_element), 7)
def test_floats(self):
"""Test a list of floats."""
floats = [1.53, 6.33, -9.123, 15.2, 6.0]
self.assertEqual(max_integer(floats), 15.2)
def test_ints_and_floats(self):
"""Test a list of ints and floats."""
ints_and_floats = [1.53, 15.5, -9, 15, 6]
self.assertEqual(max_integer(ints_and_floats), 15.5)
def test_string(self):
"""Test a string."""
string = "Brennan"
self.assertEqual(max_integer(string), 'r')
def test_list_of_strings(self):
"""Test a list of strings."""
strings = ["Brennan", "is", "my", "name"]
self.assertEqual(max_integer(strings), "name")
def test_empty_string(self):
"""Test an empty string."""
self.assertEqual(max_integer(""), None)
if __name__ == '__main__':
unittest.main()