コード例 #1
0
    def test_setItem_withNotEqualKeys_shouldInsertNewPairKeyValueIntoTree(
            self):
        bst = Treap()
        for i in range(1, 20):
            bst[i] = str(i)
            self.assertEqual(i, len(bst))

            self.assertIn(i, bst)
            self.assertEqual(str(i), bst[i])
            self.assertEqual(str(i), bst.get(i))

        for i in range(1, 20):
            self.assertIn(i, bst)
            self.assertEqual(str(i), bst[i])
            self.assertEqual(str(i), bst.get(i))
コード例 #2
0
    def test_get_withKeyInBST_shouldReturnAssociatedValue(self):
        bst = Treap()
        for i in range(1, 20):
            bst.put(i, str(i))

        for i in range(1, 20):
            self.assertEqual(str(i), bst.get(i))
コード例 #3
0
    def test_get_withKeyNotInBST_shouldReturnNone(self):
        bst = Treap()
        for i in range(1, 20):
            bst.put(i, str(i))

        for i in range(20, 30):
            self.assertIsNone(bst.get(i))