def test_top_right(self): tree = TreeSet((2, 1, 4, 3)) tree.discard(2) self.assertEqual(3, tree.root.key) self.assertEqual(0, tree.root.weight) self.assertEqual(2, tree.height()) self.assertTrue(tree.is_valid())
def test_top_left(self): tree = TreeSet((3, 4, 2, 1)) tree.discard(3) self.assertEqual(2, tree.root.key) self.assertEqual(0, tree.root.weight) self.assertEqual(2, tree.height()) self.assertTrue(tree.is_valid())
def test_7(self): for i in itertools.permutations(range(1, 8)): tree = TreeSet(i) if 3 == tree.height(): self.assertEqual(4, tree.root.key) self.assertEqual(0, tree.root.weight) self.assertEqual((1, 2, 3, 4, 5, 6, 7), tuple(tree)) self.assertTrue(tree.is_valid())
def test_3(self): for i in itertools.permutations(range(1, 4)): tree = TreeSet(i) self.assertEqual(2, tree.root.key) self.assertEqual(0, tree.root.weight) self.assertEqual(2, tree.height()) self.assertEqual((1, 2, 3), tuple(tree)) self.assertTrue(tree.is_valid())