Beispiel #1
0
 def test_DeleteNodeByKeyOneNode(self):
     testKey = 0
     tree = BST(BSTNode(testKey, testKey, None))
     self.assertTrue(tree.FindNodeByKey(testKey).NodeHasKey)
     self.assertTrue(tree.DeleteNodeByKey(testKey))
     self.assertFalse(tree.FindNodeByKey(testKey).NodeHasKey)
     self.assertTrue(tree.Root is None)
Beispiel #2
0
 def test_FindNodeByKeyOneNode(self):
     testKey = 0
     node = BSTNode(testKey, testKey, None)
     tree = BST(node)
     result = tree.FindNodeByKey(testKey)
     self.assertTrue(result.Node is node)
     self.assertTrue(result.NodeHasKey is True)
Beispiel #3
0
 def test_AddKeyValueToEmptyTree(self):
     tree = BST(None)
     testKey = 1
     self.assertFalse(tree.FindNodeByKey(testKey).NodeHasKey)
     self.assertTrue(tree.AddKeyValue(testKey, testKey))
     self.assertTrue(tree.FindNodeByKey(testKey).NodeHasKey)
Beispiel #4
0
 def test_FindNodeByKeyEmpty(self):
     tree = BST(None)
     result = tree.FindNodeByKey(0)
     self.assertTrue(result.Node is None)