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