Exemplo n.º 1
0
 def test_rotate_left(self):
     tree = TreeSet()
     for _ in (3, 2, 5, 1, 4, 6, 7):
         tree.add(_)
     self.assertEqual(1, tree.root.weight)
     tree.discard(1)
     self.assertEqual(5, tree.root.key)
     self.assertEqual(0, tree.root.weight)
     self.assertTrue(tree.is_valid())
Exemplo n.º 2
0
 def test_rotate_right(self):
     tree = TreeSet()
     for _ in (5, 3, 6, 2, 4, 7, 1):
         tree.add(_)
     self.assertEqual(-1, tree.root.weight)
     tree.discard(6)
     self.assertEqual(3, tree.root.key)
     self.assertEqual(0, tree.root.weight)
     self.assertTrue(tree.is_valid())
Exemplo n.º 3
0
 def test_low_left(self):
     tree = TreeSet()
     for _ in (4, 3, 5, 1, 2):
         tree.add(_)
     tree.discard(1)
     self.assertEqual(-1, tree.root.weight)
     self.assertEqual(2, tree.root.left.key)
     self.assertEqual(1, tree.root.left.weight)
     self.assertTrue(tree.is_valid())