Commit 14e6bc91 authored by Andreas Fischer's avatar Andreas Fischer
Browse files

Test example from exercise sheet

parent cd6ae168
......@@ -22,6 +22,20 @@ class TestBinTree(unittest.TestCase):
self.assertIsInstance(tree.root, BinTreeNode)
self.assertEqual(tree.root.value, 1)
def test_example(self):
values = [7, 3, 9, 2, 4, 8, 11]
tree = BinTree()
for value in values:
tree.insert(value)
for value in values:
node = tree.search(value)
self.assertIsInstance(node, BinTreeNode)
self.assertEqual(value, node.value)
node = tree.search(3)
self.assertEqual(node.value, 3)
self.assertEqual(node.left.value, 2)
self.assertEqual(node.right.value, 4)
class TestBinTreeNode(unittest.TestCase):
def test_creation(self):
node = BinTreeNode(5)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment