def test_insert(self): tree = FastBinaryTree() for key in self.keys: tree.insert(key, key) value = tree.get_value(key) self.assertEqual(value, key) self.assertEqual(tree.count, 6)
def test_remove_random_numbers(self): keys = list(set([randint(0, 10000) for _ in range(500)])) shuffle(keys) tree = FastBinaryTree(zip(keys, keys)) self.assertEqual(tree.count, len(keys)) for key in keys: tree.remove(key) self.assertEqual(tree.count, 0)
def test_remove(self): tree = FastBinaryTree(self.values) for key in self.keys: tree.remove(key) self.assertRaises(KeyError, tree.get_value, key) self.assertEqual(tree.count, 0)
def test_clear_tree(self): tree = FastBinaryTree(self.values) tree.clear() self.assertEqual(tree.count, 0)
def test_get_value(self): tree = FastBinaryTree(self.values) for key in self.keys: value = tree.get_value(key) self.assertTrue(value is not None)
def test_create_tree(self): tree = FastBinaryTree() self.assertEqual(tree.count, 0) tree.update(self.values) self.assertEqual(tree.count, 6)
def test_properties(self): tree = FastBinaryTree(self.values) self.assertEqual(tree.count, 6)
def test_get_value_not(self): tree = FastBinaryTree() self.assertRaises(KeyError, tree.get_value, 17)