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

Method test_leaf_find_position

python/tests/test_bplus_tree.py:231–247  ·  view source on GitHub ↗

Test finding position for keys

(self)

Source from the content-addressed store, hash-verified

229 assert len(leaf) == 4
230
231 def test_leaf_find_position(self):
232 """Test finding position for keys"""
233 leaf = LeafNode(capacity=4)
234 leaf.insert(10, "ten")
235 leaf.insert(20, "twenty")
236 leaf.insert(30, "thirty")
237
238 # Test finding existing keys
239 assert leaf.find_position(10) == (0, True)
240 assert leaf.find_position(20) == (1, True)
241 assert leaf.find_position(30) == (2, True)
242
243 # Test finding non-existing keys
244 assert leaf.find_position(5) == (0, False) # Before all
245 assert leaf.find_position(15) == (1, False) # Between 10 and 20
246 assert leaf.find_position(25) == (2, False) # Between 20 and 30
247 assert leaf.find_position(35) == (3, False) # After all
248
249
250class TestRemoval:

Callers

nothing calls this directly

Calls 3

insertMethod · 0.95
find_positionMethod · 0.95
LeafNodeClass · 0.90

Tested by

no test coverage detected