def test_delete_random(self): tree = BST() numbers = list(range(10000)) inserted = [] for v in range(1000): k = choice(numbers) tree.insert(k, v) inserted.append(k) numbers.remove(k) for v in range(999): k = choice(inserted) tree.delete(k) inserted.remove(k) self.assertEqual(tree.search(k), None) self.assertEqual(tree.isBST(), True) for k in inserted: self.assertNotEqual(tree.search(k), None)
def test_insert_simple(self): tree = BST() tree.insert(1, 'a') self.assertEqual(tree.isBST(), True)
def test_insert_multiple(self): tree = BST() tree.insert(2, 'b') tree.insert(1, 'a') tree.insert(3, 'c') self.assertEqual(tree.isBST(), True)