MCPcopy Create free account
hub / github.com/KentBeck/BPlusTree3 / test_leaf_node_insert

Method test_leaf_node_insert

python/tests/test_bplus_tree.py:196–218  ·  view source on GitHub ↗

Test inserting into a leaf node

(self)

Source from the content-addressed store, hash-verified

194 assert len(leaf) == 0
195
196 def test_leaf_node_insert(self):
197 """Test inserting into a leaf node"""
198 leaf = LeafNode(capacity=4)
199
200 # Insert first item
201 assert leaf.insert(2, "two") is None
202 assert len(leaf) == 1
203 assert leaf.get(2) == "two"
204
205 # Insert before
206 assert leaf.insert(1, "one") is None
207 assert len(leaf) == 2
208 assert leaf.keys == [1, 2]
209
210 # Insert after
211 assert leaf.insert(3, "three") is None
212 assert len(leaf) == 3
213 assert leaf.keys == [1, 2, 3]
214
215 # Update existing
216 assert leaf.insert(2, "TWO") == "two"
217 assert len(leaf) == 3
218 assert leaf.get(2) == "TWO"
219
220 def test_leaf_node_full(self):
221 """Test when leaf node is full"""

Callers

nothing calls this directly

Calls 3

insertMethod · 0.95
getMethod · 0.95
LeafNodeClass · 0.90

Tested by

no test coverage detected