-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
50 lines (36 loc) · 1.25 KB
/
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
import unittest
from min_sum_partitioning import min_sum_first_attempt, min_sum
class Test(unittest.TestCase):
def assert_both_methods(self, l, sol):
self.assertEqual(sol, min_sum_first_attempt(l))
self.assertEqual(sol, min_sum(l))
def testEmptyList(self):
l = []
self.assert_both_methods(l, 0)
def testOneElement(self):
l = [5]
self.assert_both_methods(l, 5)
def testTwoElements1(self):
l = [1, 5]
self.assert_both_methods(l, 4)
def testTwoElements2(self):
l = [5, 1]
self.assert_both_methods(l, 4)
def testSimpleCase1(self):
l = [1, 6, 5, 11]
self.assert_both_methods(l, 1)
def testSimpleCase2(self):
l = [36, 7, 46, 40]
self.assert_both_methods(l, 23)
def testSimpleCase3(self):
l = [1, 4, 5, 7]
self.assert_both_methods(l, 1)
def testSimpleCase4(self):
l = [1, 4, 5, 5, 10]
self.assert_both_methods(l, 3)
def testLargerCase(self):
l = [37, 28, 16, 44, 36, 37, 43, 50, 22, 13, 28, 41, 10, 14, 27, 41, 27,
23, 37, 12, 19, 18, 30, 33, 31, 13, 24, 18, 36, 30, 3, 23, 9, 20]
self.assert_both_methods(l, 1)
if __name__ == "__main__":
unittest.main()