Skip to content
Snippets Groups Projects
Commit e6e185f7 authored by tuhe's avatar tuhe
Browse files

updates

parent b2b82a49
No related branches found
No related tags found
No related merge requests found
File added
This diff is collapsed.
...@@ -6,10 +6,7 @@ from stones import maximum_stones ...@@ -6,10 +6,7 @@ from stones import maximum_stones
# A fancy helper function to generate nicer-looking titles. # A fancy helper function to generate nicer-looking titles.
def trlist(x): def trlist(x):
s = str(list(x)) s = str(list(x))
if len(s) > 30: return s[:30] + "...]" if len(s) > 30 else s
s = s[:30] + "...]"
return s
class Stones(UTestCase): class Stones(UTestCase):
""" Test of the Stones function """ """ Test of the Stones function """
...@@ -27,7 +24,7 @@ class Stones(UTestCase): ...@@ -27,7 +24,7 @@ class Stones(UTestCase):
self.stest(4, [4]) # One stone weighing 4 kg. self.stest(4, [4]) # One stone weighing 4 kg.
def test_stones2(self): def test_stones2(self):
self.stest(4, [1, 4]) # should also give 1 self.stest(4, [1, 2, 4]) # should also give 1
def test_stones3(self): def test_stones3(self):
self.stest(4, [4, 1]) # should also give 1 self.stest(4, [4, 1]) # should also give 1
......
This diff is collapsed.
No preview for this file type
...@@ -21,13 +21,14 @@ class Stones(UTestCase): ...@@ -21,13 +21,14 @@ class Stones(UTestCase):
def test_basecase(self): def test_basecase(self):
""" Test the stones-example given in the homework """ """ Test the stones-example given in the homework """
N = maximum_stones(15, [2, 5, 3, 1, 8, 4, 5, 7]) N = maximum_stones(15, [2, 5, 3, 1, 8, 4, 5, 7])
print("How many stones could we pick up?", N)
self.assertEqual(N, 5) # Test that we can collect 5 stones. self.assertEqual(N, 5) # Test that we can collect 5 stones.
def test_stones1(self): def test_stones1(self):
self.stest(4, [4]) # One stone weighing 4 kg. self.stest(4, [4]) # One stone weighing 4 kg.
def test_stones2(self): def test_stones2(self):
self.stest(4, [1, 4]) # should also give 1 self.stest(4, [1, 2, 4]) # should also give 1
def test_stones3(self): def test_stones3(self):
self.stest(4, [4, 1]) # should also give 1 self.stest(4, [4, 1]) # should also give 1
......
This diff is collapsed.
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment