示例#1
0
 def getTestTree(self):
     tree = aBST(3)
     tree.Tree = [
         50, 25, 75, None, 37, 62, 84, None, None, 31, 43, 55, None, None,
         92
     ]
     return tree
示例#2
0
 def test_AddKeyOneLevelOutOfTree(self):
     tree = aBST(0)
     tree.Tree[0] = 0
     result = tree.AddKey(1)
     self.assertEqual(result, -1)
示例#3
0
 def test_AddKeyOneLevelAlreadyExist(self):
     tree = aBST(0)
     tree.Tree[0] = 0
     result = tree.AddKey(0)
     self.assertEqual(result, 0)
示例#4
0
 def test_AddKeyOneLevelSuccess(self):
     tree = aBST(0)
     result = tree.AddKey(0)
     self.assertEqual(result, 0)
示例#5
0
 def test_AddKeyEmptyTree(self):
     tree = aBST(-1)
     result = tree.AddKey(0)
     self.assertEqual(result, -1)
示例#6
0
 def test_FindKeyIndexOneLevelUnsuccess(self):
     tree = aBST(0)
     tree.Tree[0] = 1
     result = tree.FindKeyIndex(2)
     self.assertTrue(result is None)
示例#7
0
 def test_FindKeyIndexOneLevelEmpty(self):
     tree = aBST(0)
     result = tree.FindKeyIndex(1)
     self.assertEqual(result, 0)
示例#8
0
 def test_FindKeyIndexOneLevelSuccess(self):
     tree = aBST(0)
     testKey = 1
     tree.Tree[0] = testKey
     result = tree.FindKeyIndex(testKey)
     self.assertEqual(result, 0)
示例#9
0
 def test_FindKeyIndexEmptyTree(self):
     tree = aBST(-1)
     result = tree.FindKeyIndex(1)
     self.assertTrue(result is None)