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

Method test_find_child_index

python/tests/test_bplus_tree.py:522–538  ·  view source on GitHub ↗

Test finding correct child index

(self)

Source from the content-addressed store, hash-verified

520 assert len(branch) == 0
521
522 def test_find_child_index(self):
523 """Test finding correct child index"""
524 branch = BranchNode(capacity=4)
525 branch.keys = [10, 20, 30]
526
527 # Create dummy leaf nodes as children
528 for i in range(4):
529 branch.children.append(LeafNode(capacity=4))
530
531 # Test finding child indices
532 assert branch.find_child_index(5) == 0 # < 10
533 assert branch.find_child_index(10) == 1 # >= 10, < 20
534 assert branch.find_child_index(15) == 1 # >= 10, < 20
535 assert branch.find_child_index(20) == 2 # >= 20, < 30
536 assert branch.find_child_index(25) == 2 # >= 20, < 30
537 assert branch.find_child_index(30) == 3 # >= 30
538 assert branch.find_child_index(35) == 3 # >= 30
539
540 def test_branch_node_split(self):
541 """Test splitting a branch node"""

Callers

nothing calls this directly

Calls 3

find_child_indexMethod · 0.95
BranchNodeClass · 0.90
LeafNodeClass · 0.90

Tested by

no test coverage detected