Пример #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)
Пример #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)
Пример #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)
Пример #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)
Пример #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)
Пример #6
0
 def test_clear_tree(self):
     tree = FastBinaryTree(self.values)
     tree.clear()
     self.assertEqual(tree.count, 0)
Пример #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)
Пример #8
0
 def test_create_tree(self):
     tree = FastBinaryTree()
     self.assertEqual(tree.count, 0)
     tree.update(self.values)
     self.assertEqual(tree.count, 6)
Пример #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)
Пример #10
0
 def test_clear_tree(self):
     tree = FastBinaryTree(self.values)
     tree.clear()
     self.assertEqual(tree.count, 0)
Пример #11
0
 def test_properties(self):
     tree = FastBinaryTree(self.values)
     self.assertEqual(tree.count, 6)
Пример #12
0
 def test_get_value_not(self):
     tree = FastBinaryTree()
     self.assertRaises(KeyError, tree.get_value, 17)
Пример #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)
Пример #14
0
 def test_create_tree(self):
     tree = FastBinaryTree()
     self.assertEqual(tree.count, 0)
     tree.update(self.values)
     self.assertEqual(tree.count, 6)