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