def test_create_balanced_tree(self): root = create_balanced_tree() self.assertTrue(type(root) is Node) self.assertEqual(root.id, 1) for child in root.children: self.assertTrue(root.id < child.id) root = create_balanced_tree() self.assertEqual(root.id, 1)
def test_depth_first_search(self): root = create_balanced_tree() result = depth_first_search(root, 1) self.assertTrue(type(result) is Node) result = depth_first_search(root, 7) self.assertTrue(type(result) is Node) result = depth_first_search(root, 12) self.assertTrue(type(result) is Node) result = depth_first_search(root, 15) self.assertTrue(type(result) is Node) result = depth_first_search(root, 0) self.assertEqual(result, None) result = depth_first_search(root, 16) self.assertEqual(result, None)