def test_empty(self): with self.assertRaises(ValueError): lca(None, None)
def test_invalid_with_string(self): with self.assertRaises(ValueError): lca("", "")
def test_node6_2(self): self.assertEqual(lca(6, 2), 1)
def test_invalid_with_int(self): with self.assertRaises(ValueError): lca(22, 33)
def test_node4_5(self): self.assertEqual(lca(4, 5), 2)
def test_root_as_node(self): self.assertEqual(lca(self.root, 8, 5).val, 5)
def test_no_root(self): self.assertEqual(lca(None, 8, 4), None)
def test_ancestor_of_itself(self): self.assertEqual(lca(self.root, 8, 4).val, 8)
def test_child_nodes_from_left_and_right(self): self.assertEqual(lca(self.root, 1, 9).val, 5)