def test_successor_withCompareFunctionAndKeyInBST_shouldReturnInOrderSuccessorOfGivenKey( self): bst = AVLTree(self.cmp) for i in range(10): bst.put([i, 0], 0) for i in range(10): if i == 9: self.assertIsNone(bst.successor([i, 0])) else: self.assertEqual([i + 1, 0], bst.successor([i, 0]))
def test_successor_withKeyInBST_shouldReturnInOrderSuccessorOfGivenKey( self): bst = AVLTree() for i in range(10): bst.put(i, 0) for i in range(10): if i == 9: self.assertIsNone(bst.successor(i)) else: self.assertEqual(i + 1, bst.successor(i))
def test_successor_withCompareFunctionAndKeyNotInBST_shouldReturnNone( self): bst = AVLTree(self.cmp) bst.put([1, 0], 0) bst.put([2, 0], 0) self.assertIsNone(bst.successor([4, 0]))
def test_successor_withKeyNotInBST_shouldReturnNone(self): bst = AVLTree() bst.put(1, 0) bst.put(2, 0) self.assertIsNone(bst.successor(4))