Exemplo n.º 1
0
 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)
Exemplo n.º 2
0
 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)
Exemplo n.º 3
0
 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)
Exemplo n.º 4
0
 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)
Exemplo n.º 5
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)
Exemplo n.º 6
0
 def test_clear_tree(self):
     tree = FastBinaryTree(self.values)
     tree.clear()
     self.assertEqual(tree.count, 0)
Exemplo n.º 7
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)
Exemplo n.º 8
0
 def test_create_tree(self):
     tree = FastBinaryTree()
     self.assertEqual(tree.count, 0)
     tree.update(self.values)
     self.assertEqual(tree.count, 6)
Exemplo n.º 9
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)
Exemplo n.º 10
0
 def test_clear_tree(self):
     tree = FastBinaryTree(self.values)
     tree.clear()
     self.assertEqual(tree.count, 0)
Exemplo n.º 11
0
 def test_properties(self):
     tree = FastBinaryTree(self.values)
     self.assertEqual(tree.count, 6)
Exemplo n.º 12
0
 def test_get_value_not(self):
     tree = FastBinaryTree()
     self.assertRaises(KeyError, tree.get_value, 17)
Exemplo n.º 13
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)
Exemplo n.º 14
0
 def test_create_tree(self):
     tree = FastBinaryTree()
     self.assertEqual(tree.count, 0)
     tree.update(self.values)
     self.assertEqual(tree.count, 6)